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);
- }
}
for (int i = 0; format[i] != '\0' && i < 4; i++) {
switch(format[i]) {
case 'C':
- if (decorations.close && frame.close_button != None) {
+ if (decorations.close) {
+ if (frame.close_button == None)
+ createCloseButton();
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) {
+ if (decorations.iconify) {
+ if (frame.iconify_button == None)
+ createIconifyButton();
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) {
+ if (decorations.maximize) {
+ if (frame.maximize_button == None)
+ createMaximizeButton();
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,
if (!hasclose) {
openbox.removeWindowSearch(frame.close_button);
- XDestroyWindow(display, frame.close_button);
+ XDestroyWindow(display, frame.close_button);
+ frame.close_button = None;
}
if (!hasiconify) {
openbox.removeWindowSearch(frame.iconify_button);
XDestroyWindow(display, frame.iconify_button);
+ frame.iconify_button = None;
}
if (!hasmaximize) {
openbox.removeWindowSearch(frame.maximize_button);
XDestroyWindow(display, frame.maximize_button);
+ frame.maximize_button = None;
}
if (redecorate_label)
decorateLabel();
}
-Bool OpenboxWindow::setInputFocus(void) {
+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);
openbox.grab();
if (! validateClient()) return False;
- Bool ret = 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)
+ if (focus_mode == F_LocallyActive || focus_mode == F_Passive) {
XSetInputFocus(display, client.window,
- RevertToPointerRoot, CurrentTime);
- else
- XSetInputFocus(display, screen->getRootWindow(),
- RevertToNone, CurrentTime);
-
- openbox.setFocusedWindow(this);
-
- if (flags.send_focus_message) {
- XEvent ce;
- ce.xclient.type = ClientMessage;
- ce.xclient.message_type = openbox.getWMProtocolsAtom();
- ce.xclient.display = display;
- ce.xclient.window = client.window;
- ce.xclient.format = 32;
- ce.xclient.data.l[0] = openbox.getWMTakeFocusAtom();
- ce.xclient.data.l[1] = openbox.getLastTime();
- 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);
- }
+ RevertToPointerRoot, CurrentTime);
+ openbox.focusWindow(this);
+
+ if (flags.send_focus_message) {
+ XEvent ce;
+ ce.xclient.type = ClientMessage;
+ ce.xclient.message_type = openbox.getWMProtocolsAtom();
+ ce.xclient.display = display;
+ ce.xclient.window = client.window;
+ ce.xclient.format = 32;
+ ce.xclient.data.l[0] = openbox.getWMTakeFocusAtom();
+ ce.xclient.data.l[1] = openbox.getLastTime();
+ 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);
+ }
- if (screen->sloppyFocus() && screen->autoRaise())
- timer->start();
+ if (screen->sloppyFocus() && screen->autoRaise())
+ timer->start();
- ret = True;
+ ret = true;
+ }
}
openbox.ungrab();
}
-void OpenboxWindow::deiconify(Bool reassoc, Bool raise) {
+void OpenboxWindow::deiconify(bool reassoc, bool raise, bool initial) {
if (flags.iconic || reassoc)
screen->reassociateWindow(this, -1, False);
else if (workspace_number != screen->getCurrentWorkspace()->getWorkspaceID())
// if we're using the click to place placement type, then immediately
// after the window is mapped, we need to start interactively moving it
- if (screen->placementPolicy() == BScreen::ClickMousePlacement &&
- place_window && !(flags.iconic || reassoc)) {
- // if the last window wasn't placed yet, or we're just moving a window
- // already, finish off that move cleanly
- OpenboxWindow *w = openbox.getFocusedWindow();
- if (w != (OpenboxWindow *) 0 && w->flags.moving)
- w->endMove();
-
+ if (initial && place_window &&
+ screen->placementPolicy() == BScreen::ClickMousePlacement) {
int x, y, rx, ry;
Window c, r;
unsigned int m;
void OpenboxWindow::maximize(unsigned int button) {
+ if (flags.moving)
+ endMove();
+
// handle case where menu is open then the max button is used instead
if (windowmenu && windowmenu->isVisible()) windowmenu->hide();
void OpenboxWindow::setWorkspace(int n) {
+ ASSERT(n < screen->getWorkspaceCount());
workspace_number = n;
openbox_attrib.flags |= AttribWorkspace;
case InactiveState:
case ZoomState:
default:
- deiconify(False);
+ deiconify(False, True, True); // specify that we're initializing the
+ // window
break;
}
openbox.grab();
if (! validateClient()) return;
+ if (flags.moving)
+ endMove();
+
XChangeSaveSet(display, client.window, SetModeDelete);
XSelectInput(display, client.window, NoEventMask);
void OpenboxWindow::destroyNotifyEvent(XDestroyWindowEvent *de) {
if (de->window == client.window) {
+ if (flags.moving)
+ endMove();
XUnmapWindow(display, frame.window);
delete this;
void OpenboxWindow::startMove(int x, int y) {
ASSERT(!flags.moving);
+ // make sure only one window is moving at a time
+ OpenboxWindow *w = openbox.getMaskedWindow();
+ if (w != (OpenboxWindow *) 0 && w->flags.moving)
+ w->endMove();
+
XGrabPointer(display, frame.window, False, PointerMotionMask |
ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
None, openbox.getMoveCursor(), CurrentTime);
}
screen->hideGeometry();
XUngrabPointer(display, CurrentTime);
+ // 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));
}
else if (functions.resize &&
(((me->state & Button1Mask) && (me->window == frame.right_grip ||
me->window == frame.left_grip)) ||
- (me->state & (Mod1Mask | Button3Mask) &&
+ (me->state == (Mod1Mask | Button3Mask) &&
me->window == frame.window))) {
Bool left = resize_zone & ZoneLeft;
#endif // SHAPE
-Bool OpenboxWindow::validateClient(void) {
+bool OpenboxWindow::validateClient(void) {
XSync(display, False);
XEvent e;
XPutBackEvent(display, &e);
openbox.ungrab();
- return False;
+ return false;
}
- return True;
+ return true;
}
XMapWindow(display, client.window);
XFlush(display);
+
+ delete this;
}