2002-04-11 03:20:38 +00:00
|
|
|
// Window.cc for Openbox
|
|
|
|
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
|
|
|
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
// stupid macros needed to access some functions in version 2 of the GNU C
|
|
|
|
// library
|
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#endif // _GNU_SOURCE
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "../config.h"
|
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
|
2002-04-16 06:25:00 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
2002-04-11 03:20:38 +00:00
|
|
|
# include <string.h>
|
2002-04-16 06:25:00 +00:00
|
|
|
#endif // HAVE_STRING_H
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
# ifdef HAVE_STDIO_H
|
|
|
|
# include <stdio.h>
|
|
|
|
# endif // HAVE_STDIO_H
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
#include "openbox.h"
|
|
|
|
#include "Iconmenu.h"
|
|
|
|
#include "Screen.h"
|
|
|
|
#include "Toolbar.h"
|
|
|
|
#include "Window.h"
|
|
|
|
#include "Windowmenu.h"
|
|
|
|
#include "Workspace.h"
|
|
|
|
#ifdef SLIT
|
|
|
|
# include "Slit.h"
|
|
|
|
#endif // SLIT
|
2002-04-20 19:53:19 +00:00
|
|
|
#include "Util.h"
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initializes the class with default values/the window's set initial values.
|
|
|
|
*/
|
2002-04-14 14:04:16 +00:00
|
|
|
OpenboxWindow::OpenboxWindow(Openbox &o, Window w, BScreen *s) : openbox(o) {
|
2002-04-11 03:20:38 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
fprintf(stderr, i18n->getMessage(WindowSet, WindowCreating,
|
|
|
|
"OpenboxWindow::OpenboxWindow(): creating 0x%lx\n"),
|
|
|
|
w);
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
client.window = w;
|
2002-04-14 14:04:16 +00:00
|
|
|
display = openbox.getXDisplay();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.grab();
|
2002-04-11 03:20:38 +00:00
|
|
|
if (! validateClient()) return;
|
|
|
|
|
|
|
|
// fetch client size and placement
|
|
|
|
XWindowAttributes wattrib;
|
|
|
|
if ((! XGetWindowAttributes(display, client.window, &wattrib)) ||
|
|
|
|
(! wattrib.screen) || wattrib.override_redirect) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
fprintf(stderr,
|
|
|
|
i18n->getMessage(WindowSet, WindowXGetWindowAttributesFail,
|
|
|
|
"OpenboxWindow::OpenboxWindow(): XGetWindowAttributes "
|
|
|
|
"failed\n"));
|
|
|
|
#endif // DEBUG
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-11 03:20:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s) {
|
|
|
|
screen = s;
|
|
|
|
} else {
|
2002-04-14 14:04:16 +00:00
|
|
|
screen = openbox.searchScreen(RootWindowOfScreen(wattrib.screen));
|
2002-04-11 03:20:38 +00:00
|
|
|
if (! screen) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
fprintf(stderr, i18n->getMessage(WindowSet, WindowCannotFindScreen,
|
|
|
|
"OpenboxWindow::OpenboxWindow(): can't find screen\n"
|
|
|
|
"\tfor root window 0x%lx\n"),
|
|
|
|
RootWindowOfScreen(wattrib.screen));
|
|
|
|
#endif // DEBUG
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-11 03:20:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flags.moving = flags.resizing = flags.shaded = flags.visible =
|
|
|
|
flags.iconic = flags.transient = flags.focused =
|
|
|
|
flags.stuck = flags.modal = flags.send_focus_message =
|
|
|
|
flags.shaped = flags.managed = False;
|
|
|
|
flags.maximized = 0;
|
|
|
|
|
|
|
|
openbox_attrib.workspace = workspace_number = window_number = -1;
|
|
|
|
|
|
|
|
openbox_attrib.flags = openbox_attrib.attrib = openbox_attrib.stack
|
|
|
|
= openbox_attrib.decoration = 0l;
|
|
|
|
openbox_attrib.premax_x = openbox_attrib.premax_y = 0;
|
|
|
|
openbox_attrib.premax_w = openbox_attrib.premax_h = 0;
|
|
|
|
|
|
|
|
frame.window = frame.plate = frame.title = frame.handle = None;
|
|
|
|
frame.close_button = frame.iconify_button = frame.maximize_button = None;
|
|
|
|
frame.right_grip = frame.left_grip = None;
|
|
|
|
|
|
|
|
frame.utitle = frame.ftitle = frame.uhandle = frame.fhandle = None;
|
|
|
|
frame.ulabel = frame.flabel = frame.ubutton = frame.fbutton = None;
|
|
|
|
frame.pbutton = frame.ugrip = frame.fgrip = None;
|
|
|
|
|
|
|
|
decorations.titlebar = decorations.border = decorations.handle = True;
|
|
|
|
decorations.iconify = decorations.maximize = decorations.menu = True;
|
|
|
|
functions.resize = functions.move = functions.iconify =
|
|
|
|
functions.maximize = True;
|
|
|
|
functions.close = decorations.close = False;
|
|
|
|
|
|
|
|
client.wm_hint_flags = client.normal_hint_flags = 0;
|
|
|
|
client.transient_for = client.transient = 0;
|
|
|
|
client.title = 0;
|
|
|
|
client.title_len = 0;
|
|
|
|
client.icon_title = 0;
|
|
|
|
client.mwm_hint = (MwmHints *) 0;
|
|
|
|
client.openbox_hint = (OpenboxHints *) 0;
|
|
|
|
|
|
|
|
// get the initial size and location of client window (relative to the
|
|
|
|
// _root window_). This position is the reference point used with the
|
|
|
|
// window's gravity to find the window's initial position.
|
|
|
|
client.x = wattrib.x;
|
|
|
|
client.y = wattrib.y;
|
|
|
|
client.width = wattrib.width;
|
|
|
|
client.height = wattrib.height;
|
|
|
|
client.old_bw = wattrib.border_width;
|
|
|
|
|
|
|
|
windowmenu = 0;
|
|
|
|
lastButtonPressTime = 0;
|
|
|
|
image_ctrl = screen->getImageControl();
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
timer = new BTimer(openbox, *this);
|
|
|
|
timer->setTimeout(openbox.getAutoRaiseDelay());
|
2002-04-11 03:20:38 +00:00
|
|
|
timer->fireOnce(True);
|
|
|
|
|
|
|
|
getOpenboxHints();
|
|
|
|
if (! client.openbox_hint)
|
|
|
|
getMWMHints();
|
|
|
|
|
|
|
|
// get size, aspect, minimum/maximum size and other hints set by the
|
|
|
|
// client
|
|
|
|
getWMProtocols();
|
|
|
|
getWMHints();
|
|
|
|
getWMNormalHints();
|
|
|
|
|
|
|
|
#ifdef SLIT
|
|
|
|
if (client.initial_state == WithdrawnState) {
|
|
|
|
screen->getSlit()->addClient(client.window);
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-18 20:56:23 +00:00
|
|
|
delete this;
|
2002-04-11 03:20:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif // SLIT
|
|
|
|
|
|
|
|
flags.managed = True;
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.saveWindowSearch(client.window, this);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
// determine if this is a transient window
|
|
|
|
Window win;
|
|
|
|
if (XGetTransientForHint(display, client.window, &win)) {
|
|
|
|
if (win && (win != client.window)) {
|
|
|
|
OpenboxWindow *tr;
|
2002-04-14 14:04:16 +00:00
|
|
|
if ((tr = openbox.searchWindow(win))) {
|
2002-04-11 03:20:38 +00:00
|
|
|
while (tr->client.transient) tr = tr->client.transient;
|
|
|
|
client.transient_for = tr;
|
|
|
|
tr->client.transient = this;
|
|
|
|
flags.stuck = client.transient_for->flags.stuck;
|
|
|
|
flags.transient = True;
|
|
|
|
} else if (win == client.window_group) {
|
2002-04-14 14:04:16 +00:00
|
|
|
if ((tr = openbox.searchGroup(win, this))) {
|
2002-04-11 03:20:38 +00:00
|
|
|
while (tr->client.transient) tr = tr->client.transient;
|
|
|
|
client.transient_for = tr;
|
|
|
|
tr->client.transient = this;
|
|
|
|
flags.stuck = client.transient_for->flags.stuck;
|
|
|
|
flags.transient = True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (win == screen->getRootWindow()) flags.modal = True;
|
|
|
|
}
|
|
|
|
|
|
|
|
// adjust the window decorations based on transience and window sizes
|
|
|
|
if (flags.transient)
|
|
|
|
decorations.maximize = decorations.handle = functions.maximize = False;
|
|
|
|
|
|
|
|
if ((client.normal_hint_flags & PMinSize) &&
|
|
|
|
(client.normal_hint_flags & PMaxSize) &&
|
|
|
|
client.max_width <= client.min_width &&
|
|
|
|
client.max_height <= client.min_height) {
|
|
|
|
decorations.maximize = decorations.handle =
|
|
|
|
functions.resize = functions.maximize = False;
|
|
|
|
}
|
|
|
|
upsize();
|
|
|
|
|
2002-04-28 19:14:54 +00:00
|
|
|
place_window = true;
|
2002-04-14 14:04:16 +00:00
|
|
|
if (openbox.isStartup() || flags.transient ||
|
2002-04-11 03:20:38 +00:00
|
|
|
client.normal_hint_flags & (PPosition|USPosition)) {
|
|
|
|
setGravityOffsets();
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
if ((openbox.isStartup()) ||
|
2002-04-11 03:20:38 +00:00
|
|
|
(frame.x >= 0 &&
|
|
|
|
(signed) (frame.y + frame.y_border) >= 0 &&
|
2002-04-14 18:48:32 +00:00
|
|
|
frame.x <= (signed) screen->size().w() &&
|
|
|
|
frame.y <= (signed) screen->size().h()))
|
2002-04-28 19:14:54 +00:00
|
|
|
place_window = false;
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
frame.window = createToplevelWindow(frame.x, frame.y, frame.width,
|
|
|
|
frame.height,
|
|
|
|
frame.border_w);
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.saveWindowSearch(frame.window, this);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
frame.plate = createChildWindow(frame.window);
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.saveWindowSearch(frame.plate, this);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
if (decorations.titlebar) {
|
|
|
|
frame.title = createChildWindow(frame.window);
|
|
|
|
frame.label = createChildWindow(frame.title);
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.saveWindowSearch(frame.title, this);
|
|
|
|
openbox.saveWindowSearch(frame.label, this);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (decorations.handle) {
|
|
|
|
frame.handle = createChildWindow(frame.window);
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.saveWindowSearch(frame.handle, this);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
frame.left_grip =
|
2002-04-14 14:04:16 +00:00
|
|
|
createChildWindow(frame.handle, openbox.getLowerLeftAngleCursor());
|
|
|
|
openbox.saveWindowSearch(frame.left_grip, this);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
frame.right_grip =
|
2002-04-14 14:04:16 +00:00
|
|
|
createChildWindow(frame.handle, openbox.getLowerRightAngleCursor());
|
|
|
|
openbox.saveWindowSearch(frame.right_grip, this);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
associateClientWindow();
|
|
|
|
|
2002-04-17 08:30:55 +00:00
|
|
|
if (! screen->sloppyFocus())
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.grabButton(Button1, 0, frame.plate, True, ButtonPressMask,
|
2002-04-11 03:20:38 +00:00
|
|
|
GrabModeSync, GrabModeSync, None, None);
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.grabButton(Button1, Mod1Mask, frame.window, True,
|
2002-04-11 03:20:38 +00:00
|
|
|
ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
|
2002-04-14 14:04:16 +00:00
|
|
|
GrabModeAsync, None, openbox.getMoveCursor());
|
|
|
|
openbox.grabButton(Button2, Mod1Mask, frame.window, True,
|
2002-04-11 03:20:38 +00:00
|
|
|
ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None);
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.grabButton(Button3, Mod1Mask, frame.window, True,
|
2002-04-11 03:20:38 +00:00
|
|
|
ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
|
|
|
|
GrabModeAsync, None, None);
|
|
|
|
|
|
|
|
positionWindows();
|
|
|
|
XRaiseWindow(display, frame.plate);
|
|
|
|
XMapSubwindows(display, frame.plate);
|
|
|
|
if (decorations.titlebar) XMapSubwindows(display, frame.title);
|
|
|
|
XMapSubwindows(display, frame.window);
|
|
|
|
|
|
|
|
if (decorations.menu)
|
2002-04-14 11:37:22 +00:00
|
|
|
windowmenu = new Windowmenu(*this);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
decorate();
|
|
|
|
|
2002-04-12 06:05:04 +00:00
|
|
|
if (workspace_number < 0 || workspace_number >= screen->getWorkspaceCount())
|
2002-04-11 03:20:38 +00:00
|
|
|
screen->getCurrentWorkspace()->addWindow(this, place_window);
|
|
|
|
else
|
|
|
|
screen->getWorkspace(workspace_number)->addWindow(this, place_window);
|
|
|
|
|
|
|
|
configure(frame.x, frame.y, frame.width, frame.height);
|
|
|
|
|
|
|
|
if (flags.shaded) {
|
|
|
|
flags.shaded = False;
|
|
|
|
shade();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags.maximized && functions.maximize) {
|
|
|
|
unsigned int button = flags.maximized;
|
|
|
|
flags.maximized = 0;
|
|
|
|
maximize(button);
|
|
|
|
}
|
|
|
|
|
|
|
|
setFocusFlag(False);
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OpenboxWindow::~OpenboxWindow(void) {
|
|
|
|
if (flags.moving || flags.resizing) {
|
|
|
|
screen->hideGeometry();
|
|
|
|
XUngrabPointer(display, CurrentTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (workspace_number != -1 && window_number != -1)
|
|
|
|
screen->getWorkspace(workspace_number)->removeWindow(this);
|
|
|
|
else if (flags.iconic)
|
|
|
|
screen->removeIcon(this);
|
|
|
|
|
|
|
|
if (timer) {
|
|
|
|
if (timer->isTiming()) timer->stop();
|
|
|
|
delete timer;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (windowmenu) delete windowmenu;
|
|
|
|
|
|
|
|
if (client.title)
|
|
|
|
delete [] client.title;
|
|
|
|
|
|
|
|
if (client.icon_title)
|
|
|
|
delete [] client.icon_title;
|
|
|
|
|
|
|
|
if (client.mwm_hint)
|
|
|
|
XFree(client.mwm_hint);
|
|
|
|
|
|
|
|
if (client.openbox_hint)
|
|
|
|
XFree(client.openbox_hint);
|
|
|
|
|
|
|
|
if (client.window_group)
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.removeGroupSearch(client.window_group);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
if (flags.transient && client.transient_for)
|
|
|
|
client.transient_for->client.transient = client.transient;
|
|
|
|
if (client.transient)
|
|
|
|
client.transient->client.transient_for = client.transient_for;
|
|
|
|
|
|
|
|
if (frame.close_button) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.removeWindowSearch(frame.close_button);
|
2002-04-11 03:20:38 +00:00
|
|
|
XDestroyWindow(display, frame.close_button);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frame.iconify_button) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.removeWindowSearch(frame.iconify_button);
|
2002-04-11 03:20:38 +00:00
|
|
|
XDestroyWindow(display, frame.iconify_button);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frame.maximize_button) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.removeWindowSearch(frame.maximize_button);
|
2002-04-11 03:20:38 +00:00
|
|
|
XDestroyWindow(display, frame.maximize_button);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frame.title) {
|
|
|
|
if (frame.ftitle)
|
|
|
|
image_ctrl->removeImage(frame.ftitle);
|
|
|
|
|
|
|
|
if (frame.utitle)
|
|
|
|
image_ctrl->removeImage(frame.utitle);
|
|
|
|
|
|
|
|
if (frame.flabel)
|
|
|
|
image_ctrl->removeImage(frame.flabel);
|
|
|
|
|
|
|
|
if( frame.ulabel)
|
|
|
|
image_ctrl->removeImage(frame.ulabel);
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.removeWindowSearch(frame.label);
|
|
|
|
openbox.removeWindowSearch(frame.title);
|
2002-04-11 03:20:38 +00:00
|
|
|
XDestroyWindow(display, frame.label);
|
|
|
|
XDestroyWindow(display, frame.title);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frame.handle) {
|
|
|
|
if (frame.fhandle)
|
|
|
|
image_ctrl->removeImage(frame.fhandle);
|
|
|
|
|
|
|
|
if (frame.uhandle)
|
|
|
|
image_ctrl->removeImage(frame.uhandle);
|
|
|
|
|
|
|
|
if (frame.fgrip)
|
|
|
|
image_ctrl->removeImage(frame.fgrip);
|
|
|
|
|
|
|
|
if (frame.ugrip)
|
|
|
|
image_ctrl->removeImage(frame.ugrip);
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.removeWindowSearch(frame.handle);
|
|
|
|
openbox.removeWindowSearch(frame.right_grip);
|
|
|
|
openbox.removeWindowSearch(frame.left_grip);
|
2002-04-11 03:20:38 +00:00
|
|
|
XDestroyWindow(display, frame.right_grip);
|
|
|
|
XDestroyWindow(display, frame.left_grip);
|
|
|
|
XDestroyWindow(display, frame.handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frame.fbutton)
|
|
|
|
image_ctrl->removeImage(frame.fbutton);
|
|
|
|
|
|
|
|
if (frame.ubutton)
|
|
|
|
image_ctrl->removeImage(frame.ubutton);
|
|
|
|
|
|
|
|
if (frame.pbutton)
|
|
|
|
image_ctrl->removeImage(frame.pbutton);
|
|
|
|
|
|
|
|
if (frame.plate) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.removeWindowSearch(frame.plate);
|
2002-04-11 03:20:38 +00:00
|
|
|
XDestroyWindow(display, frame.plate);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frame.window) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.removeWindowSearch(frame.window);
|
2002-04-11 03:20:38 +00:00
|
|
|
XDestroyWindow(display, frame.window);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags.managed) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.removeWindowSearch(client.window);
|
2002-04-11 03:20:38 +00:00
|
|
|
screen->removeNetizen(client.window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Creates a new top level window, with a given location, size, and border
|
|
|
|
* width.
|
|
|
|
* Returns: the newly created window
|
|
|
|
*/
|
|
|
|
Window OpenboxWindow::createToplevelWindow(int x, int y, unsigned int width,
|
|
|
|
unsigned int height,
|
|
|
|
unsigned int borderwidth)
|
|
|
|
{
|
|
|
|
XSetWindowAttributes attrib_create;
|
|
|
|
unsigned long create_mask = CWBackPixmap | CWBorderPixel | CWColormap |
|
|
|
|
CWOverrideRedirect | CWEventMask;
|
|
|
|
|
|
|
|
attrib_create.background_pixmap = None;
|
|
|
|
attrib_create.colormap = screen->getColormap();
|
|
|
|
attrib_create.override_redirect = True;
|
|
|
|
attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask |
|
|
|
|
ButtonMotionMask | EnterWindowMask;
|
|
|
|
|
|
|
|
return XCreateWindow(display, screen->getRootWindow(), x, y, width, height,
|
|
|
|
borderwidth, screen->getDepth(), InputOutput,
|
|
|
|
screen->getVisual(), create_mask,
|
|
|
|
&attrib_create);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Creates a child window, and optionally associates a given cursor with
|
|
|
|
* the new window.
|
|
|
|
*/
|
|
|
|
Window OpenboxWindow::createChildWindow(Window parent, Cursor cursor) {
|
|
|
|
XSetWindowAttributes attrib_create;
|
|
|
|
unsigned long create_mask = CWBackPixmap | CWBorderPixel |
|
|
|
|
CWEventMask;
|
|
|
|
|
|
|
|
attrib_create.background_pixmap = None;
|
|
|
|
attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask |
|
|
|
|
ButtonMotionMask | ExposureMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask;
|
|
|
|
|
|
|
|
if (cursor) {
|
|
|
|
create_mask |= CWCursor;
|
|
|
|
attrib_create.cursor = cursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
return XCreateWindow(display, parent, 0, 0, 1, 1, 0, screen->getDepth(),
|
|
|
|
InputOutput, screen->getVisual(), create_mask,
|
|
|
|
&attrib_create);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::associateClientWindow(void) {
|
|
|
|
XSetWindowBorderWidth(display, client.window, 0);
|
|
|
|
getWMName();
|
|
|
|
getWMIconName();
|
|
|
|
|
|
|
|
XChangeSaveSet(display, client.window, SetModeInsert);
|
|
|
|
XSetWindowAttributes attrib_set;
|
|
|
|
|
|
|
|
XSelectInput(display, frame.plate, NoEventMask);
|
|
|
|
XReparentWindow(display, client.window, frame.plate, 0, 0);
|
|
|
|
XSelectInput(display, frame.plate, SubstructureRedirectMask);
|
|
|
|
|
|
|
|
XFlush(display);
|
|
|
|
|
|
|
|
attrib_set.event_mask = PropertyChangeMask | StructureNotifyMask |
|
|
|
|
FocusChangeMask;
|
|
|
|
attrib_set.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask |
|
|
|
|
ButtonMotionMask;
|
|
|
|
|
|
|
|
XChangeWindowAttributes(display, client.window, CWEventMask|CWDontPropagate,
|
|
|
|
&attrib_set);
|
|
|
|
|
|
|
|
#ifdef SHAPE
|
2002-04-14 14:04:16 +00:00
|
|
|
if (openbox.hasShapeExtensions()) {
|
2002-04-11 03:20:38 +00:00
|
|
|
XShapeSelectInput(display, client.window, ShapeNotifyMask);
|
|
|
|
|
|
|
|
int foo;
|
|
|
|
unsigned int ufoo;
|
|
|
|
|
|
|
|
XShapeQueryExtents(display, client.window, &flags.shaped, &foo, &foo,
|
|
|
|
&ufoo, &ufoo, &foo, &foo, &foo, &ufoo, &ufoo);
|
|
|
|
|
|
|
|
if (flags.shaped) {
|
|
|
|
XShapeCombineShape(display, frame.window, ShapeBounding,
|
|
|
|
frame.mwm_border_w, frame.y_border +
|
|
|
|
frame.mwm_border_w, client.window,
|
|
|
|
ShapeBounding, ShapeSet);
|
|
|
|
|
|
|
|
int num = 1;
|
|
|
|
XRectangle xrect[2];
|
|
|
|
xrect[0].x = xrect[0].y = 0;
|
|
|
|
xrect[0].width = frame.width;
|
|
|
|
xrect[0].height = frame.y_border;
|
|
|
|
|
|
|
|
if (decorations.handle) {
|
|
|
|
xrect[1].x = 0;
|
|
|
|
xrect[1].y = frame.y_handle;
|
|
|
|
xrect[1].width = frame.width;
|
|
|
|
xrect[1].height = frame.handle_h + frame.border_w;
|
|
|
|
num++;
|
|
|
|
}
|
|
|
|
|
|
|
|
XShapeCombineRectangles(display, frame.window, ShapeBounding, 0, 0,
|
|
|
|
xrect, num, ShapeUnion, Unsorted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // SHAPE
|
|
|
|
|
|
|
|
if (decorations.iconify) createIconifyButton();
|
|
|
|
if (decorations.maximize) createMaximizeButton();
|
|
|
|
if (decorations.close) createCloseButton();
|
|
|
|
|
|
|
|
if (frame.ubutton) {
|
|
|
|
if (frame.close_button)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.close_button, frame.ubutton);
|
|
|
|
if (frame.maximize_button)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.maximize_button,
|
|
|
|
frame.ubutton);
|
|
|
|
if (frame.iconify_button)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.iconify_button, frame.ubutton);
|
|
|
|
} else {
|
|
|
|
if (frame.close_button)
|
|
|
|
XSetWindowBackground(display, frame.close_button, frame.ubutton_pixel);
|
|
|
|
if (frame.maximize_button)
|
|
|
|
XSetWindowBackground(display, frame.maximize_button,
|
|
|
|
frame.ubutton_pixel);
|
|
|
|
if (frame.iconify_button)
|
|
|
|
XSetWindowBackground(display, frame.iconify_button, frame.ubutton_pixel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::decorate(void) {
|
|
|
|
Pixmap tmp = frame.fbutton;
|
|
|
|
BTexture *texture = &(screen->getWindowStyle()->b_focus);
|
|
|
|
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
|
|
|
frame.fbutton = None;
|
|
|
|
frame.fbutton_pixel = texture->getColor()->getPixel();
|
|
|
|
} else {
|
|
|
|
frame.fbutton =
|
|
|
|
image_ctrl->renderImage(frame.button_w, frame.button_h, texture);
|
|
|
|
}
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
|
|
|
|
tmp = frame.ubutton;
|
|
|
|
texture = &(screen->getWindowStyle()->b_unfocus);
|
|
|
|
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
|
|
|
frame.ubutton = None;
|
|
|
|
frame.ubutton_pixel = texture->getColor()->getPixel();
|
|
|
|
} else {
|
|
|
|
frame.ubutton =
|
|
|
|
image_ctrl->renderImage(frame.button_w, frame.button_h, texture);
|
|
|
|
}
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
|
|
|
|
tmp = frame.pbutton;
|
|
|
|
texture = &(screen->getWindowStyle()->b_pressed);
|
|
|
|
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
|
|
|
frame.pbutton = None;
|
|
|
|
frame.pbutton_pixel = texture->getColor()->getPixel();
|
|
|
|
} else {
|
|
|
|
frame.pbutton =
|
|
|
|
image_ctrl->renderImage(frame.button_w, frame.button_h, texture);
|
|
|
|
}
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
|
|
|
|
if (decorations.titlebar) {
|
|
|
|
tmp = frame.ftitle;
|
|
|
|
texture = &(screen->getWindowStyle()->t_focus);
|
|
|
|
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
|
|
|
frame.ftitle = None;
|
|
|
|
frame.ftitle_pixel = texture->getColor()->getPixel();
|
|
|
|
} else {
|
|
|
|
frame.ftitle =
|
|
|
|
image_ctrl->renderImage(frame.width, frame.title_h, texture);
|
|
|
|
}
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
|
|
|
|
tmp = frame.utitle;
|
|
|
|
texture = &(screen->getWindowStyle()->t_unfocus);
|
|
|
|
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
|
|
|
frame.utitle = None;
|
|
|
|
frame.utitle_pixel = texture->getColor()->getPixel();
|
|
|
|
} else {
|
|
|
|
frame.utitle =
|
|
|
|
image_ctrl->renderImage(frame.width, frame.title_h, texture);
|
|
|
|
}
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
|
|
|
|
XSetWindowBorder(display, frame.title,
|
|
|
|
screen->getBorderColor()->getPixel());
|
|
|
|
|
|
|
|
decorateLabel();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (decorations.border) {
|
|
|
|
frame.fborder_pixel = screen->getWindowStyle()->f_focus.getPixel();
|
|
|
|
frame.uborder_pixel = screen->getWindowStyle()->f_unfocus.getPixel();
|
|
|
|
openbox_attrib.flags |= AttribDecoration;
|
|
|
|
openbox_attrib.decoration = DecorNormal;
|
|
|
|
} else {
|
|
|
|
openbox_attrib.flags |= AttribDecoration;
|
|
|
|
openbox_attrib.decoration = DecorNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (decorations.handle) {
|
|
|
|
tmp = frame.fhandle;
|
|
|
|
texture = &(screen->getWindowStyle()->h_focus);
|
|
|
|
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
|
|
|
frame.fhandle = None;
|
|
|
|
frame.fhandle_pixel = texture->getColor()->getPixel();
|
|
|
|
} else {
|
|
|
|
frame.fhandle =
|
|
|
|
image_ctrl->renderImage(frame.width, frame.handle_h, texture);
|
|
|
|
}
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
|
|
|
|
tmp = frame.uhandle;
|
|
|
|
texture = &(screen->getWindowStyle()->h_unfocus);
|
|
|
|
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
|
|
|
frame.uhandle = None;
|
|
|
|
frame.uhandle_pixel = texture->getColor()->getPixel();
|
|
|
|
} else {
|
|
|
|
frame.uhandle =
|
|
|
|
image_ctrl->renderImage(frame.width, frame.handle_h, texture);
|
|
|
|
}
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
|
|
|
|
tmp = frame.fgrip;
|
|
|
|
texture = &(screen->getWindowStyle()->g_focus);
|
|
|
|
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
|
|
|
frame.fgrip = None;
|
|
|
|
frame.fgrip_pixel = texture->getColor()->getPixel();
|
|
|
|
} else {
|
|
|
|
frame.fgrip =
|
|
|
|
image_ctrl->renderImage(frame.grip_w, frame.grip_h, texture);
|
|
|
|
}
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
|
|
|
|
tmp = frame.ugrip;
|
|
|
|
texture = &(screen->getWindowStyle()->g_unfocus);
|
|
|
|
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
|
|
|
frame.ugrip = None;
|
|
|
|
frame.ugrip_pixel = texture->getColor()->getPixel();
|
|
|
|
} else {
|
|
|
|
frame.ugrip =
|
|
|
|
image_ctrl->renderImage(frame.grip_w, frame.grip_h, texture);
|
|
|
|
}
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
|
|
|
|
XSetWindowBorder(display, frame.handle,
|
|
|
|
screen->getBorderColor()->getPixel());
|
|
|
|
XSetWindowBorder(display, frame.left_grip,
|
|
|
|
screen->getBorderColor()->getPixel());
|
|
|
|
XSetWindowBorder(display, frame.right_grip,
|
|
|
|
screen->getBorderColor()->getPixel());
|
|
|
|
}
|
|
|
|
|
|
|
|
XSetWindowBorder(display, frame.window,
|
|
|
|
screen->getBorderColor()->getPixel());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::decorateLabel(void) {
|
|
|
|
Pixmap tmp = frame.flabel;
|
|
|
|
BTexture *texture = &(screen->getWindowStyle()->l_focus);
|
|
|
|
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
|
|
|
frame.flabel = None;
|
|
|
|
frame.flabel_pixel = texture->getColor()->getPixel();
|
|
|
|
} else {
|
|
|
|
frame.flabel =
|
|
|
|
image_ctrl->renderImage(frame.label_w, frame.label_h, texture);
|
|
|
|
}
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
|
|
|
|
tmp = frame.ulabel;
|
|
|
|
texture = &(screen->getWindowStyle()->l_unfocus);
|
|
|
|
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
|
|
|
frame.ulabel = None;
|
|
|
|
frame.ulabel_pixel = texture->getColor()->getPixel();
|
|
|
|
} else {
|
|
|
|
frame.ulabel =
|
|
|
|
image_ctrl->renderImage(frame.label_w, frame.label_h, texture);
|
|
|
|
}
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::createCloseButton(void) {
|
|
|
|
if (decorations.close && frame.title != None) {
|
|
|
|
frame.close_button = createChildWindow(frame.title);
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.saveWindowSearch(frame.close_button, this);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::createIconifyButton(void) {
|
|
|
|
if (decorations.iconify && frame.title != None) {
|
|
|
|
frame.iconify_button = createChildWindow(frame.title);
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.saveWindowSearch(frame.iconify_button, this);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::createMaximizeButton(void) {
|
|
|
|
if (decorations.maximize && frame.title != None) {
|
|
|
|
frame.maximize_button = createChildWindow(frame.title);
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.saveWindowSearch(frame.maximize_button, this);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::positionButtons(Bool redecorate_label) {
|
2002-04-14 14:04:16 +00:00
|
|
|
const char *format = openbox.getTitleBarLayout();
|
2002-04-11 03:20:38 +00:00
|
|
|
const unsigned int bw = frame.bevel_w + 1;
|
|
|
|
const unsigned int by = frame.bevel_w + 1;
|
|
|
|
unsigned int bx = frame.bevel_w + 1;
|
|
|
|
unsigned int bcount = strlen(format) - 1;
|
|
|
|
|
|
|
|
if (!decorations.close)
|
|
|
|
bcount--;
|
|
|
|
if (!decorations.maximize)
|
|
|
|
bcount--;
|
|
|
|
if (!decorations.iconify)
|
|
|
|
bcount--;
|
|
|
|
frame.label_w = frame.width - bx * 2 - (frame.button_w + bw) * bcount;
|
|
|
|
|
|
|
|
bool hasclose, hasiconify, hasmaximize;
|
|
|
|
hasclose = hasiconify = hasmaximize = false;
|
|
|
|
|
|
|
|
for (int i = 0; format[i] != '\0' && i < 4; i++) {
|
|
|
|
switch(format[i]) {
|
|
|
|
case 'C':
|
|
|
|
if (decorations.close && frame.close_button != None) {
|
|
|
|
XMoveResizeWindow(display, frame.close_button, bx, by,
|
|
|
|
frame.button_w, frame.button_h);
|
|
|
|
XMapWindow(display, frame.close_button);
|
|
|
|
XClearWindow(display, frame.close_button);
|
|
|
|
bx += frame.button_w + bw;
|
|
|
|
hasclose = true;
|
|
|
|
} else if (frame.close_button)
|
|
|
|
XUnmapWindow(display, frame.close_button);
|
|
|
|
break;
|
|
|
|
case 'I':
|
|
|
|
if (decorations.iconify && frame.iconify_button != None) {
|
|
|
|
XMoveResizeWindow(display, frame.iconify_button, bx, by,
|
|
|
|
frame.button_w, frame.button_h);
|
|
|
|
XMapWindow(display, frame.iconify_button);
|
|
|
|
XClearWindow(display, frame.iconify_button);
|
|
|
|
bx += frame.button_w + bw;
|
|
|
|
hasiconify = true;
|
|
|
|
} else if (frame.close_button)
|
|
|
|
XUnmapWindow(display, frame.close_button);
|
|
|
|
break;
|
|
|
|
case 'M':
|
|
|
|
if (decorations.maximize && frame.maximize_button != None) {
|
|
|
|
XMoveResizeWindow(display, frame.maximize_button, bx, by,
|
|
|
|
frame.button_w, frame.button_h);
|
|
|
|
XMapWindow(display, frame.maximize_button);
|
|
|
|
XClearWindow(display, frame.maximize_button);
|
|
|
|
bx += frame.button_w + bw;
|
|
|
|
hasmaximize = true;
|
|
|
|
} else if (frame.close_button)
|
|
|
|
XUnmapWindow(display, frame.close_button);
|
|
|
|
break;
|
|
|
|
case 'L':
|
|
|
|
XMoveResizeWindow(display, frame.label, bx, by - 1,
|
|
|
|
frame.label_w, frame.label_h);
|
|
|
|
bx += frame.label_w + bw;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hasclose) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.removeWindowSearch(frame.close_button);
|
2002-04-11 03:20:38 +00:00
|
|
|
XDestroyWindow(display, frame.close_button);
|
|
|
|
}
|
|
|
|
if (!hasiconify) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.removeWindowSearch(frame.iconify_button);
|
2002-04-11 03:20:38 +00:00
|
|
|
XDestroyWindow(display, frame.iconify_button);
|
|
|
|
}
|
|
|
|
if (!hasmaximize) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.removeWindowSearch(frame.maximize_button);
|
2002-04-11 03:20:38 +00:00
|
|
|
XDestroyWindow(display, frame.maximize_button);
|
|
|
|
}
|
|
|
|
if (redecorate_label)
|
|
|
|
decorateLabel();
|
|
|
|
redrawLabel();
|
|
|
|
redrawAllButtons();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::reconfigure(void) {
|
|
|
|
upsize();
|
|
|
|
|
|
|
|
client.x = frame.x + frame.mwm_border_w + frame.border_w;
|
|
|
|
client.y = frame.y + frame.y_border + frame.mwm_border_w +
|
|
|
|
frame.border_w;
|
|
|
|
|
|
|
|
if (client.title) {
|
|
|
|
if (i18n->multibyte()) {
|
|
|
|
XRectangle ink, logical;
|
|
|
|
XmbTextExtents(screen->getWindowStyle()->fontset,
|
|
|
|
client.title, client.title_len, &ink, &logical);
|
|
|
|
client.title_text_w = logical.width;
|
|
|
|
} else {
|
|
|
|
client.title_text_w = XTextWidth(screen->getWindowStyle()->font,
|
|
|
|
client.title, client.title_len);
|
|
|
|
}
|
|
|
|
client.title_text_w += (frame.bevel_w * 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
positionWindows();
|
|
|
|
decorate();
|
|
|
|
|
|
|
|
XClearWindow(display, frame.window);
|
|
|
|
setFocusFlag(flags.focused);
|
|
|
|
|
|
|
|
configure(frame.x, frame.y, frame.width, frame.height);
|
|
|
|
|
2002-04-17 08:30:55 +00:00
|
|
|
if (! screen->sloppyFocus())
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.grabButton(Button1, 0, frame.plate, True, ButtonPressMask,
|
2002-04-11 03:20:38 +00:00
|
|
|
GrabModeSync, GrabModeSync, None, None);
|
|
|
|
else
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrabButton(Button1, 0, frame.plate);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
if (windowmenu) {
|
|
|
|
windowmenu->move(windowmenu->getX(), frame.y + frame.title_h);
|
|
|
|
windowmenu->reconfigure();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::positionWindows(void) {
|
|
|
|
XResizeWindow(display, frame.window, frame.width,
|
|
|
|
((flags.shaded) ? frame.title_h : frame.height));
|
|
|
|
XSetWindowBorderWidth(display, frame.window, frame.border_w);
|
|
|
|
XSetWindowBorderWidth(display, frame.plate, frame.mwm_border_w);
|
|
|
|
XMoveResizeWindow(display, frame.plate, 0, frame.y_border,
|
|
|
|
client.width, client.height);
|
|
|
|
XMoveResizeWindow(display, client.window, 0, 0, client.width, client.height);
|
|
|
|
|
|
|
|
if (decorations.titlebar) {
|
|
|
|
XSetWindowBorderWidth(display, frame.title, frame.border_w);
|
|
|
|
XMoveResizeWindow(display, frame.title, -frame.border_w,
|
|
|
|
-frame.border_w, frame.width, frame.title_h);
|
|
|
|
|
|
|
|
positionButtons();
|
|
|
|
} else if (frame.title) {
|
|
|
|
XUnmapWindow(display, frame.title);
|
|
|
|
}
|
|
|
|
if (decorations.handle) {
|
|
|
|
XSetWindowBorderWidth(display, frame.handle, frame.border_w);
|
|
|
|
XSetWindowBorderWidth(display, frame.left_grip, frame.border_w);
|
|
|
|
XSetWindowBorderWidth(display, frame.right_grip, frame.border_w);
|
|
|
|
|
|
|
|
XMoveResizeWindow(display, frame.handle, -frame.border_w,
|
|
|
|
frame.y_handle - frame.border_w,
|
|
|
|
frame.width, frame.handle_h);
|
|
|
|
XMoveResizeWindow(display, frame.left_grip, -frame.border_w,
|
|
|
|
-frame.border_w, frame.grip_w, frame.grip_h);
|
|
|
|
XMoveResizeWindow(display, frame.right_grip,
|
|
|
|
frame.width - frame.grip_w - frame.border_w,
|
|
|
|
-frame.border_w, frame.grip_w, frame.grip_h);
|
|
|
|
XMapSubwindows(display, frame.handle);
|
|
|
|
} else if (frame.handle) {
|
|
|
|
XUnmapWindow(display, frame.handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::getWMName(void) {
|
|
|
|
if (client.title) {
|
|
|
|
delete [] client.title;
|
|
|
|
client.title = (char *) 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
XTextProperty text_prop;
|
|
|
|
char **list;
|
|
|
|
int num;
|
|
|
|
|
|
|
|
if (XGetWMName(display, client.window, &text_prop)) {
|
|
|
|
if (text_prop.value && text_prop.nitems > 0) {
|
|
|
|
if (text_prop.encoding != XA_STRING) {
|
|
|
|
text_prop.nitems = strlen((char *) text_prop.value);
|
|
|
|
|
|
|
|
if ((XmbTextPropertyToTextList(display, &text_prop,
|
|
|
|
&list, &num) == Success) &&
|
|
|
|
(num > 0) && *list) {
|
|
|
|
client.title = bstrdup(*list);
|
|
|
|
XFreeStringList(list);
|
|
|
|
} else {
|
|
|
|
client.title = bstrdup((char *) text_prop.value);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
client.title = bstrdup((char *) text_prop.value);
|
|
|
|
}
|
|
|
|
XFree((char *) text_prop.value);
|
|
|
|
} else {
|
|
|
|
client.title = bstrdup(i18n->getMessage(WindowSet, WindowUnnamed,
|
|
|
|
"Unnamed"));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
client.title = bstrdup(i18n->getMessage(WindowSet, WindowUnnamed,
|
|
|
|
"Unnamed"));
|
|
|
|
}
|
|
|
|
client.title_len = strlen(client.title);
|
|
|
|
|
|
|
|
if (i18n->multibyte()) {
|
|
|
|
XRectangle ink, logical;
|
|
|
|
XmbTextExtents(screen->getWindowStyle()->fontset,
|
|
|
|
client.title, client.title_len, &ink, &logical);
|
|
|
|
client.title_text_w = logical.width;
|
|
|
|
} else {
|
|
|
|
client.title_len = strlen(client.title);
|
|
|
|
client.title_text_w = XTextWidth(screen->getWindowStyle()->font,
|
|
|
|
client.title, client.title_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
client.title_text_w += (frame.bevel_w * 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::getWMIconName(void) {
|
|
|
|
if (client.icon_title) {
|
|
|
|
delete [] client.icon_title;
|
|
|
|
client.icon_title = (char *) 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
XTextProperty text_prop;
|
|
|
|
char **list;
|
|
|
|
int num;
|
|
|
|
|
|
|
|
if (XGetWMIconName(display, client.window, &text_prop)) {
|
|
|
|
if (text_prop.value && text_prop.nitems > 0) {
|
|
|
|
if (text_prop.encoding != XA_STRING) {
|
|
|
|
text_prop.nitems = strlen((char *) text_prop.value);
|
|
|
|
|
|
|
|
if ((XmbTextPropertyToTextList(display, &text_prop,
|
|
|
|
&list, &num) == Success) &&
|
|
|
|
(num > 0) && *list) {
|
|
|
|
client.icon_title = bstrdup(*list);
|
|
|
|
XFreeStringList(list);
|
|
|
|
} else {
|
|
|
|
client.icon_title = bstrdup((char *) text_prop.value);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
client.icon_title = bstrdup((char *) text_prop.value);
|
|
|
|
}
|
|
|
|
XFree((char *) text_prop.value);
|
|
|
|
} else {
|
|
|
|
client.icon_title = bstrdup(client.title);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
client.icon_title = bstrdup(client.title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Retrieve which WM Protocols are supported by the client window.
|
|
|
|
* If the WM_DELETE_WINDOW protocol is supported, add the close button to the
|
|
|
|
* window's decorations and allow the close behavior.
|
|
|
|
* If the WM_TAKE_FOCUS protocol is supported, save a value that indicates
|
|
|
|
* this.
|
|
|
|
*/
|
|
|
|
void OpenboxWindow::getWMProtocols(void) {
|
|
|
|
Atom *proto;
|
|
|
|
int num_return = 0;
|
|
|
|
|
|
|
|
if (XGetWMProtocols(display, client.window, &proto, &num_return)) {
|
|
|
|
for (int i = 0; i < num_return; ++i) {
|
2002-04-14 14:04:16 +00:00
|
|
|
if (proto[i] == openbox.getWMDeleteAtom())
|
2002-04-11 03:20:38 +00:00
|
|
|
functions.close = decorations.close = True;
|
2002-04-14 14:04:16 +00:00
|
|
|
else if (proto[i] == openbox.getWMTakeFocusAtom())
|
2002-04-11 03:20:38 +00:00
|
|
|
flags.send_focus_message = True;
|
2002-04-14 14:04:16 +00:00
|
|
|
else if (proto[i] == openbox.getOpenboxStructureMessagesAtom())
|
2002-04-14 13:58:17 +00:00
|
|
|
screen->addNetizen(new Netizen(*screen, client.window));
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
XFree(proto);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets the value of the WM_HINTS property.
|
|
|
|
* If the property is not set, then use a set of default values.
|
|
|
|
*/
|
|
|
|
void OpenboxWindow::getWMHints(void) {
|
|
|
|
XWMHints *wmhint = XGetWMHints(display, client.window);
|
|
|
|
if (! wmhint) {
|
|
|
|
flags.visible = True;
|
|
|
|
flags.iconic = False;
|
|
|
|
focus_mode = F_Passive;
|
|
|
|
client.window_group = None;
|
|
|
|
client.initial_state = NormalState;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
client.wm_hint_flags = wmhint->flags;
|
|
|
|
if (wmhint->flags & InputHint) {
|
|
|
|
if (wmhint->input == True) {
|
|
|
|
if (flags.send_focus_message)
|
|
|
|
focus_mode = F_LocallyActive;
|
|
|
|
else
|
|
|
|
focus_mode = F_Passive;
|
|
|
|
} else {
|
|
|
|
if (flags.send_focus_message)
|
|
|
|
focus_mode = F_GloballyActive;
|
|
|
|
else
|
|
|
|
focus_mode = F_NoInput;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
focus_mode = F_Passive;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wmhint->flags & StateHint)
|
|
|
|
client.initial_state = wmhint->initial_state;
|
|
|
|
else
|
|
|
|
client.initial_state = NormalState;
|
|
|
|
|
|
|
|
if (wmhint->flags & WindowGroupHint) {
|
|
|
|
if (! client.window_group) {
|
|
|
|
client.window_group = wmhint->window_group;
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.saveGroupSearch(client.window_group, this);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
client.window_group = None;
|
|
|
|
}
|
|
|
|
XFree(wmhint);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets the value of the WM_NORMAL_HINTS property.
|
|
|
|
* If the property is not set, then use a set of default values.
|
|
|
|
*/
|
|
|
|
void OpenboxWindow::getWMNormalHints(void) {
|
|
|
|
long icccm_mask;
|
|
|
|
XSizeHints sizehint;
|
|
|
|
|
|
|
|
client.min_width = client.min_height =
|
|
|
|
client.base_width = client.base_height =
|
|
|
|
client.width_inc = client.height_inc = 1;
|
2002-04-14 18:48:32 +00:00
|
|
|
client.max_width = screen->size().w();
|
|
|
|
client.max_height = screen->size().h();
|
2002-04-11 03:20:38 +00:00
|
|
|
client.min_aspect_x = client.min_aspect_y =
|
|
|
|
client.max_aspect_x = client.max_aspect_y = 1;
|
|
|
|
client.win_gravity = NorthWestGravity;
|
|
|
|
|
|
|
|
if (! XGetWMNormalHints(display, client.window, &sizehint, &icccm_mask))
|
|
|
|
return;
|
|
|
|
|
|
|
|
client.normal_hint_flags = sizehint.flags;
|
|
|
|
|
|
|
|
if (sizehint.flags & PMinSize) {
|
|
|
|
client.min_width = sizehint.min_width;
|
|
|
|
client.min_height = sizehint.min_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sizehint.flags & PMaxSize) {
|
|
|
|
client.max_width = sizehint.max_width;
|
|
|
|
client.max_height = sizehint.max_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sizehint.flags & PResizeInc) {
|
|
|
|
client.width_inc = sizehint.width_inc;
|
|
|
|
client.height_inc = sizehint.height_inc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sizehint.flags & PAspect) {
|
|
|
|
client.min_aspect_x = sizehint.min_aspect.x;
|
|
|
|
client.min_aspect_y = sizehint.min_aspect.y;
|
|
|
|
client.max_aspect_x = sizehint.max_aspect.x;
|
|
|
|
client.max_aspect_y = sizehint.max_aspect.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sizehint.flags & PBaseSize) {
|
|
|
|
client.base_width = sizehint.base_width;
|
|
|
|
client.base_height = sizehint.base_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sizehint.flags & PWinGravity)
|
|
|
|
client.win_gravity = sizehint.win_gravity;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets the MWM hints for the class' contained window.
|
|
|
|
* This is used while initializing the window to its first state, and not
|
|
|
|
* thereafter.
|
|
|
|
* Returns: true if the MWM hints are successfully retreived and applied; false
|
|
|
|
* if they are not.
|
|
|
|
*/
|
|
|
|
void OpenboxWindow::getMWMHints(void) {
|
|
|
|
int format;
|
|
|
|
Atom atom_return;
|
|
|
|
unsigned long num, len;
|
|
|
|
|
|
|
|
int ret = XGetWindowProperty(display, client.window,
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.getMotifWMHintsAtom(), 0,
|
2002-04-11 03:20:38 +00:00
|
|
|
PropMwmHintsElements, False,
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.getMotifWMHintsAtom(), &atom_return,
|
2002-04-11 03:20:38 +00:00
|
|
|
&format, &num, &len,
|
|
|
|
(unsigned char **) &client.mwm_hint);
|
|
|
|
|
|
|
|
if (ret != Success || !client.mwm_hint || num != PropMwmHintsElements)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (client.mwm_hint->flags & MwmHintsDecorations) {
|
|
|
|
if (client.mwm_hint->decorations & MwmDecorAll) {
|
|
|
|
decorations.titlebar = decorations.handle = decorations.border =
|
|
|
|
decorations.iconify = decorations.maximize =
|
|
|
|
decorations.close = decorations.menu = True;
|
|
|
|
} else {
|
|
|
|
decorations.titlebar = decorations.handle = decorations.border =
|
|
|
|
decorations.iconify = decorations.maximize =
|
|
|
|
decorations.close = decorations.menu = False;
|
|
|
|
|
|
|
|
if (client.mwm_hint->decorations & MwmDecorBorder)
|
|
|
|
decorations.border = True;
|
|
|
|
if (client.mwm_hint->decorations & MwmDecorHandle)
|
|
|
|
decorations.handle = True;
|
|
|
|
if (client.mwm_hint->decorations & MwmDecorTitle)
|
|
|
|
decorations.titlebar = True;
|
|
|
|
if (client.mwm_hint->decorations & MwmDecorMenu)
|
|
|
|
decorations.menu = True;
|
|
|
|
if (client.mwm_hint->decorations & MwmDecorIconify)
|
|
|
|
decorations.iconify = True;
|
|
|
|
if (client.mwm_hint->decorations & MwmDecorMaximize)
|
|
|
|
decorations.maximize = True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (client.mwm_hint->flags & MwmHintsFunctions) {
|
|
|
|
if (client.mwm_hint->functions & MwmFuncAll) {
|
|
|
|
functions.resize = functions.move = functions.iconify =
|
|
|
|
functions.maximize = functions.close = True;
|
|
|
|
} else {
|
|
|
|
functions.resize = functions.move = functions.iconify =
|
|
|
|
functions.maximize = functions.close = False;
|
|
|
|
|
|
|
|
if (client.mwm_hint->functions & MwmFuncResize)
|
|
|
|
functions.resize = True;
|
|
|
|
if (client.mwm_hint->functions & MwmFuncMove)
|
|
|
|
functions.move = True;
|
|
|
|
if (client.mwm_hint->functions & MwmFuncIconify)
|
|
|
|
functions.iconify = True;
|
|
|
|
if (client.mwm_hint->functions & MwmFuncMaximize)
|
|
|
|
functions.maximize = True;
|
|
|
|
if (client.mwm_hint->functions & MwmFuncClose)
|
|
|
|
functions.close = True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets the openbox hints from the class' contained window.
|
|
|
|
* This is used while initializing the window to its first state, and not
|
|
|
|
* thereafter.
|
|
|
|
* Returns: true if the hints are successfully retreived and applied; false if
|
|
|
|
* they are not.
|
|
|
|
*/
|
|
|
|
void OpenboxWindow::getOpenboxHints(void) {
|
|
|
|
int format;
|
|
|
|
Atom atom_return;
|
|
|
|
unsigned long num, len;
|
|
|
|
|
|
|
|
int ret = XGetWindowProperty(display, client.window,
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.getOpenboxHintsAtom(), 0,
|
2002-04-11 03:20:38 +00:00
|
|
|
PropOpenboxHintsElements, False,
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.getOpenboxHintsAtom(), &atom_return,
|
2002-04-11 03:20:38 +00:00
|
|
|
&format, &num, &len,
|
|
|
|
(unsigned char **) &client.openbox_hint);
|
|
|
|
if (ret != Success || !client.openbox_hint ||
|
|
|
|
num != PropOpenboxHintsElements)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (client.openbox_hint->flags & AttribShaded)
|
|
|
|
flags.shaded = (client.openbox_hint->attrib & AttribShaded);
|
|
|
|
|
|
|
|
if ((client.openbox_hint->flags & AttribMaxHoriz) &&
|
|
|
|
(client.openbox_hint->flags & AttribMaxVert))
|
|
|
|
flags.maximized = (client.openbox_hint->attrib &
|
|
|
|
(AttribMaxHoriz | AttribMaxVert)) ? 1 : 0;
|
|
|
|
else if (client.openbox_hint->flags & AttribMaxVert)
|
|
|
|
flags.maximized = (client.openbox_hint->attrib & AttribMaxVert) ? 2 : 0;
|
|
|
|
else if (client.openbox_hint->flags & AttribMaxHoriz)
|
|
|
|
flags.maximized = (client.openbox_hint->attrib & AttribMaxHoriz) ? 3 : 0;
|
|
|
|
|
|
|
|
if (client.openbox_hint->flags & AttribOmnipresent)
|
|
|
|
flags.stuck = (client.openbox_hint->attrib & AttribOmnipresent);
|
|
|
|
|
|
|
|
if (client.openbox_hint->flags & AttribWorkspace)
|
|
|
|
workspace_number = client.openbox_hint->workspace;
|
|
|
|
|
|
|
|
// if (client.openbox_hint->flags & AttribStack)
|
|
|
|
// don't yet have always on top/bottom for openbox yet... working
|
|
|
|
// on that
|
|
|
|
|
|
|
|
if (client.openbox_hint->flags & AttribDecoration) {
|
|
|
|
switch (client.openbox_hint->decoration) {
|
|
|
|
case DecorNone:
|
|
|
|
decorations.titlebar = decorations.border = decorations.handle =
|
|
|
|
decorations.iconify = decorations.maximize =
|
|
|
|
decorations.menu = False;
|
|
|
|
functions.resize = functions.move = functions.iconify =
|
|
|
|
functions.maximize = False;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DecorTiny:
|
|
|
|
decorations.titlebar = decorations.iconify = decorations.menu =
|
|
|
|
functions.move = functions.iconify = True;
|
|
|
|
decorations.border = decorations.handle = decorations.maximize =
|
|
|
|
functions.resize = functions.maximize = False;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DecorTool:
|
|
|
|
decorations.titlebar = decorations.menu = functions.move = True;
|
|
|
|
decorations.iconify = decorations.border = decorations.handle =
|
|
|
|
decorations.maximize = functions.resize = functions.maximize =
|
|
|
|
functions.iconify = False;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DecorNormal:
|
|
|
|
default:
|
|
|
|
decorations.titlebar = decorations.border = decorations.handle =
|
|
|
|
decorations.iconify = decorations.maximize =
|
|
|
|
decorations.menu = True;
|
|
|
|
functions.resize = functions.move = functions.iconify =
|
|
|
|
functions.maximize = True;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
reconfigure();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::configure(int dx, int dy,
|
|
|
|
unsigned int dw, unsigned int dh) {
|
|
|
|
Bool send_event = (frame.x != dx || frame.y != dy);
|
|
|
|
|
|
|
|
if ((dw != frame.width) || (dh != frame.height)) {
|
|
|
|
if ((((signed) frame.width) + dx) < 0) dx = 0;
|
|
|
|
if ((((signed) frame.height) + dy) < 0) dy = 0;
|
|
|
|
|
|
|
|
frame.x = dx;
|
|
|
|
frame.y = dy;
|
|
|
|
frame.width = dw;
|
|
|
|
frame.height = dh;
|
|
|
|
|
|
|
|
downsize();
|
|
|
|
|
|
|
|
#ifdef SHAPE
|
2002-04-14 14:04:16 +00:00
|
|
|
if (openbox.hasShapeExtensions() && flags.shaped) {
|
2002-04-11 03:20:38 +00:00
|
|
|
XShapeCombineShape(display, frame.window, ShapeBounding,
|
|
|
|
frame.mwm_border_w, frame.y_border +
|
|
|
|
frame.mwm_border_w, client.window,
|
|
|
|
ShapeBounding, ShapeSet);
|
|
|
|
|
|
|
|
int num = 1;
|
|
|
|
XRectangle xrect[2];
|
|
|
|
xrect[0].x = xrect[0].y = 0;
|
|
|
|
xrect[0].width = frame.width;
|
|
|
|
xrect[0].height = frame.y_border;
|
|
|
|
|
|
|
|
if (decorations.handle) {
|
|
|
|
xrect[1].x = 0;
|
|
|
|
xrect[1].y = frame.y_handle;
|
|
|
|
xrect[1].width = frame.width;
|
|
|
|
xrect[1].height = frame.handle_h + frame.border_w;
|
|
|
|
num++;
|
|
|
|
}
|
|
|
|
|
|
|
|
XShapeCombineRectangles(display, frame.window, ShapeBounding, 0, 0,
|
|
|
|
xrect, num, ShapeUnion, Unsorted);
|
|
|
|
}
|
|
|
|
#endif // SHAPE
|
|
|
|
|
|
|
|
XMoveWindow(display, frame.window, frame.x, frame.y);
|
|
|
|
|
|
|
|
positionWindows();
|
|
|
|
decorate();
|
|
|
|
setFocusFlag(flags.focused);
|
|
|
|
redrawAllButtons();
|
|
|
|
} else {
|
|
|
|
frame.x = dx;
|
|
|
|
frame.y = dy;
|
|
|
|
|
|
|
|
XMoveWindow(display, frame.window, frame.x, frame.y);
|
|
|
|
|
|
|
|
if (! flags.moving) send_event = True;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (send_event && ! flags.moving) {
|
|
|
|
client.x = dx + frame.mwm_border_w + frame.border_w;
|
|
|
|
client.y = dy + frame.y_border + frame.mwm_border_w +
|
|
|
|
frame.border_w;
|
|
|
|
|
|
|
|
XEvent event;
|
|
|
|
event.type = ConfigureNotify;
|
|
|
|
|
|
|
|
event.xconfigure.display = display;
|
|
|
|
event.xconfigure.event = client.window;
|
|
|
|
event.xconfigure.window = client.window;
|
|
|
|
event.xconfigure.x = client.x;
|
|
|
|
event.xconfigure.y = client.y;
|
|
|
|
event.xconfigure.width = client.width;
|
|
|
|
event.xconfigure.height = client.height;
|
|
|
|
event.xconfigure.border_width = client.old_bw;
|
|
|
|
event.xconfigure.above = frame.window;
|
|
|
|
event.xconfigure.override_redirect = False;
|
|
|
|
|
|
|
|
XSendEvent(display, client.window, True, NoEventMask, &event);
|
|
|
|
|
|
|
|
screen->updateNetizenConfigNotify(&event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Bool OpenboxWindow::setInputFocus(void) {
|
|
|
|
if (((signed) (frame.x + frame.width)) < 0) {
|
|
|
|
if (((signed) (frame.y + frame.y_border)) < 0)
|
|
|
|
configure(frame.border_w, frame.border_w, frame.width, frame.height);
|
2002-04-14 18:48:32 +00:00
|
|
|
else if (frame.y > (signed) screen->size().h())
|
|
|
|
configure(frame.border_w, screen->size().h() - frame.height,
|
2002-04-11 03:20:38 +00:00
|
|
|
frame.width, frame.height);
|
|
|
|
else
|
|
|
|
configure(frame.border_w, frame.y + frame.border_w,
|
|
|
|
frame.width, frame.height);
|
2002-04-14 18:48:32 +00:00
|
|
|
} else if (frame.x > (signed) screen->size().w()) {
|
2002-04-11 03:20:38 +00:00
|
|
|
if (((signed) (frame.y + frame.y_border)) < 0)
|
2002-04-14 18:48:32 +00:00
|
|
|
configure(screen->size().w() - frame.width, frame.border_w,
|
2002-04-11 03:20:38 +00:00
|
|
|
frame.width, frame.height);
|
2002-04-14 18:48:32 +00:00
|
|
|
else if (frame.y > (signed) screen->size().h())
|
|
|
|
configure(screen->size().w() - frame.width,
|
|
|
|
screen->size().h() - frame.height, frame.width, frame.height);
|
2002-04-11 03:20:38 +00:00
|
|
|
else
|
2002-04-14 18:48:32 +00:00
|
|
|
configure(screen->size().w() - frame.width,
|
2002-04-11 03:20:38 +00:00
|
|
|
frame.y + frame.border_w, frame.width, frame.height);
|
|
|
|
}
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.grab();
|
2002-04-11 03:20:38 +00:00
|
|
|
if (! validateClient()) return False;
|
|
|
|
|
|
|
|
Bool ret = False;
|
|
|
|
|
|
|
|
if (client.transient && flags.modal) {
|
|
|
|
ret = client.transient->setInputFocus();
|
|
|
|
} else if (! flags.focused) {
|
|
|
|
if (focus_mode == F_LocallyActive || focus_mode == F_Passive)
|
|
|
|
XSetInputFocus(display, client.window,
|
|
|
|
RevertToPointerRoot, CurrentTime);
|
|
|
|
else
|
|
|
|
XSetInputFocus(display, screen->getRootWindow(),
|
|
|
|
RevertToNone, CurrentTime);
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.setFocusedWindow(this);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
if (flags.send_focus_message) {
|
|
|
|
XEvent ce;
|
|
|
|
ce.xclient.type = ClientMessage;
|
2002-04-14 14:04:16 +00:00
|
|
|
ce.xclient.message_type = openbox.getWMProtocolsAtom();
|
2002-04-11 03:20:38 +00:00
|
|
|
ce.xclient.display = display;
|
|
|
|
ce.xclient.window = client.window;
|
|
|
|
ce.xclient.format = 32;
|
2002-04-14 14:04:16 +00:00
|
|
|
ce.xclient.data.l[0] = openbox.getWMTakeFocusAtom();
|
|
|
|
ce.xclient.data.l[1] = openbox.getLastTime();
|
2002-04-11 03:20:38 +00:00
|
|
|
ce.xclient.data.l[2] = 0l;
|
|
|
|
ce.xclient.data.l[3] = 0l;
|
|
|
|
ce.xclient.data.l[4] = 0l;
|
|
|
|
XSendEvent(display, client.window, False, NoEventMask, &ce);
|
|
|
|
}
|
|
|
|
|
2002-04-17 08:30:55 +00:00
|
|
|
if (screen->sloppyFocus() && screen->autoRaise())
|
2002-04-11 03:20:38 +00:00
|
|
|
timer->start();
|
|
|
|
|
|
|
|
ret = True;
|
|
|
|
}
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::iconify(void) {
|
|
|
|
if (flags.iconic) return;
|
|
|
|
|
2002-04-28 19:17:16 +00:00
|
|
|
if (flags.moving)
|
|
|
|
endMove();
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
if (windowmenu) windowmenu->hide();
|
|
|
|
|
|
|
|
setState(IconicState);
|
|
|
|
|
|
|
|
XSelectInput(display, client.window, NoEventMask);
|
|
|
|
XUnmapWindow(display, client.window);
|
|
|
|
XSelectInput(display, client.window,
|
|
|
|
PropertyChangeMask | StructureNotifyMask | FocusChangeMask);
|
|
|
|
|
|
|
|
XUnmapWindow(display, frame.window);
|
|
|
|
flags.visible = False;
|
|
|
|
flags.iconic = True;
|
|
|
|
|
|
|
|
screen->getWorkspace(workspace_number)->removeWindow(this);
|
|
|
|
|
|
|
|
if (flags.transient && client.transient_for &&
|
|
|
|
!client.transient_for->flags.iconic) {
|
|
|
|
client.transient_for->iconify();
|
|
|
|
}
|
|
|
|
screen->addIcon(this);
|
|
|
|
|
|
|
|
if (client.transient && !client.transient->flags.iconic) {
|
|
|
|
client.transient->iconify();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-30 07:46:46 +00:00
|
|
|
void OpenboxWindow::deiconify(bool reassoc, bool raise, bool initial) {
|
2002-04-11 03:20:38 +00:00
|
|
|
if (flags.iconic || reassoc)
|
|
|
|
screen->reassociateWindow(this, -1, False);
|
|
|
|
else if (workspace_number != screen->getCurrentWorkspace()->getWorkspaceID())
|
|
|
|
return;
|
|
|
|
|
|
|
|
setState(NormalState);
|
|
|
|
|
|
|
|
XSelectInput(display, client.window, NoEventMask);
|
|
|
|
XMapWindow(display, client.window);
|
|
|
|
XSelectInput(display, client.window,
|
|
|
|
PropertyChangeMask | StructureNotifyMask | FocusChangeMask);
|
|
|
|
|
|
|
|
XMapSubwindows(display, frame.window);
|
|
|
|
XMapWindow(display, frame.window);
|
|
|
|
|
2002-04-28 19:09:25 +00:00
|
|
|
// if we're using the click to place placement type, then immediately
|
|
|
|
// after the window is mapped, we need to start interactively moving it
|
2002-04-30 07:46:46 +00:00
|
|
|
if (initial && place_window &&
|
|
|
|
screen->placementPolicy() == BScreen::ClickMousePlacement) {
|
2002-04-28 19:09:25 +00:00
|
|
|
int x, y, rx, ry;
|
|
|
|
Window c, r;
|
|
|
|
unsigned int m;
|
|
|
|
XQueryPointer(openbox.getXDisplay(), screen->getRootWindow(),
|
|
|
|
&r, &c, &rx, &ry, &x, &y, &m);
|
|
|
|
startMove(rx, ry);
|
|
|
|
}
|
|
|
|
|
2002-04-17 08:30:55 +00:00
|
|
|
if (flags.iconic && screen->focusNew()) setInputFocus();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
flags.visible = True;
|
|
|
|
flags.iconic = False;
|
|
|
|
|
|
|
|
if (reassoc && client.transient) client.transient->deiconify(True, False);
|
|
|
|
|
|
|
|
if (raise)
|
|
|
|
screen->getWorkspace(workspace_number)->raiseWindow(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::close(void) {
|
|
|
|
XEvent ce;
|
|
|
|
ce.xclient.type = ClientMessage;
|
2002-04-14 14:04:16 +00:00
|
|
|
ce.xclient.message_type = openbox.getWMProtocolsAtom();
|
2002-04-11 03:20:38 +00:00
|
|
|
ce.xclient.display = display;
|
|
|
|
ce.xclient.window = client.window;
|
|
|
|
ce.xclient.format = 32;
|
2002-04-14 14:04:16 +00:00
|
|
|
ce.xclient.data.l[0] = openbox.getWMDeleteAtom();
|
2002-04-11 03:20:38 +00:00
|
|
|
ce.xclient.data.l[1] = CurrentTime;
|
|
|
|
ce.xclient.data.l[2] = 0l;
|
|
|
|
ce.xclient.data.l[3] = 0l;
|
|
|
|
ce.xclient.data.l[4] = 0l;
|
|
|
|
XSendEvent(display, client.window, False, NoEventMask, &ce);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::withdraw(void) {
|
2002-04-28 12:34:34 +00:00
|
|
|
if (flags.moving)
|
|
|
|
endMove();
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
flags.visible = False;
|
|
|
|
flags.iconic = False;
|
|
|
|
|
|
|
|
XUnmapWindow(display, frame.window);
|
|
|
|
|
|
|
|
XSelectInput(display, client.window, NoEventMask);
|
|
|
|
XUnmapWindow(display, client.window);
|
|
|
|
XSelectInput(display, client.window,
|
|
|
|
PropertyChangeMask | StructureNotifyMask | FocusChangeMask);
|
|
|
|
|
|
|
|
if (windowmenu) windowmenu->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::maximize(unsigned int button) {
|
|
|
|
// handle case where menu is open then the max button is used instead
|
|
|
|
if (windowmenu && windowmenu->isVisible()) windowmenu->hide();
|
|
|
|
|
|
|
|
if (flags.maximized) {
|
|
|
|
flags.maximized = 0;
|
|
|
|
|
|
|
|
openbox_attrib.flags &= ! (AttribMaxHoriz | AttribMaxVert);
|
|
|
|
openbox_attrib.attrib &= ! (AttribMaxHoriz | AttribMaxVert);
|
|
|
|
|
|
|
|
// when a resize is begun, maximize(0) is called to clear any maximization
|
|
|
|
// flags currently set. Otherwise it still thinks it is maximized.
|
|
|
|
// so we do not need to call configure() because resizing will handle it
|
|
|
|
if (!flags.resizing)
|
|
|
|
configure(openbox_attrib.premax_x, openbox_attrib.premax_y,
|
|
|
|
openbox_attrib.premax_w, openbox_attrib.premax_h);
|
|
|
|
|
|
|
|
openbox_attrib.premax_x = openbox_attrib.premax_y = 0;
|
|
|
|
openbox_attrib.premax_w = openbox_attrib.premax_h = 0;
|
|
|
|
|
|
|
|
redrawAllButtons();
|
|
|
|
setState(current_state);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
openbox_attrib.premax_x = frame.x;
|
|
|
|
openbox_attrib.premax_y = frame.y;
|
|
|
|
openbox_attrib.premax_w = frame.width;
|
|
|
|
openbox_attrib.premax_h = frame.height;
|
|
|
|
|
2002-04-27 19:25:20 +00:00
|
|
|
Rect space = screen->availableArea();
|
2002-04-20 19:53:19 +00:00
|
|
|
unsigned int dw = space.w(),
|
|
|
|
dh = space.h();
|
2002-04-11 03:20:38 +00:00
|
|
|
dw -= frame.border_w * 2;
|
|
|
|
dw -= frame.mwm_border_w * 2;
|
|
|
|
dw -= client.base_width;
|
|
|
|
|
|
|
|
dh -= frame.border_w * 2;
|
|
|
|
dh -= frame.mwm_border_w * 2;
|
|
|
|
dh -= ((frame.handle_h + frame.border_w) * decorations.handle);
|
|
|
|
dh -= client.base_height;
|
|
|
|
dh -= frame.y_border;
|
|
|
|
|
|
|
|
if (dw < client.min_width) dw = client.min_width;
|
|
|
|
if (dh < client.min_height) dh = client.min_height;
|
|
|
|
if (dw > client.max_width) dw = client.max_width;
|
|
|
|
if (dh > client.max_height) dh = client.max_height;
|
|
|
|
|
|
|
|
dw -= (dw % client.width_inc);
|
|
|
|
dw += client.base_width;
|
|
|
|
dw += frame.mwm_border_w * 2;
|
|
|
|
|
|
|
|
dh -= (dh % client.height_inc);
|
|
|
|
dh += client.base_height;
|
|
|
|
dh += frame.y_border;
|
|
|
|
dh += ((frame.handle_h + frame.border_w) * decorations.handle);
|
|
|
|
dh += frame.mwm_border_w * 2;
|
|
|
|
|
2002-04-20 19:53:19 +00:00
|
|
|
int dx = space.x() + ((space.w() - dw) / 2) - frame.border_w,
|
|
|
|
dy = space.y() + ((space.h() - dh) / 2) - frame.border_w;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
switch(button) {
|
|
|
|
case 1:
|
|
|
|
openbox_attrib.flags |= AttribMaxHoriz | AttribMaxVert;
|
|
|
|
openbox_attrib.attrib |= AttribMaxHoriz | AttribMaxVert;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
openbox_attrib.flags |= AttribMaxVert;
|
|
|
|
openbox_attrib.attrib |= AttribMaxVert;
|
|
|
|
|
|
|
|
dw = frame.width;
|
|
|
|
dx = frame.x;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
openbox_attrib.flags |= AttribMaxHoriz;
|
|
|
|
openbox_attrib.attrib |= AttribMaxHoriz;
|
|
|
|
|
|
|
|
dh = frame.height;
|
|
|
|
dy = frame.y;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags.shaded) {
|
|
|
|
openbox_attrib.flags ^= AttribShaded;
|
|
|
|
openbox_attrib.attrib ^= AttribShaded;
|
|
|
|
flags.shaded = False;
|
|
|
|
}
|
|
|
|
|
|
|
|
flags.maximized = button;
|
|
|
|
|
|
|
|
configure(dx, dy, dw, dh);
|
|
|
|
screen->getWorkspace(workspace_number)->raiseWindow(this);
|
|
|
|
redrawAllButtons();
|
|
|
|
setState(current_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::setWorkspace(int n) {
|
|
|
|
workspace_number = n;
|
|
|
|
|
|
|
|
openbox_attrib.flags |= AttribWorkspace;
|
|
|
|
openbox_attrib.workspace = workspace_number;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::shade(void) {
|
|
|
|
if (!decorations.titlebar)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (flags.shaded) {
|
|
|
|
XResizeWindow(display, frame.window, frame.width, frame.height);
|
|
|
|
flags.shaded = False;
|
|
|
|
openbox_attrib.flags ^= AttribShaded;
|
|
|
|
openbox_attrib.attrib ^= AttribShaded;
|
|
|
|
|
|
|
|
setState(NormalState);
|
|
|
|
} else {
|
|
|
|
XResizeWindow(display, frame.window, frame.width, frame.title_h);
|
|
|
|
flags.shaded = True;
|
|
|
|
openbox_attrib.flags |= AttribShaded;
|
|
|
|
openbox_attrib.attrib |= AttribShaded;
|
|
|
|
|
|
|
|
setState(IconicState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::stick(void) {
|
|
|
|
if (flags.stuck) {
|
|
|
|
openbox_attrib.flags ^= AttribOmnipresent;
|
|
|
|
openbox_attrib.attrib ^= AttribOmnipresent;
|
|
|
|
|
|
|
|
flags.stuck = False;
|
|
|
|
|
|
|
|
if (! flags.iconic)
|
|
|
|
screen->reassociateWindow(this, -1, True);
|
|
|
|
|
|
|
|
setState(current_state);
|
|
|
|
} else {
|
|
|
|
flags.stuck = True;
|
|
|
|
|
|
|
|
openbox_attrib.flags |= AttribOmnipresent;
|
|
|
|
openbox_attrib.attrib |= AttribOmnipresent;
|
|
|
|
|
|
|
|
setState(current_state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::setFocusFlag(Bool focus) {
|
|
|
|
flags.focused = focus;
|
|
|
|
|
|
|
|
if (decorations.titlebar) {
|
|
|
|
if (flags.focused) {
|
|
|
|
if (frame.ftitle)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.title, frame.ftitle);
|
|
|
|
else
|
|
|
|
XSetWindowBackground(display, frame.title, frame.ftitle_pixel);
|
|
|
|
} else {
|
|
|
|
if (frame.utitle)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.title, frame.utitle);
|
|
|
|
else
|
|
|
|
XSetWindowBackground(display, frame.title, frame.utitle_pixel);
|
|
|
|
}
|
|
|
|
XClearWindow(display, frame.title);
|
|
|
|
|
|
|
|
redrawLabel();
|
|
|
|
redrawAllButtons();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (decorations.handle) {
|
|
|
|
if (flags.focused) {
|
|
|
|
if (frame.fhandle)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.handle, frame.fhandle);
|
|
|
|
else
|
|
|
|
XSetWindowBackground(display, frame.handle, frame.fhandle_pixel);
|
|
|
|
|
|
|
|
if (frame.fgrip) {
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.right_grip, frame.fgrip);
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.left_grip, frame.fgrip);
|
|
|
|
} else {
|
|
|
|
XSetWindowBackground(display, frame.right_grip, frame.fgrip_pixel);
|
|
|
|
XSetWindowBackground(display, frame.left_grip, frame.fgrip_pixel);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (frame.uhandle)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.handle, frame.uhandle);
|
|
|
|
else
|
|
|
|
XSetWindowBackground(display, frame.handle, frame.uhandle_pixel);
|
|
|
|
|
|
|
|
if (frame.ugrip) {
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.right_grip, frame.ugrip);
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.left_grip, frame.ugrip);
|
|
|
|
} else {
|
|
|
|
XSetWindowBackground(display, frame.right_grip, frame.ugrip_pixel);
|
|
|
|
XSetWindowBackground(display, frame.left_grip, frame.ugrip_pixel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
XClearWindow(display, frame.handle);
|
|
|
|
XClearWindow(display, frame.right_grip);
|
|
|
|
XClearWindow(display, frame.left_grip);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (decorations.border) {
|
|
|
|
if (flags.focused)
|
|
|
|
XSetWindowBorder(display, frame.plate, frame.fborder_pixel);
|
|
|
|
else
|
|
|
|
XSetWindowBorder(display, frame.plate, frame.uborder_pixel);
|
|
|
|
}
|
|
|
|
|
2002-04-17 08:30:55 +00:00
|
|
|
if (screen->sloppyFocus() && screen->autoRaise() && timer->isTiming())
|
2002-04-11 03:20:38 +00:00
|
|
|
timer->stop();
|
2002-04-28 19:09:25 +00:00
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::installColormap(Bool install) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.grab();
|
2002-04-11 03:20:38 +00:00
|
|
|
if (! validateClient()) return;
|
|
|
|
|
|
|
|
int i = 0, ncmap = 0;
|
|
|
|
Colormap *cmaps = XListInstalledColormaps(display, client.window, &ncmap);
|
|
|
|
XWindowAttributes wattrib;
|
|
|
|
if (cmaps) {
|
|
|
|
if (XGetWindowAttributes(display, client.window, &wattrib)) {
|
|
|
|
if (install) {
|
|
|
|
// install the window's colormap
|
|
|
|
for (i = 0; i < ncmap; i++) {
|
|
|
|
if (*(cmaps + i) == wattrib.colormap)
|
|
|
|
// this window is using an installed color map... do not install
|
|
|
|
install = False;
|
|
|
|
}
|
|
|
|
// otherwise, install the window's colormap
|
|
|
|
if (install)
|
|
|
|
XInstallColormap(display, wattrib.colormap);
|
|
|
|
} else {
|
|
|
|
// uninstall the window's colormap
|
|
|
|
for (i = 0; i < ncmap; i++) {
|
|
|
|
if (*(cmaps + i) == wattrib.colormap)
|
|
|
|
// we found the colormap to uninstall
|
|
|
|
XUninstallColormap(display, wattrib.colormap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XFree(cmaps);
|
|
|
|
}
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::setState(unsigned long new_state) {
|
|
|
|
current_state = new_state;
|
|
|
|
|
|
|
|
unsigned long state[2];
|
|
|
|
state[0] = (unsigned long) current_state;
|
|
|
|
state[1] = (unsigned long) None;
|
2002-04-14 14:04:16 +00:00
|
|
|
XChangeProperty(display, client.window, openbox.getWMStateAtom(),
|
|
|
|
openbox.getWMStateAtom(), 32, PropModeReplace,
|
2002-04-11 03:20:38 +00:00
|
|
|
(unsigned char *) state, 2);
|
|
|
|
|
|
|
|
XChangeProperty(display, client.window,
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.getOpenboxAttributesAtom(),
|
|
|
|
openbox.getOpenboxAttributesAtom(), 32, PropModeReplace,
|
2002-04-11 03:20:38 +00:00
|
|
|
(unsigned char *) &openbox_attrib,
|
|
|
|
PropOpenboxAttributesElements);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Bool OpenboxWindow::getState(void) {
|
|
|
|
current_state = 0;
|
|
|
|
|
|
|
|
Atom atom_return;
|
|
|
|
Bool ret = False;
|
|
|
|
int foo;
|
|
|
|
unsigned long *state, ulfoo, nitems;
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
if ((XGetWindowProperty(display, client.window, openbox.getWMStateAtom(),
|
|
|
|
0l, 2l, False, openbox.getWMStateAtom(),
|
2002-04-11 03:20:38 +00:00
|
|
|
&atom_return, &foo, &nitems, &ulfoo,
|
|
|
|
(unsigned char **) &state) != Success) ||
|
|
|
|
(! state)) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-11 03:20:38 +00:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nitems >= 1) {
|
|
|
|
current_state = (unsigned long) state[0];
|
|
|
|
|
|
|
|
ret = True;
|
|
|
|
}
|
|
|
|
|
|
|
|
XFree((void *) state);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::setGravityOffsets(void) {
|
|
|
|
// x coordinates for each gravity type
|
|
|
|
const int x_west = client.x;
|
|
|
|
const int x_east = client.x + client.width - frame.width;
|
|
|
|
const int x_center = client.x + client.width - frame.width/2;
|
|
|
|
// y coordinates for each gravity type
|
|
|
|
const int y_north = client.y;
|
|
|
|
const int y_south = client.y + client.height - frame.height;
|
|
|
|
const int y_center = client.y + client.height - frame.height/2;
|
|
|
|
|
|
|
|
switch (client.win_gravity) {
|
|
|
|
case NorthWestGravity:
|
|
|
|
default:
|
|
|
|
frame.x = x_west;
|
|
|
|
frame.y = y_north;
|
|
|
|
break;
|
|
|
|
case NorthGravity:
|
|
|
|
frame.x = x_center;
|
|
|
|
frame.y = y_north;
|
|
|
|
break;
|
|
|
|
case NorthEastGravity:
|
|
|
|
frame.x = x_east;
|
|
|
|
frame.y = y_north;
|
|
|
|
break;
|
|
|
|
case SouthWestGravity:
|
|
|
|
frame.x = x_west;
|
|
|
|
frame.y = y_south;
|
|
|
|
break;
|
|
|
|
case SouthGravity:
|
|
|
|
frame.x = x_center;
|
|
|
|
frame.y = y_south;
|
|
|
|
break;
|
|
|
|
case SouthEastGravity:
|
|
|
|
frame.x = x_east;
|
|
|
|
frame.y = y_south;
|
|
|
|
break;
|
|
|
|
case WestGravity:
|
|
|
|
frame.x = x_west;
|
|
|
|
frame.y = y_center;
|
|
|
|
break;
|
|
|
|
case EastGravity:
|
|
|
|
frame.x = x_east;
|
|
|
|
frame.y = y_center;
|
|
|
|
break;
|
|
|
|
case CenterGravity:
|
|
|
|
frame.x = x_center;
|
|
|
|
frame.y = y_center;
|
|
|
|
break;
|
|
|
|
case ForgetGravity:
|
|
|
|
case StaticGravity:
|
|
|
|
frame.x = client.x - frame.mwm_border_w + frame.border_w;
|
|
|
|
frame.y = client.y - frame.y_border - frame.mwm_border_w - frame.border_w;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::restoreAttributes(void) {
|
|
|
|
if (! getState()) current_state = NormalState;
|
|
|
|
|
|
|
|
Atom atom_return;
|
|
|
|
int foo;
|
|
|
|
unsigned long ulfoo, nitems;
|
|
|
|
|
|
|
|
OpenboxAttributes *net;
|
|
|
|
int ret = XGetWindowProperty(display, client.window,
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.getOpenboxAttributesAtom(), 0l,
|
2002-04-11 03:20:38 +00:00
|
|
|
PropOpenboxAttributesElements, False,
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.getOpenboxAttributesAtom(),
|
2002-04-11 03:20:38 +00:00
|
|
|
&atom_return, &foo, &nitems, &ulfoo,
|
|
|
|
(unsigned char **) &net);
|
|
|
|
if (ret != Success || !net || nitems != PropOpenboxAttributesElements)
|
|
|
|
return;
|
|
|
|
|
|
|
|
openbox_attrib.flags = net->flags;
|
|
|
|
openbox_attrib.attrib = net->attrib;
|
|
|
|
openbox_attrib.decoration = net->decoration;
|
|
|
|
openbox_attrib.workspace = net->workspace;
|
|
|
|
openbox_attrib.stack = net->stack;
|
|
|
|
openbox_attrib.premax_x = net->premax_x;
|
|
|
|
openbox_attrib.premax_y = net->premax_y;
|
|
|
|
openbox_attrib.premax_w = net->premax_w;
|
|
|
|
openbox_attrib.premax_h = net->premax_h;
|
|
|
|
|
|
|
|
XFree((void *) net);
|
|
|
|
|
|
|
|
if (openbox_attrib.flags & AttribShaded &&
|
|
|
|
openbox_attrib.attrib & AttribShaded) {
|
|
|
|
int save_state =
|
|
|
|
((current_state == IconicState) ? NormalState : current_state);
|
|
|
|
|
|
|
|
flags.shaded = False;
|
|
|
|
shade();
|
|
|
|
|
|
|
|
current_state = save_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((int) openbox_attrib.workspace != screen->getCurrentWorkspaceID()) &&
|
2002-04-12 06:05:04 +00:00
|
|
|
((int) openbox_attrib.workspace < screen->getWorkspaceCount())) {
|
2002-04-11 03:20:38 +00:00
|
|
|
screen->reassociateWindow(this, openbox_attrib.workspace, True);
|
|
|
|
|
|
|
|
if (current_state == NormalState) current_state = WithdrawnState;
|
|
|
|
} else if (current_state == WithdrawnState) {
|
|
|
|
current_state = NormalState;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (openbox_attrib.flags & AttribOmnipresent &&
|
|
|
|
openbox_attrib.attrib & AttribOmnipresent) {
|
|
|
|
flags.stuck = False;
|
|
|
|
stick();
|
|
|
|
|
|
|
|
current_state = NormalState;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((openbox_attrib.flags & AttribMaxHoriz) ||
|
|
|
|
(openbox_attrib.flags & AttribMaxVert)) {
|
|
|
|
int x = openbox_attrib.premax_x, y = openbox_attrib.premax_y;
|
|
|
|
unsigned int w = openbox_attrib.premax_w, h = openbox_attrib.premax_h;
|
|
|
|
flags.maximized = 0;
|
|
|
|
|
|
|
|
unsigned int m = False;
|
|
|
|
if ((openbox_attrib.flags & AttribMaxHoriz) &&
|
|
|
|
(openbox_attrib.flags & AttribMaxVert))
|
|
|
|
m = (openbox_attrib.attrib & (AttribMaxHoriz | AttribMaxVert)) ? 1 : 0;
|
|
|
|
else if (openbox_attrib.flags & AttribMaxVert)
|
|
|
|
m = (openbox_attrib.attrib & AttribMaxVert) ? 2 : 0;
|
|
|
|
else if (openbox_attrib.flags & AttribMaxHoriz)
|
|
|
|
m = (openbox_attrib.attrib & AttribMaxHoriz) ? 3 : 0;
|
|
|
|
|
|
|
|
if (m) maximize(m);
|
|
|
|
|
|
|
|
openbox_attrib.premax_x = x;
|
|
|
|
openbox_attrib.premax_y = y;
|
|
|
|
openbox_attrib.premax_w = w;
|
|
|
|
openbox_attrib.premax_h = h;
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(current_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The reverse of the setGravityOffsets function. Uses the frame window's
|
|
|
|
* position to find the window's reference point.
|
|
|
|
*/
|
|
|
|
void OpenboxWindow::restoreGravity(void) {
|
|
|
|
// x coordinates for each gravity type
|
|
|
|
const int x_west = frame.x;
|
|
|
|
const int x_east = frame.x + frame.width - client.width;
|
|
|
|
const int x_center = frame.x + (frame.width/2) - client.width;
|
|
|
|
// y coordinates for each gravity type
|
|
|
|
const int y_north = frame.y;
|
|
|
|
const int y_south = frame.y + frame.height - client.height;
|
|
|
|
const int y_center = frame.y + (frame.height/2) - client.height;
|
|
|
|
|
|
|
|
switch(client.win_gravity) {
|
|
|
|
default:
|
|
|
|
case NorthWestGravity:
|
|
|
|
client.x = x_west;
|
|
|
|
client.y = y_north;
|
|
|
|
break;
|
|
|
|
case NorthGravity:
|
|
|
|
client.x = x_center;
|
|
|
|
client.y = y_north;
|
|
|
|
break;
|
|
|
|
case NorthEastGravity:
|
|
|
|
client.x = x_east;
|
|
|
|
client.y = y_north;
|
|
|
|
break;
|
|
|
|
case SouthWestGravity:
|
|
|
|
client.x = x_west;
|
|
|
|
client.y = y_south;
|
|
|
|
break;
|
|
|
|
case SouthGravity:
|
|
|
|
client.x = x_center;
|
|
|
|
client.y = y_south;
|
|
|
|
break;
|
|
|
|
case SouthEastGravity:
|
|
|
|
client.x = x_east;
|
|
|
|
client.y = y_south;
|
|
|
|
break;
|
|
|
|
case WestGravity:
|
|
|
|
client.x = x_west;
|
|
|
|
client.y = y_center;
|
|
|
|
break;
|
|
|
|
case EastGravity:
|
|
|
|
client.x = x_east;
|
|
|
|
client.y = y_center;
|
|
|
|
break;
|
|
|
|
case CenterGravity:
|
|
|
|
client.x = x_center;
|
|
|
|
client.y = y_center;
|
|
|
|
break;
|
|
|
|
case ForgetGravity:
|
|
|
|
case StaticGravity:
|
|
|
|
client.x = frame.x + frame.mwm_border_w + frame.border_w;
|
|
|
|
client.y = frame.y + frame.y_border + frame.mwm_border_w +
|
|
|
|
frame.border_w;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::redrawLabel(void) {
|
|
|
|
int dx = frame.bevel_w * 2, dlen = client.title_len;
|
|
|
|
unsigned int l = client.title_text_w;
|
|
|
|
|
|
|
|
if (flags.focused) {
|
|
|
|
if (frame.flabel)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.label, frame.flabel);
|
|
|
|
else
|
|
|
|
XSetWindowBackground(display, frame.label, frame.flabel_pixel);
|
|
|
|
} else {
|
|
|
|
if (frame.ulabel)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.label, frame.ulabel);
|
|
|
|
else
|
|
|
|
XSetWindowBackground(display, frame.label, frame.ulabel_pixel);
|
|
|
|
}
|
|
|
|
XClearWindow(display, frame.label);
|
|
|
|
|
|
|
|
if (client.title_text_w > frame.label_w) {
|
|
|
|
for (; dlen >= 0; dlen--) {
|
|
|
|
if (i18n->multibyte()) {
|
|
|
|
XRectangle ink, logical;
|
|
|
|
XmbTextExtents(screen->getWindowStyle()->fontset, client.title, dlen,
|
|
|
|
&ink, &logical);
|
|
|
|
l = logical.width;
|
|
|
|
} else {
|
|
|
|
l = XTextWidth(screen->getWindowStyle()->font, client.title, dlen);
|
|
|
|
}
|
|
|
|
l += (frame.bevel_w * 4);
|
|
|
|
|
|
|
|
if (l < frame.label_w)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (screen->getWindowStyle()->justify) {
|
|
|
|
case BScreen::RightJustify:
|
|
|
|
dx += frame.label_w - l;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BScreen::CenterJustify:
|
|
|
|
dx += (frame.label_w - l) / 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
WindowStyle *style = screen->getWindowStyle();
|
|
|
|
GC text_gc = (flags.focused) ? style->l_text_focus_gc :
|
|
|
|
style->l_text_unfocus_gc;
|
|
|
|
if (i18n->multibyte())
|
|
|
|
XmbDrawString(display, frame.label, style->fontset, text_gc, dx,
|
|
|
|
(1 - style->fontset_extents->max_ink_extent.y),
|
|
|
|
client.title, dlen);
|
|
|
|
else
|
|
|
|
XDrawString(display, frame.label, text_gc, dx,
|
|
|
|
(style->font->ascent + 1), client.title, dlen);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::redrawAllButtons(void) {
|
|
|
|
if (frame.iconify_button) redrawIconifyButton(False);
|
|
|
|
if (frame.maximize_button) redrawMaximizeButton(flags.maximized);
|
|
|
|
if (frame.close_button) redrawCloseButton(False);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::redrawIconifyButton(Bool pressed) {
|
|
|
|
if (! pressed) {
|
|
|
|
if (flags.focused) {
|
|
|
|
if (frame.fbutton)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.iconify_button,
|
|
|
|
frame.fbutton);
|
|
|
|
else
|
|
|
|
XSetWindowBackground(display, frame.iconify_button,
|
|
|
|
frame.fbutton_pixel);
|
|
|
|
} else {
|
|
|
|
if (frame.ubutton)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.iconify_button,
|
|
|
|
frame.ubutton);
|
|
|
|
else
|
|
|
|
XSetWindowBackground(display, frame.iconify_button,
|
|
|
|
frame.ubutton_pixel);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (frame.pbutton)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.iconify_button, frame.pbutton);
|
|
|
|
else
|
|
|
|
XSetWindowBackground(display, frame.iconify_button, frame.pbutton_pixel);
|
|
|
|
}
|
|
|
|
XClearWindow(display, frame.iconify_button);
|
|
|
|
|
|
|
|
XDrawRectangle(display, frame.iconify_button,
|
|
|
|
((flags.focused) ? screen->getWindowStyle()->b_pic_focus_gc :
|
|
|
|
screen->getWindowStyle()->b_pic_unfocus_gc),
|
|
|
|
2, (frame.button_h - 5), (frame.button_w - 5), 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::redrawMaximizeButton(Bool pressed) {
|
|
|
|
if (! pressed) {
|
|
|
|
if (flags.focused) {
|
|
|
|
if (frame.fbutton)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.maximize_button,
|
|
|
|
frame.fbutton);
|
|
|
|
else
|
|
|
|
XSetWindowBackground(display, frame.maximize_button,
|
|
|
|
frame.fbutton_pixel);
|
|
|
|
} else {
|
|
|
|
if (frame.ubutton)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.maximize_button,
|
|
|
|
frame.ubutton);
|
|
|
|
else
|
|
|
|
XSetWindowBackground(display, frame.maximize_button,
|
|
|
|
frame.ubutton_pixel);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (frame.pbutton)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.maximize_button,
|
|
|
|
frame.pbutton);
|
|
|
|
else
|
|
|
|
XSetWindowBackground(display, frame.maximize_button,
|
|
|
|
frame.pbutton_pixel);
|
|
|
|
}
|
|
|
|
XClearWindow(display, frame.maximize_button);
|
|
|
|
|
|
|
|
XDrawRectangle(display, frame.maximize_button,
|
|
|
|
((flags.focused) ? screen->getWindowStyle()->b_pic_focus_gc :
|
|
|
|
screen->getWindowStyle()->b_pic_unfocus_gc),
|
|
|
|
2, 2, (frame.button_w - 5), (frame.button_h - 5));
|
|
|
|
XDrawLine(display, frame.maximize_button,
|
|
|
|
((flags.focused) ? screen->getWindowStyle()->b_pic_focus_gc :
|
|
|
|
screen->getWindowStyle()->b_pic_unfocus_gc),
|
|
|
|
2, 3, (frame.button_w - 3), 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::redrawCloseButton(Bool pressed) {
|
|
|
|
if (! pressed) {
|
|
|
|
if (flags.focused) {
|
|
|
|
if (frame.fbutton)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.close_button,
|
|
|
|
frame.fbutton);
|
|
|
|
else
|
|
|
|
XSetWindowBackground(display, frame.close_button,
|
|
|
|
frame.fbutton_pixel);
|
|
|
|
} else {
|
|
|
|
if (frame.ubutton)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.close_button,
|
|
|
|
frame.ubutton);
|
|
|
|
else
|
|
|
|
XSetWindowBackground(display, frame.close_button,
|
|
|
|
frame.ubutton_pixel);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (frame.pbutton)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.close_button, frame.pbutton);
|
|
|
|
else
|
|
|
|
XSetWindowBackground(display, frame.close_button, frame.pbutton_pixel);
|
|
|
|
}
|
|
|
|
XClearWindow(display, frame.close_button);
|
|
|
|
|
|
|
|
XDrawLine(display, frame.close_button,
|
|
|
|
((flags.focused) ? screen->getWindowStyle()->b_pic_focus_gc :
|
|
|
|
screen->getWindowStyle()->b_pic_unfocus_gc), 2, 2,
|
|
|
|
(frame.button_w - 3), (frame.button_h - 3));
|
|
|
|
XDrawLine(display, frame.close_button,
|
|
|
|
((flags.focused) ? screen->getWindowStyle()->b_pic_focus_gc :
|
|
|
|
screen->getWindowStyle()->b_pic_unfocus_gc), 2,
|
|
|
|
(frame.button_h - 3),
|
|
|
|
(frame.button_w - 3), 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::mapRequestEvent(XMapRequestEvent *re) {
|
2002-04-30 07:24:54 +00:00
|
|
|
cout << "MAP REQUEST " << client.window << " " << client.title << endl;
|
2002-04-11 03:20:38 +00:00
|
|
|
if (re->window == client.window) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
fprintf(stderr, i18n->getMessage(WindowSet, WindowMapRequest,
|
|
|
|
"OpenboxWindow::mapRequestEvent() for 0x%lx\n"),
|
|
|
|
client.window);
|
|
|
|
#endif // DEBUG
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.grab();
|
2002-04-11 03:20:38 +00:00
|
|
|
if (! validateClient()) return;
|
|
|
|
|
|
|
|
Bool get_state_ret = getState();
|
2002-04-14 14:04:16 +00:00
|
|
|
if (! (get_state_ret && openbox.isStartup())) {
|
2002-04-11 03:20:38 +00:00
|
|
|
if ((client.wm_hint_flags & StateHint) &&
|
|
|
|
(! (current_state == NormalState || current_state == IconicState)))
|
|
|
|
current_state = client.initial_state;
|
|
|
|
else
|
|
|
|
current_state = NormalState;
|
|
|
|
} else if (flags.iconic) {
|
|
|
|
current_state = NormalState;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (current_state) {
|
|
|
|
case IconicState:
|
|
|
|
iconify();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WithdrawnState:
|
|
|
|
withdraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NormalState:
|
|
|
|
case InactiveState:
|
|
|
|
case ZoomState:
|
|
|
|
default:
|
2002-04-30 07:46:46 +00:00
|
|
|
deiconify(False, True, True); // specify that we're initializing the
|
|
|
|
// window
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::mapNotifyEvent(XMapEvent *ne) {
|
|
|
|
if ((ne->window == client.window) && (! ne->override_redirect)
|
|
|
|
&& (flags.visible)) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.grab();
|
2002-04-11 03:20:38 +00:00
|
|
|
if (! validateClient()) return;
|
|
|
|
|
|
|
|
if (decorations.titlebar) positionButtons();
|
|
|
|
|
|
|
|
setState(NormalState);
|
|
|
|
|
|
|
|
redrawAllButtons();
|
|
|
|
|
2002-04-17 08:30:55 +00:00
|
|
|
if (flags.transient || screen->focusNew())
|
2002-04-11 03:20:38 +00:00
|
|
|
setInputFocus();
|
|
|
|
else
|
|
|
|
setFocusFlag(False);
|
|
|
|
|
|
|
|
flags.visible = True;
|
|
|
|
flags.iconic = False;
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::unmapNotifyEvent(XUnmapEvent *ue) {
|
|
|
|
if (ue->window == client.window) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
fprintf(stderr, i18n->getMessage(WindowSet, WindowUnmapNotify,
|
|
|
|
"OpenboxWindow::unmapNotifyEvent() for 0x%lx\n"),
|
|
|
|
client.window);
|
|
|
|
#endif // DEBUG
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.grab();
|
2002-04-11 03:20:38 +00:00
|
|
|
if (! validateClient()) return;
|
|
|
|
|
2002-05-01 07:13:12 +00:00
|
|
|
if (flags.moving)
|
|
|
|
endMove();
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
XChangeSaveSet(display, client.window, SetModeDelete);
|
|
|
|
XSelectInput(display, client.window, NoEventMask);
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
XDeleteProperty(display, client.window, openbox.getWMStateAtom());
|
2002-04-11 03:20:38 +00:00
|
|
|
XDeleteProperty(display, client.window,
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.getOpenboxAttributesAtom());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
XUnmapWindow(display, frame.window);
|
|
|
|
XUnmapWindow(display, client.window);
|
|
|
|
|
|
|
|
XEvent dummy;
|
|
|
|
if (! XCheckTypedWindowEvent(display, client.window, ReparentNotify,
|
|
|
|
&dummy)) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
fprintf(stderr, i18n->getMessage(WindowSet, WindowUnmapNotifyReparent,
|
|
|
|
"OpenboxWindow::unmapNotifyEvent(): reparent 0x%lx to "
|
|
|
|
"root.\n"), client.window);
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
restoreGravity();
|
|
|
|
XReparentWindow(display, client.window, screen->getRootWindow(),
|
|
|
|
client.x, client.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
XFlush(display);
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::destroyNotifyEvent(XDestroyWindowEvent *de) {
|
|
|
|
if (de->window == client.window) {
|
2002-05-01 07:13:12 +00:00
|
|
|
if (flags.moving)
|
|
|
|
endMove();
|
2002-04-11 03:20:38 +00:00
|
|
|
XUnmapWindow(display, frame.window);
|
|
|
|
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::propertyNotifyEvent(Atom atom) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.grab();
|
2002-04-11 03:20:38 +00:00
|
|
|
if (! validateClient()) return;
|
|
|
|
|
|
|
|
switch(atom) {
|
|
|
|
case XA_WM_CLASS:
|
|
|
|
case XA_WM_CLIENT_MACHINE:
|
|
|
|
case XA_WM_COMMAND:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XA_WM_TRANSIENT_FOR:
|
|
|
|
// determine if this is a transient window
|
|
|
|
Window win;
|
|
|
|
if (XGetTransientForHint(display, client.window, &win)) {
|
|
|
|
if (win && (win != client.window)) {
|
2002-04-14 14:04:16 +00:00
|
|
|
if ((client.transient_for = openbox.searchWindow(win))) {
|
2002-04-11 03:20:38 +00:00
|
|
|
client.transient_for->client.transient = this;
|
|
|
|
flags.stuck = client.transient_for->flags.stuck;
|
|
|
|
flags.transient = True;
|
|
|
|
} else if (win == client.window_group) {
|
|
|
|
//jr This doesn't look quite right...
|
2002-04-14 14:04:16 +00:00
|
|
|
if ((client.transient_for = openbox.searchGroup(win, this))) {
|
2002-04-11 03:20:38 +00:00
|
|
|
client.transient_for->client.transient = this;
|
|
|
|
flags.stuck = client.transient_for->flags.stuck;
|
|
|
|
flags.transient = True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (win == screen->getRootWindow()) flags.modal = True;
|
|
|
|
}
|
|
|
|
|
|
|
|
// adjust the window decorations based on transience
|
|
|
|
if (flags.transient)
|
|
|
|
decorations.maximize = decorations.handle = functions.maximize = False;
|
|
|
|
|
|
|
|
reconfigure();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XA_WM_HINTS:
|
|
|
|
getWMHints();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XA_WM_ICON_NAME:
|
|
|
|
getWMIconName();
|
|
|
|
if (flags.iconic) screen->iconUpdate();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XA_WM_NAME:
|
|
|
|
getWMName();
|
|
|
|
|
|
|
|
if (decorations.titlebar)
|
|
|
|
redrawLabel();
|
|
|
|
|
|
|
|
if (! flags.iconic)
|
|
|
|
screen->getWorkspace(workspace_number)->update();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XA_WM_NORMAL_HINTS: {
|
|
|
|
getWMNormalHints();
|
|
|
|
|
|
|
|
if ((client.normal_hint_flags & PMinSize) &&
|
|
|
|
(client.normal_hint_flags & PMaxSize)) {
|
|
|
|
if (client.max_width <= client.min_width &&
|
|
|
|
client.max_height <= client.min_height)
|
|
|
|
decorations.maximize = decorations.handle =
|
|
|
|
functions.resize = functions.maximize = False;
|
|
|
|
else
|
|
|
|
decorations.maximize = decorations.handle =
|
|
|
|
functions.resize = functions.maximize = True;
|
|
|
|
}
|
|
|
|
|
|
|
|
int x = frame.x, y = frame.y;
|
|
|
|
unsigned int w = frame.width, h = frame.height;
|
|
|
|
|
|
|
|
upsize();
|
|
|
|
|
|
|
|
if ((x != frame.x) || (y != frame.y) ||
|
|
|
|
(w != frame.width) || (h != frame.height))
|
|
|
|
reconfigure();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2002-04-14 14:04:16 +00:00
|
|
|
if (atom == openbox.getWMProtocolsAtom()) {
|
2002-04-11 03:20:38 +00:00
|
|
|
getWMProtocols();
|
|
|
|
|
|
|
|
if (decorations.close && (! frame.close_button)) {
|
|
|
|
createCloseButton();
|
|
|
|
if (decorations.titlebar) positionButtons(True);
|
|
|
|
if (windowmenu) windowmenu->reconfigure();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::exposeEvent(XExposeEvent *ee) {
|
|
|
|
if (frame.label == ee->window && decorations.titlebar)
|
|
|
|
redrawLabel();
|
|
|
|
else if (frame.close_button == ee->window)
|
|
|
|
redrawCloseButton(False);
|
|
|
|
else if (frame.maximize_button == ee->window)
|
|
|
|
redrawMaximizeButton(flags.maximized);
|
|
|
|
else if (frame.iconify_button == ee->window)
|
|
|
|
redrawIconifyButton(False);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::configureRequestEvent(XConfigureRequestEvent *cr) {
|
|
|
|
if (cr->window == client.window) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.grab();
|
2002-04-11 03:20:38 +00:00
|
|
|
if (! validateClient()) return;
|
|
|
|
|
|
|
|
int cx = frame.x, cy = frame.y;
|
|
|
|
unsigned int cw = frame.width, ch = frame.height;
|
|
|
|
|
|
|
|
if (cr->value_mask & CWBorderWidth)
|
|
|
|
client.old_bw = cr->border_width;
|
|
|
|
|
|
|
|
if (cr->value_mask & CWX)
|
|
|
|
cx = cr->x - frame.mwm_border_w - frame.border_w;
|
|
|
|
|
|
|
|
if (cr->value_mask & CWY)
|
|
|
|
cy = cr->y - frame.y_border - frame.mwm_border_w -
|
|
|
|
frame.border_w;
|
|
|
|
|
|
|
|
if (cr->value_mask & CWWidth)
|
|
|
|
cw = cr->width + (frame.mwm_border_w * 2);
|
|
|
|
|
|
|
|
if (cr->value_mask & CWHeight)
|
|
|
|
ch = cr->height + frame.y_border + (frame.mwm_border_w * 2) +
|
|
|
|
(frame.border_w * decorations.handle) + frame.handle_h;
|
|
|
|
|
|
|
|
if (frame.x != cx || frame.y != cy ||
|
|
|
|
frame.width != cw || frame.height != ch)
|
|
|
|
configure(cx, cy, cw, ch);
|
|
|
|
|
|
|
|
if (cr->value_mask & CWStackMode) {
|
|
|
|
switch (cr->detail) {
|
|
|
|
case Above:
|
|
|
|
case TopIf:
|
|
|
|
default:
|
|
|
|
if (flags.iconic) deiconify();
|
|
|
|
screen->getWorkspace(workspace_number)->raiseWindow(this);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Below:
|
|
|
|
case BottomIf:
|
|
|
|
if (flags.iconic) deiconify();
|
|
|
|
screen->getWorkspace(workspace_number)->lowerWindow(this);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::buttonPressEvent(XButtonEvent *be) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.grab();
|
2002-04-11 03:20:38 +00:00
|
|
|
if (! validateClient())
|
|
|
|
return;
|
|
|
|
|
|
|
|
int stack_change = 1; // < 0 means to lower the window
|
|
|
|
// > 0 means to raise the window
|
|
|
|
// 0 means to leave it where it is
|
|
|
|
|
|
|
|
// alt + left/right click begins interactively moving/resizing the window
|
|
|
|
// when the mouse is moved
|
|
|
|
if (be->state == Mod1Mask && (be->button == 1 || be->button == 3)) {
|
|
|
|
if (be->button == 3) {
|
|
|
|
if (screen->getWindowZones() == 4 &&
|
|
|
|
be->y < (signed) frame.height / 2) {
|
|
|
|
resize_zone = ZoneTop;
|
|
|
|
} else {
|
|
|
|
resize_zone = ZoneBottom;
|
|
|
|
}
|
|
|
|
if (screen->getWindowZones() >= 2 &&
|
|
|
|
be->x < (signed) frame.width / 2) {
|
|
|
|
resize_zone |= ZoneLeft;
|
|
|
|
} else {
|
|
|
|
resize_zone |= ZoneRight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// control + left click on the titlebar shades the window
|
|
|
|
} else if (be->state == ControlMask && be->button == 1) {
|
|
|
|
if (be->window == frame.title ||
|
|
|
|
be->window == frame.label)
|
|
|
|
shade();
|
|
|
|
// left click
|
|
|
|
} else if (be->state == 0 && be->button == 1) {
|
|
|
|
if (windowmenu && windowmenu->isVisible())
|
|
|
|
windowmenu->hide();
|
|
|
|
|
|
|
|
if (be->window == frame.maximize_button) {
|
|
|
|
redrawMaximizeButton(True);
|
|
|
|
} else if (be->window == frame.iconify_button) {
|
|
|
|
redrawIconifyButton(True);
|
|
|
|
} else if (be->window == frame.close_button) {
|
|
|
|
redrawCloseButton(True);
|
|
|
|
} else if (be->window == frame.plate) {
|
|
|
|
XAllowEvents(display, ReplayPointer, be->time);
|
|
|
|
} else if (be->window == frame.title ||
|
|
|
|
be->window == frame.label) {
|
|
|
|
// shade the window when the titlebar is double clicked
|
|
|
|
if ( (be->time - lastButtonPressTime) <=
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.getDoubleClickInterval()) {
|
2002-04-11 03:20:38 +00:00
|
|
|
lastButtonPressTime = 0;
|
|
|
|
shade();
|
|
|
|
} else {
|
|
|
|
lastButtonPressTime = be->time;
|
|
|
|
}
|
|
|
|
// clicking and dragging on the titlebar moves the window, so on a click
|
|
|
|
// we need to save the coords of the click in case the user drags
|
|
|
|
frame.grab_x = be->x_root - frame.x - frame.border_w;
|
|
|
|
frame.grab_y = be->y_root - frame.y - frame.border_w;
|
|
|
|
} else if (be->window == frame.handle ||
|
|
|
|
be->window == frame.left_grip ||
|
|
|
|
be->window == frame.right_grip ||
|
|
|
|
be->window == frame.window) {
|
|
|
|
// clicking and dragging on the window's frame moves the window, so on a
|
|
|
|
// click we need to save the coords of the click in case the user drags
|
|
|
|
frame.grab_x = be->x_root - frame.x - frame.border_w;
|
|
|
|
frame.grab_y = be->y_root - frame.y - frame.border_w;
|
|
|
|
if (be->window == frame.left_grip)
|
|
|
|
resize_zone = ZoneBottom | ZoneLeft;
|
|
|
|
else if (be->window == frame.right_grip)
|
|
|
|
resize_zone = ZoneBottom | ZoneRight;
|
|
|
|
}
|
|
|
|
// middle click
|
|
|
|
} else if (be->state == 0 && be->button == 2) {
|
|
|
|
if (be->window == frame.maximize_button) {
|
|
|
|
redrawMaximizeButton(True);
|
|
|
|
// a middle click anywhere on the window's frame except for on the buttons
|
|
|
|
// will lower the window
|
|
|
|
} else if (! (be->window == frame.iconify_button ||
|
|
|
|
be->window == frame.close_button) ) {
|
|
|
|
stack_change = -1;
|
|
|
|
}
|
|
|
|
// right click
|
|
|
|
} else if (be->state == 0 && be->button == 3) {
|
|
|
|
if (be->window == frame.maximize_button) {
|
|
|
|
redrawMaximizeButton(True);
|
|
|
|
// a right click on the window's frame will show or hide the window's
|
|
|
|
// windowmenu
|
|
|
|
} else if (be->window == frame.title ||
|
|
|
|
be->window == frame.label ||
|
|
|
|
be->window == frame.handle ||
|
|
|
|
be->window == frame.window) {
|
|
|
|
int mx, my;
|
|
|
|
if (windowmenu) {
|
|
|
|
if (windowmenu->isVisible()) {
|
|
|
|
windowmenu->hide();
|
|
|
|
} else {
|
|
|
|
// get the coords for the menu
|
|
|
|
mx = be->x_root - windowmenu->getWidth() / 2;
|
|
|
|
if (be->window == frame.title || be->window == frame.label) {
|
|
|
|
my = frame.y + frame.title_h;
|
2002-04-29 23:27:31 +00:00
|
|
|
} else if (be->window == frame.handle) {
|
2002-04-11 03:20:38 +00:00
|
|
|
my = frame.y + frame.y_handle - windowmenu->getHeight();
|
|
|
|
} else { // (be->window == frame.window)
|
|
|
|
if (be->y <= (signed) frame.bevel_w) {
|
|
|
|
my = frame.y + frame.y_border;
|
|
|
|
} else {
|
|
|
|
my = be->y_root - (windowmenu->getHeight() / 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mx > (signed) (frame.x + frame.width -
|
|
|
|
windowmenu->getWidth())) {
|
|
|
|
mx = frame.x + frame.width - windowmenu->getWidth();
|
|
|
|
} else if (mx < frame.x) {
|
|
|
|
mx = frame.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (my > (signed) (frame.y + frame.y_handle -
|
|
|
|
windowmenu->getHeight())) {
|
|
|
|
my = frame.y + frame.y_handle - windowmenu->getHeight();
|
|
|
|
} else if (my < (signed) (frame.y +
|
|
|
|
((decorations.titlebar) ? frame.title_h : frame.y_border))) {
|
|
|
|
my = frame.y +
|
|
|
|
((decorations.titlebar) ? frame.title_h : frame.y_border);
|
|
|
|
}
|
|
|
|
|
|
|
|
windowmenu->move(mx, my);
|
|
|
|
windowmenu->show();
|
|
|
|
XRaiseWindow(display, windowmenu->getWindowID());
|
|
|
|
XRaiseWindow(display, windowmenu->getSendToMenu()->getWindowID());
|
|
|
|
stack_change = 0; // dont raise the window overtop of the menu
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// mouse wheel up
|
|
|
|
} else if (be->state == 0 && be->button == 4) {
|
|
|
|
if ((be->window == frame.label ||
|
|
|
|
be->window == frame.title) &&
|
|
|
|
!flags.shaded)
|
|
|
|
shade();
|
|
|
|
// mouse wheel down
|
|
|
|
} else if (be->state == 0 && be->button == 5) {
|
|
|
|
if ((be->window == frame.label ||
|
|
|
|
be->window == frame.title) &&
|
|
|
|
flags.shaded)
|
|
|
|
shade();
|
|
|
|
}
|
|
|
|
|
2002-04-17 08:30:55 +00:00
|
|
|
if (! (flags.focused || screen->sloppyFocus()) ) {
|
2002-04-11 03:20:38 +00:00
|
|
|
setInputFocus(); // any click focus' the window in 'click to focus'
|
|
|
|
}
|
|
|
|
if (stack_change < 0) {
|
|
|
|
screen->getWorkspace(workspace_number)->lowerWindow(this);
|
|
|
|
} else if (stack_change > 0) {
|
|
|
|
screen->getWorkspace(workspace_number)->raiseWindow(this);
|
|
|
|
}
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::buttonReleaseEvent(XButtonEvent *re) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.grab();
|
2002-04-11 03:20:38 +00:00
|
|
|
if (! validateClient())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// alt + middle button released
|
|
|
|
if (re->state == (Mod1Mask & Button2Mask) && re->button == 2) {
|
|
|
|
if (re->window == frame.window) {
|
|
|
|
XUngrabPointer(display, CurrentTime); // why? i dont know
|
|
|
|
}
|
|
|
|
// left button released
|
|
|
|
} else if (re->button == 1) {
|
|
|
|
if (re->window == frame.maximize_button) {
|
|
|
|
if (re->state == Button1Mask && // only the left button was depressed
|
|
|
|
(re->x >= 0) && ((unsigned) re->x <= frame.button_w) &&
|
|
|
|
(re->y >= 0) && ((unsigned) re->y <= frame.button_h)) {
|
|
|
|
maximize(re->button);
|
|
|
|
} else {
|
|
|
|
redrawMaximizeButton(False);
|
|
|
|
}
|
|
|
|
} else if (re->window == frame.iconify_button) {
|
|
|
|
if (re->state == Button1Mask && // only the left button was depressed
|
|
|
|
(re->x >= 0) && ((unsigned) re->x <= frame.button_w) &&
|
|
|
|
(re->y >= 0) && ((unsigned) re->y <= frame.button_h)) {
|
|
|
|
iconify();
|
|
|
|
} else {
|
|
|
|
redrawIconifyButton(False);
|
|
|
|
}
|
|
|
|
} else if (re->window == frame.close_button) {
|
|
|
|
if (re->state == Button1Mask && // only the left button was depressed
|
|
|
|
(re->x >= 0) && ((unsigned) re->x <= frame.button_w) &&
|
|
|
|
(re->y >= 0) && ((unsigned) re->y <= frame.button_h)) {
|
|
|
|
close();
|
|
|
|
}
|
2002-04-12 06:05:04 +00:00
|
|
|
//we should always redraw the close button. some applications
|
|
|
|
//eg. acroread don't honour the close.
|
|
|
|
redrawCloseButton(False);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
// middle button released
|
|
|
|
} else if (re->button == 2) {
|
|
|
|
if (re->window == frame.maximize_button) {
|
|
|
|
if (re->state == Button2Mask && // only the middle button was depressed
|
|
|
|
(re->x >= 0) && ((unsigned) re->x <= frame.button_w) &&
|
|
|
|
(re->y >= 0) && ((unsigned) re->y <= frame.button_h)) {
|
|
|
|
maximize(re->button);
|
|
|
|
} else {
|
|
|
|
redrawMaximizeButton(False);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// right button released
|
|
|
|
} else if (re->button == 3) {
|
|
|
|
if (re->window == frame.maximize_button) {
|
|
|
|
if (re->state == Button3Mask && // only the right button was depressed
|
|
|
|
(re->x >= 0) && ((unsigned) re->x <= frame.button_w) &&
|
|
|
|
(re->y >= 0) && ((unsigned) re->y <= frame.button_h)) {
|
|
|
|
maximize(re->button);
|
|
|
|
} else {
|
|
|
|
redrawMaximizeButton(False);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// when the window is being interactively moved, a button release stops the
|
|
|
|
// move where it is
|
|
|
|
if (flags.moving) {
|
2002-04-28 11:26:55 +00:00
|
|
|
endMove();
|
2002-04-11 03:20:38 +00:00
|
|
|
// when the window is being interactively resized, a button release stops the
|
|
|
|
// resizing
|
|
|
|
} else if (flags.resizing) {
|
|
|
|
flags.resizing = False;
|
|
|
|
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
|
|
|
|
frame.resize_x, frame.resize_y,
|
|
|
|
frame.resize_w - 1, frame.resize_h - 1);
|
|
|
|
screen->hideGeometry();
|
|
|
|
if (resize_zone & ZoneLeft) {
|
|
|
|
left_fixsize();
|
|
|
|
} else { // when resizing with "Alt+Button3", the resize is the same as if
|
|
|
|
// done with the right grip (the right side of the window is what
|
|
|
|
// moves)
|
|
|
|
right_fixsize();
|
|
|
|
}
|
|
|
|
// unset maximized state when resized after fully maximized
|
|
|
|
if (flags.maximized == 1) {
|
|
|
|
maximize(0);
|
|
|
|
}
|
|
|
|
configure(frame.resize_x, frame.resize_y,
|
|
|
|
frame.resize_w - (frame.border_w * 2),
|
|
|
|
frame.resize_h - (frame.border_w * 2));
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-11 03:20:38 +00:00
|
|
|
XUngrabPointer(display, CurrentTime);
|
|
|
|
resize_zone = 0;
|
|
|
|
}
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-28 11:26:55 +00:00
|
|
|
void OpenboxWindow::startMove(int x, int y) {
|
|
|
|
ASSERT(!flags.moving);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-30 08:09:53 +00:00
|
|
|
// make sure only one window is moving at a time
|
2002-05-01 07:13:12 +00:00
|
|
|
OpenboxWindow *w = openbox.getMaskedWindow();
|
|
|
|
if (w != (OpenboxWindow *) 0 && w->flags.moving)
|
2002-04-30 08:09:53 +00:00
|
|
|
w->endMove();
|
|
|
|
|
2002-04-28 12:12:24 +00:00
|
|
|
XGrabPointer(display, frame.window, False, PointerMotionMask |
|
2002-04-28 11:26:55 +00:00
|
|
|
ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
|
|
|
|
None, openbox.getMoveCursor(), CurrentTime);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-28 11:26:55 +00:00
|
|
|
if (windowmenu && windowmenu->isVisible())
|
|
|
|
windowmenu->hide();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-28 11:26:55 +00:00
|
|
|
flags.moving = True;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-28 11:26:55 +00:00
|
|
|
openbox.maskWindowEvents(client.window, this);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-28 11:26:55 +00:00
|
|
|
if (! screen->opaqueMove()) {
|
|
|
|
openbox.grab();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-28 11:26:55 +00:00
|
|
|
frame.move_x = frame.x;
|
|
|
|
frame.move_y = frame.y;
|
|
|
|
frame.resize_w = frame.width + (frame.border_w * 2);
|
|
|
|
frame.resize_h = ((flags.shaded) ? frame.title_h : frame.height) +
|
|
|
|
(frame.border_w * 2);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-28 11:26:55 +00:00
|
|
|
screen->showPosition(frame.x, frame.y);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-28 11:26:55 +00:00
|
|
|
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
|
|
|
|
frame.move_x, frame.move_y,
|
|
|
|
frame.resize_w - 1, frame.resize_h - 1);
|
|
|
|
}
|
|
|
|
frame.grab_x = x - frame.x - frame.border_w;
|
|
|
|
frame.grab_y = y - frame.y - frame.border_w;
|
2002-04-30 07:24:54 +00:00
|
|
|
cout << "START MOVE " << client.window << " " << client.title << endl;
|
2002-04-28 11:26:55 +00:00
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
|
2002-04-28 11:26:55 +00:00
|
|
|
void OpenboxWindow::doMove(int x, int y) {
|
|
|
|
ASSERT(flags.moving);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-28 11:26:55 +00:00
|
|
|
int dx = x - frame.grab_x, dy = y - frame.grab_y;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-28 11:26:55 +00:00
|
|
|
dx -= frame.border_w;
|
|
|
|
dy -= frame.border_w;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-28 11:26:55 +00:00
|
|
|
int snap_distance = screen->edgeSnapThreshold();
|
|
|
|
// width/height of the snapping window
|
|
|
|
unsigned int snap_w = frame.width + (frame.border_w * 2);
|
|
|
|
unsigned int snap_h = area().h() + (frame.border_w * 2);
|
|
|
|
if (snap_distance) {
|
|
|
|
int drx = screen->size().w() - (dx + snap_w);
|
|
|
|
|
|
|
|
if (dx < drx && (dx > 0 && dx < snap_distance) ||
|
|
|
|
(dx < 0 && dx > -snap_distance) )
|
|
|
|
dx = 0;
|
|
|
|
else if ( (drx > 0 && drx < snap_distance) ||
|
|
|
|
(drx < 0 && drx > -snap_distance) )
|
|
|
|
dx = screen->size().w() - snap_w;
|
|
|
|
|
|
|
|
int dtty, dbby, dty, dby;
|
|
|
|
switch (screen->getToolbar()->placement()) {
|
|
|
|
case Toolbar::TopLeft:
|
|
|
|
case Toolbar::TopCenter:
|
|
|
|
case Toolbar::TopRight:
|
|
|
|
dtty = screen->getToolbar()->getExposedHeight() +
|
|
|
|
frame.border_w;
|
|
|
|
dbby = screen->size().h();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
dtty = 0;
|
|
|
|
dbby = screen->getToolbar()->area().y();
|
|
|
|
break;
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
2002-04-28 11:26:55 +00:00
|
|
|
|
|
|
|
dty = dy - dtty;
|
|
|
|
dby = dbby - (dy + snap_h);
|
|
|
|
|
|
|
|
if ( (dy > 0 && dty < snap_distance) ||
|
|
|
|
(dy < 0 && dty > -snap_distance) )
|
|
|
|
dy = dtty;
|
|
|
|
else if ( (dby > 0 && dby < snap_distance) ||
|
|
|
|
(dby < 0 && dby > -snap_distance) )
|
|
|
|
dy = dbby - snap_h;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (screen->opaqueMove()) {
|
|
|
|
configure(dx, dy, frame.width, frame.height);
|
|
|
|
} else {
|
|
|
|
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
|
|
|
|
frame.move_x, frame.move_y, frame.resize_w - 1,
|
|
|
|
frame.resize_h - 1);
|
|
|
|
|
|
|
|
frame.move_x = dx;
|
|
|
|
frame.move_y = dy;
|
|
|
|
|
|
|
|
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
|
|
|
|
frame.move_x, frame.move_y, frame.resize_w - 1,
|
|
|
|
frame.resize_h - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
screen->showPosition(dx, dy);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::endMove() {
|
|
|
|
ASSERT(flags.moving);
|
|
|
|
|
|
|
|
flags.moving = False;
|
|
|
|
|
|
|
|
openbox.maskWindowEvents(0, (OpenboxWindow *) 0);
|
|
|
|
if (!screen->opaqueMove()) {
|
|
|
|
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
|
|
|
|
frame.move_x, frame.move_y, frame.resize_w - 1,
|
|
|
|
frame.resize_h - 1);
|
|
|
|
|
|
|
|
configure(frame.move_x, frame.move_y, frame.width, frame.height);
|
|
|
|
openbox.ungrab();
|
|
|
|
} else {
|
|
|
|
configure(frame.x, frame.y, frame.width, frame.height);
|
|
|
|
}
|
|
|
|
screen->hideGeometry();
|
|
|
|
XUngrabPointer(display, CurrentTime);
|
2002-04-30 07:24:54 +00:00
|
|
|
// if there are any left over motions from the move, drop them now cuz they
|
|
|
|
// cause problems
|
|
|
|
XEvent e;
|
|
|
|
while (XCheckTypedWindowEvent(display, frame.window, MotionNotify, &e));
|
|
|
|
cout << "END MOVE " << client.window << " " << client.title << endl;
|
2002-04-28 11:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::motionNotifyEvent(XMotionEvent *me) {
|
2002-04-28 12:12:24 +00:00
|
|
|
if (flags.moving)
|
2002-04-28 11:26:55 +00:00
|
|
|
doMove(me->x_root, me->y_root);
|
2002-04-28 12:12:24 +00:00
|
|
|
else if (!flags.resizing && (me->state & Button1Mask) && functions.move &&
|
|
|
|
(frame.title == me->window || frame.label == me->window ||
|
|
|
|
frame.handle == me->window || frame.window == me->window))
|
|
|
|
startMove(me->x_root, me->y_root);
|
|
|
|
else if (functions.resize &&
|
2002-04-11 03:20:38 +00:00
|
|
|
(((me->state & Button1Mask) && (me->window == frame.right_grip ||
|
|
|
|
me->window == frame.left_grip)) ||
|
2002-04-30 07:24:54 +00:00
|
|
|
(me->state == (Mod1Mask | Button3Mask) &&
|
2002-04-11 03:20:38 +00:00
|
|
|
me->window == frame.window))) {
|
|
|
|
Bool left = resize_zone & ZoneLeft;
|
|
|
|
|
|
|
|
if (! flags.resizing) {
|
2002-04-30 07:24:54 +00:00
|
|
|
cout << "START RESIZE " << client.window << " " << client.title << endl;
|
2002-04-11 03:20:38 +00:00
|
|
|
Cursor cursor;
|
|
|
|
if (resize_zone & ZoneTop)
|
|
|
|
cursor = (resize_zone & ZoneLeft) ?
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.getUpperLeftAngleCursor() :
|
|
|
|
openbox.getUpperRightAngleCursor();
|
2002-04-11 03:20:38 +00:00
|
|
|
else
|
|
|
|
cursor = (resize_zone & ZoneLeft) ?
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.getLowerLeftAngleCursor() :
|
|
|
|
openbox.getLowerRightAngleCursor();
|
2002-04-11 03:20:38 +00:00
|
|
|
XGrabPointer(display, me->window, False, ButtonMotionMask |
|
|
|
|
ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None,
|
|
|
|
cursor, CurrentTime);
|
|
|
|
|
|
|
|
flags.resizing = True;
|
|
|
|
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.grab();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
int gx, gy;
|
|
|
|
if (resize_zone & ZoneRight)
|
|
|
|
frame.grab_x = me->x - screen->getBorderWidth();
|
|
|
|
else
|
|
|
|
frame.grab_x = me->x + screen->getBorderWidth();
|
|
|
|
if (resize_zone & ZoneTop)
|
|
|
|
frame.grab_y = me->y + screen->getBorderWidth() * 2;
|
|
|
|
else
|
|
|
|
frame.grab_y = me->y - screen->getBorderWidth() * 2;
|
|
|
|
frame.resize_x = frame.x;
|
|
|
|
frame.resize_y = frame.y;
|
|
|
|
frame.resize_w = frame.width + (frame.border_w * 2);
|
|
|
|
frame.resize_h = frame.height + (frame.border_w * 2);
|
|
|
|
|
|
|
|
if (left)
|
|
|
|
left_fixsize(&gx, &gy);
|
|
|
|
else
|
|
|
|
right_fixsize(&gx, &gy);
|
|
|
|
|
|
|
|
screen->showGeometry(gx, gy);
|
|
|
|
|
|
|
|
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
|
|
|
|
frame.resize_x, frame.resize_y,
|
|
|
|
frame.resize_w - 1, frame.resize_h - 1);
|
|
|
|
} else {
|
|
|
|
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
|
|
|
|
frame.resize_x, frame.resize_y,
|
|
|
|
frame.resize_w - 1, frame.resize_h - 1);
|
|
|
|
|
|
|
|
int gx, gy;
|
|
|
|
|
|
|
|
if (resize_zone & ZoneTop)
|
|
|
|
frame.resize_h = frame.height - (me->y - frame.grab_y);
|
|
|
|
else
|
|
|
|
frame.resize_h = frame.height + (me->y - frame.grab_y);
|
|
|
|
if (frame.resize_h < 1) frame.resize_h = 1;
|
|
|
|
|
|
|
|
if (left) {
|
|
|
|
frame.resize_x = me->x_root - frame.grab_x;
|
|
|
|
if (frame.resize_x > (signed) (frame.x + frame.width))
|
|
|
|
frame.resize_x = frame.resize_x + frame.width - 1;
|
|
|
|
|
|
|
|
left_fixsize(&gx, &gy);
|
|
|
|
} else {
|
|
|
|
frame.resize_w = frame.width + (me->x - frame.grab_x);
|
|
|
|
if (frame.resize_w < 1) frame.resize_w = 1;
|
|
|
|
|
|
|
|
right_fixsize(&gx, &gy);
|
|
|
|
}
|
|
|
|
|
|
|
|
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
|
|
|
|
frame.resize_x, frame.resize_y,
|
|
|
|
frame.resize_w - 1, frame.resize_h - 1);
|
|
|
|
|
|
|
|
screen->showGeometry(gx, gy);
|
|
|
|
}
|
2002-04-30 07:24:54 +00:00
|
|
|
} else
|
|
|
|
cout << "MOTION " << client.window << " " << client.title << endl;
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SHAPE
|
|
|
|
void OpenboxWindow::shapeEvent(XShapeEvent *) {
|
2002-04-14 14:04:16 +00:00
|
|
|
if (openbox.hasShapeExtensions()) {
|
2002-04-11 03:20:38 +00:00
|
|
|
if (flags.shaped) {
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.grab();
|
2002-04-11 03:20:38 +00:00
|
|
|
if (! validateClient()) return;
|
|
|
|
XShapeCombineShape(display, frame.window, ShapeBounding,
|
|
|
|
frame.mwm_border_w, frame.y_border +
|
|
|
|
frame.mwm_border_w, client.window,
|
|
|
|
ShapeBounding, ShapeSet);
|
|
|
|
|
|
|
|
int num = 1;
|
|
|
|
XRectangle xrect[2];
|
|
|
|
xrect[0].x = xrect[0].y = 0;
|
|
|
|
xrect[0].width = frame.width;
|
|
|
|
xrect[0].height = frame.y_border;
|
|
|
|
|
|
|
|
if (decorations.handle) {
|
|
|
|
xrect[1].x = 0;
|
|
|
|
xrect[1].y = frame.y_handle;
|
|
|
|
xrect[1].width = frame.width;
|
|
|
|
xrect[1].height = frame.handle_h + frame.border_w;
|
|
|
|
num++;
|
|
|
|
}
|
|
|
|
|
|
|
|
XShapeCombineRectangles(display, frame.window, ShapeBounding, 0, 0,
|
|
|
|
xrect, num, ShapeUnion, Unsorted);
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // SHAPE
|
|
|
|
|
|
|
|
|
|
|
|
Bool OpenboxWindow::validateClient(void) {
|
|
|
|
XSync(display, False);
|
|
|
|
|
|
|
|
XEvent e;
|
|
|
|
if (XCheckTypedWindowEvent(display, client.window, DestroyNotify, &e) ||
|
|
|
|
XCheckTypedWindowEvent(display, client.window, UnmapNotify, &e)) {
|
|
|
|
XPutBackEvent(display, &e);
|
2002-04-14 14:04:16 +00:00
|
|
|
openbox.ungrab();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::restore(void) {
|
|
|
|
XChangeSaveSet(display, client.window, SetModeDelete);
|
|
|
|
XSelectInput(display, client.window, NoEventMask);
|
|
|
|
|
|
|
|
restoreGravity();
|
|
|
|
|
|
|
|
XUnmapWindow(display, frame.window);
|
|
|
|
XUnmapWindow(display, client.window);
|
|
|
|
|
|
|
|
XSetWindowBorderWidth(display, client.window, client.old_bw);
|
|
|
|
XReparentWindow(display, client.window, screen->getRootWindow(),
|
|
|
|
client.x, client.y);
|
|
|
|
XMapWindow(display, client.window);
|
|
|
|
|
|
|
|
XFlush(display);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::timeout(void) {
|
|
|
|
screen->getWorkspace(workspace_number)->raiseWindow(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::changeOpenboxHints(OpenboxHints *net) {
|
|
|
|
if ((net->flags & AttribShaded) &&
|
|
|
|
((openbox_attrib.attrib & AttribShaded) !=
|
|
|
|
(net->attrib & AttribShaded)))
|
|
|
|
shade();
|
|
|
|
|
|
|
|
if (flags.visible && // watch out for requests when we can not be seen
|
|
|
|
(net->flags & (AttribMaxVert | AttribMaxHoriz)) &&
|
|
|
|
((openbox_attrib.attrib & (AttribMaxVert | AttribMaxHoriz)) !=
|
|
|
|
(net->attrib & (AttribMaxVert | AttribMaxHoriz)))) {
|
|
|
|
if (flags.maximized) {
|
|
|
|
maximize(0);
|
|
|
|
} else {
|
|
|
|
int button = 0;
|
|
|
|
|
|
|
|
if ((net->flags & AttribMaxHoriz) && (net->flags & AttribMaxVert))
|
|
|
|
button = ((net->attrib & (AttribMaxHoriz | AttribMaxVert)) ? 1 : 0);
|
|
|
|
else if (net->flags & AttribMaxVert)
|
|
|
|
button = ((net->attrib & AttribMaxVert) ? 2 : 0);
|
|
|
|
else if (net->flags & AttribMaxHoriz)
|
|
|
|
button = ((net->attrib & AttribMaxHoriz) ? 3 : 0);
|
|
|
|
|
|
|
|
maximize(button);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((net->flags & AttribOmnipresent) &&
|
|
|
|
((openbox_attrib.attrib & AttribOmnipresent) !=
|
|
|
|
(net->attrib & AttribOmnipresent)))
|
|
|
|
stick();
|
|
|
|
|
|
|
|
if ((net->flags & AttribWorkspace) &&
|
|
|
|
(workspace_number != (signed) net->workspace)) {
|
|
|
|
screen->reassociateWindow(this, net->workspace, True);
|
|
|
|
|
|
|
|
if (screen->getCurrentWorkspaceID() != (signed) net->workspace) withdraw();
|
|
|
|
else deiconify();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (net->flags & AttribDecoration) {
|
|
|
|
switch (net->decoration) {
|
|
|
|
case DecorNone:
|
|
|
|
decorations.titlebar = decorations.border = decorations.handle =
|
|
|
|
decorations.iconify = decorations.maximize = decorations.menu = False;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
case DecorNormal:
|
2002-04-29 07:31:44 +00:00
|
|
|
decorations.titlebar = decorations.iconify = decorations.menu =
|
|
|
|
decorations.border = True;
|
|
|
|
decorations.handle = (functions.resize && !flags.transient);
|
|
|
|
decorations.maximize = functions.maximize;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DecorTiny:
|
|
|
|
decorations.titlebar = decorations.iconify = decorations.menu = True;
|
2002-04-29 07:31:44 +00:00
|
|
|
decorations.border = decorations.border = decorations.handle = False;
|
|
|
|
decorations.maximize = functions.maximize;
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DecorTool:
|
2002-04-29 07:31:44 +00:00
|
|
|
decorations.titlebar = decorations.menu = True;
|
|
|
|
decorations.iconify = decorations.border = False;
|
|
|
|
decorations.handle = (functions.resize && !flags.transient);
|
|
|
|
decorations.maximize = functions.maximize;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (frame.window) {
|
|
|
|
XMapSubwindows(display, frame.window);
|
|
|
|
XMapWindow(display, frame.window);
|
|
|
|
}
|
|
|
|
|
|
|
|
reconfigure();
|
|
|
|
setState(current_state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the sizes of all components of the window frame
|
|
|
|
* (the window decorations).
|
|
|
|
* These values are based upon the current style settings and the client
|
|
|
|
* window's dimentions.
|
|
|
|
*/
|
|
|
|
void OpenboxWindow::upsize(void) {
|
|
|
|
frame.bevel_w = screen->getBevelWidth();
|
|
|
|
|
|
|
|
if (decorations.border) {
|
|
|
|
frame.border_w = screen->getBorderWidth();
|
|
|
|
if (!flags.transient)
|
|
|
|
frame.mwm_border_w = screen->getFrameWidth();
|
|
|
|
else
|
|
|
|
frame.mwm_border_w = 0;
|
|
|
|
} else {
|
|
|
|
frame.mwm_border_w = frame.border_w = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (decorations.titlebar) {
|
|
|
|
// the height of the titlebar is based upon the height of the font being
|
|
|
|
// used to display the window's title
|
|
|
|
WindowStyle *style = screen->getWindowStyle();
|
|
|
|
if (i18n->multibyte())
|
|
|
|
frame.title_h = (style->fontset_extents->max_ink_extent.height +
|
|
|
|
(frame.bevel_w * 2) + 2);
|
|
|
|
else
|
|
|
|
frame.title_h = (style->font->ascent + style->font->descent +
|
|
|
|
(frame.bevel_w * 2) + 2);
|
|
|
|
|
|
|
|
frame.label_h = frame.title_h - (frame.bevel_w * 2);
|
|
|
|
frame.button_w = frame.button_h = (frame.label_h - 2);
|
|
|
|
frame.y_border = frame.title_h + frame.border_w;
|
|
|
|
} else {
|
|
|
|
frame.title_h = 0;
|
|
|
|
frame.label_h = 0;
|
|
|
|
frame.button_w = frame.button_h = 0;
|
|
|
|
frame.y_border = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
frame.border_h = client.height + frame.mwm_border_w * 2;
|
|
|
|
|
|
|
|
if (decorations.handle) {
|
|
|
|
frame.y_handle = frame.y_border + frame.border_h + frame.border_w;
|
|
|
|
frame.grip_w = frame.button_w * 2;
|
|
|
|
frame.grip_h = frame.handle_h = screen->getHandleWidth();
|
|
|
|
} else {
|
|
|
|
frame.y_handle = frame.y_border + frame.border_h;
|
|
|
|
frame.handle_h = 0;
|
|
|
|
frame.grip_w = frame.grip_h = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
frame.width = client.width + (frame.mwm_border_w * 2);
|
|
|
|
frame.height = frame.y_handle + frame.handle_h;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the size and position of the client window.
|
|
|
|
* These values are based upon the current style settings and the frame
|
|
|
|
* window's dimensions.
|
|
|
|
*/
|
|
|
|
void OpenboxWindow::downsize(void) {
|
|
|
|
frame.y_handle = frame.height - frame.handle_h;
|
|
|
|
frame.border_h = frame.y_handle - frame.y_border -
|
|
|
|
(decorations.handle ? frame.border_w : 0);
|
|
|
|
|
|
|
|
client.x = frame.x + frame.mwm_border_w + frame.border_w;
|
|
|
|
client.y = frame.y + frame.y_border + frame.mwm_border_w + frame.border_w;
|
|
|
|
|
|
|
|
client.width = frame.width - (frame.mwm_border_w * 2);
|
|
|
|
client.height = frame.height - frame.y_border - (frame.mwm_border_w * 2)
|
|
|
|
- frame.handle_h - (decorations.handle ? frame.border_w : 0);
|
|
|
|
|
|
|
|
frame.y_handle = frame.border_h + frame.y_border + frame.border_w;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::right_fixsize(int *gx, int *gy) {
|
|
|
|
// calculate the size of the client window and conform it to the
|
|
|
|
// size specified by the size hints of the client window...
|
|
|
|
int dx = frame.resize_w - client.base_width - (frame.mwm_border_w * 2) -
|
|
|
|
(frame.border_w * 2) + (client.width_inc / 2);
|
|
|
|
int dy = frame.resize_h - frame.y_border - client.base_height -
|
|
|
|
frame.handle_h - (frame.border_w * 3) - (frame.mwm_border_w * 2)
|
|
|
|
+ (client.height_inc / 2);
|
|
|
|
|
|
|
|
if (dx < (signed) client.min_width) dx = client.min_width;
|
|
|
|
if (dy < (signed) client.min_height) dy = client.min_height;
|
|
|
|
if ((unsigned) dx > client.max_width) dx = client.max_width;
|
|
|
|
if ((unsigned) dy > client.max_height) dy = client.max_height;
|
|
|
|
|
|
|
|
dx /= client.width_inc;
|
|
|
|
dy /= client.height_inc;
|
|
|
|
|
|
|
|
if (gx) *gx = dx;
|
|
|
|
if (gy) *gy = dy;
|
|
|
|
|
|
|
|
dx = (dx * client.width_inc) + client.base_width;
|
|
|
|
dy = (dy * client.height_inc) + client.base_height;
|
|
|
|
|
|
|
|
frame.resize_w = dx + (frame.mwm_border_w * 2) + (frame.border_w * 2);
|
|
|
|
frame.resize_h = dy + frame.y_border + frame.handle_h +
|
|
|
|
(frame.mwm_border_w * 2) + (frame.border_w * 3);
|
|
|
|
if (resize_zone & ZoneTop)
|
|
|
|
frame.resize_y = frame.y + frame.height - frame.resize_h +
|
|
|
|
screen->getBorderWidth() * 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenboxWindow::left_fixsize(int *gx, int *gy) {
|
|
|
|
// calculate the size of the client window and conform it to the
|
|
|
|
// size specified by the size hints of the client window...
|
|
|
|
int dx = frame.x + frame.width - frame.resize_x - client.base_width -
|
|
|
|
(frame.mwm_border_w * 2) + (client.width_inc / 2);
|
|
|
|
int dy = frame.resize_h - frame.y_border - client.base_height -
|
|
|
|
frame.handle_h - (frame.border_w * 3) - (frame.mwm_border_w * 2)
|
|
|
|
+ (client.height_inc / 2);
|
|
|
|
|
|
|
|
if (dx < (signed) client.min_width) dx = client.min_width;
|
|
|
|
if (dy < (signed) client.min_height) dy = client.min_height;
|
|
|
|
if ((unsigned) dx > client.max_width) dx = client.max_width;
|
|
|
|
if ((unsigned) dy > client.max_height) dy = client.max_height;
|
|
|
|
|
|
|
|
dx /= client.width_inc;
|
|
|
|
dy /= client.height_inc;
|
|
|
|
|
|
|
|
if (gx) *gx = dx;
|
|
|
|
if (gy) *gy = dy;
|
|
|
|
|
|
|
|
dx = (dx * client.width_inc) + client.base_width;
|
|
|
|
dy = (dy * client.height_inc) + client.base_height;
|
|
|
|
|
|
|
|
frame.resize_w = dx + (frame.mwm_border_w * 2) + (frame.border_w * 2);
|
|
|
|
frame.resize_x = frame.x + frame.width - frame.resize_w +
|
|
|
|
(frame.border_w * 2);
|
|
|
|
frame.resize_h = dy + frame.y_border + frame.handle_h +
|
|
|
|
(frame.mwm_border_w * 2) + (frame.border_w * 3);
|
|
|
|
if (resize_zone & ZoneTop)
|
|
|
|
frame.resize_y = frame.y + frame.height - frame.resize_h +
|
|
|
|
screen->getBorderWidth() * 2;
|
|
|
|
|
|
|
|
}
|