X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2FWindow.cc;h=b73af2b503618607dcb8742262cb151d1892bb77;hb=551a17d2563679eb6ef7c650f1384ee7e48dbc29;hp=3edc83d1965d39acac37497a306675552acff754;hpb=f633c5f057f3f19df20a31ee4bb62f27902b7e74;p=chaz%2Fopenbox diff --git a/src/Window.cc b/src/Window.cc index 3edc83d1..b73af2b5 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -142,7 +142,7 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) { functions = Func_Resize | Func_Move | Func_Iconify | Func_Maximize; mwm_decorations = Decor_Titlebar | Decor_Handle | Decor_Border | - Decor_Iconify | Decor_Maximize | Decor_Close; + Decor_Iconify | Decor_Maximize; client.normal_hint_flags = 0; client.window_group = None; @@ -153,7 +153,7 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) { windowmenu = 0; /* - get the initial size and location of client window (relative to the + set 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. */ @@ -422,13 +422,12 @@ void BlackboxWindow::enableDecor(bool enable) { void BlackboxWindow::setupDecor() { if (blackbox_attrib.decoration != DecorNone) { // start with everything on - decorations = + decorations = Decor_Close | (mwm_decorations & Decor_Titlebar ? Decor_Titlebar : 0) | (mwm_decorations & Decor_Border ? Decor_Border : 0) | (mwm_decorations & Decor_Handle ? Decor_Handle : 0) | (mwm_decorations & Decor_Iconify ? Decor_Iconify : 0) | - (mwm_decorations & Decor_Maximize ? Decor_Maximize : 0) | - (mwm_decorations & Decor_Close ? Decor_Close : 0); + (mwm_decorations & Decor_Maximize ? Decor_Maximize : 0); if (! (functions & Func_Close)) decorations &= ~Decor_Close; if (! (functions & Func_Maximize)) decorations &= ~Decor_Maximize; @@ -1311,7 +1310,7 @@ void BlackboxWindow::getMWMHints(void) { if (mwm_hint->flags & MwmHintsDecorations) { if (mwm_hint->decorations & MwmDecorAll) { mwm_decorations = Decor_Titlebar | Decor_Handle | Decor_Border | - Decor_Iconify | Decor_Maximize | Decor_Close; + Decor_Iconify | Decor_Maximize; } else { mwm_decorations = 0; @@ -2612,6 +2611,14 @@ void BlackboxWindow::mapRequestEvent(const XMapRequestEvent *re) { client.window); #endif // DEBUG + /* + Even though the window wants to be shown, if it is not on the current + workspace, then it isn't going to be shown right now. + */ + if (blackbox_attrib.workspace != screen->getCurrentWorkspaceID() && + blackbox_attrib.workspace < screen->getWorkspaceCount()) + if (current_state == NormalState) current_state = WithdrawnState; + switch (current_state) { case IconicState: iconify(); @@ -2630,8 +2637,8 @@ void BlackboxWindow::mapRequestEvent(const XMapRequestEvent *re) { if (isNormal()) { if (! blackbox->isStartup()) { XSync(blackbox->getXDisplay(), False); // make sure the frame is mapped - if (screen->doFocusNew()|| (isTransient() && getTransientFor() && - getTransientFor()->isFocused())) { + if (screen->doFocusNew() || (isTransient() && getTransientFor() && + getTransientFor()->isFocused())) { setInputFocus(); } if (screen->getPlacementPolicy() == BScreen::ClickMousePlacement) { @@ -2695,7 +2702,7 @@ void BlackboxWindow::propertyNotifyEvent(const XPropertyEvent *pe) { if (pe->state == PropertyDelete) return; -#ifdef DEBUG +#if 0 fprintf(stderr, "BlackboxWindow::propertyNotifyEvent(): for 0x%lx\n", client.window); #endif @@ -2707,9 +2714,13 @@ void BlackboxWindow::propertyNotifyEvent(const XPropertyEvent *pe) { break; case XA_WM_TRANSIENT_FOR: { + bool s = flags.stuck; + // determine if this is a transient window getTransientInfo(); + if (flags.stuck != s) stick(); + // adjust the window decorations based on transience if (isTransient()) { functions &= ~Func_Maximize; @@ -2793,7 +2804,7 @@ void BlackboxWindow::propertyNotifyEvent(const XPropertyEvent *pe) { void BlackboxWindow::exposeEvent(const XExposeEvent *ee) { -#ifdef DEBUG +#if 0 fprintf(stderr, "BlackboxWindow::exposeEvent() for 0x%lx\n", client.window); #endif @@ -3047,10 +3058,6 @@ void BlackboxWindow::doMove(int x_root, int y_root) { dx -= frame.border_w; dy -= frame.border_w; - if (screen->doWorkspaceWarping()) - if (doWorkspaceWarping(x_root, y_root, dx, dy)) - return; - doWindowSnapping(dx, dy); if (screen->doOpaqueMove()) { @@ -3073,12 +3080,15 @@ void BlackboxWindow::doMove(int x_root, int y_root) { frame.changing.height() - 1); } + if (screen->doWorkspaceWarping()) + doWorkspaceWarping(x_root, y_root, dx, dy); + screen->showPosition(dx, dy); } -bool BlackboxWindow::doWorkspaceWarping(int x_root, int y_root, - int dx, int dy) { +void BlackboxWindow::doWorkspaceWarping(int x_root, int y_root, + int &dx, int dy) { // workspace warping bool warp = False; unsigned int dest = screen->getCurrentWorkspaceID(); @@ -3095,7 +3105,7 @@ bool BlackboxWindow::doWorkspaceWarping(int x_root, int y_root, else dest = 0; } if (! warp) - return false; + return; endMove(); bool focus = flags.focused; // had focus while moving? @@ -3105,6 +3115,15 @@ bool BlackboxWindow::doWorkspaceWarping(int x_root, int y_root, if (focus) setInputFocus(); + int dest_x; + if (x_root <= 0) { + dest_x = screen->getRect().right() - 1; + dx += screen->getRect().width() - 1; + } else { + dest_x = 0; + dx -= screen->getRect().width() - 1; + } + /* We grab the X server here because we are moving the window and then the mouse cursor. When one moves, it could end up putting the mouse cursor @@ -3112,23 +3131,15 @@ bool BlackboxWindow::doWorkspaceWarping(int x_root, int y_root, move on another window. */ XGrabServer(blackbox->getXDisplay()); - int dest_x; - if (x_root <= 0) { - dest_x = screen->getRect().right() - 1; - configure(dx + (screen->getRect().width() - 1), dy, - frame.rect.width(), frame.rect.height()); - } else { - dest_x = 0; - configure(dx - (screen->getRect().width() - 1), dy, - frame.rect.width(), frame.rect.height()); - } + + configure(dx, dy, frame.rect.width(), frame.rect.height()); XWarpPointer(blackbox->getXDisplay(), None, screen->getRootWindow(), 0, 0, 0, 0, dest_x, y_root); + XUngrabServer(blackbox->getXDisplay()); beginMove(dest_x, y_root); - return true; } @@ -3602,7 +3613,7 @@ void BlackboxWindow::endResize(void) { void BlackboxWindow::motionNotifyEvent(const XMotionEvent *me) { -#ifdef DEBUG +#if 0 fprintf(stderr, "BlackboxWindow::motionNotifyEvent() for 0x%lx\n", client.window); #endif @@ -3612,15 +3623,17 @@ void BlackboxWindow::motionNotifyEvent(const XMotionEvent *me) { } else if (flags.resizing) { doResize(me->x_root, me->y_root); } else { - if (!flags.resizing && me->state & Button1Mask && (functions & Func_Move) && + if ((functions & Func_Move) && + (me->state & Button1Mask) && (frame.title == me->window || frame.label == me->window || frame.handle == me->window || frame.window == me->window)) { beginMove(me->x_root, me->y_root); } else if ((functions & Func_Resize) && - (me->state & Button1Mask && (me->window == frame.right_grip || - me->window == frame.left_grip)) || - (me->state & Button3Mask && me->state & mod_mask && - me->window == frame.window)) { + ((me->state & Button1Mask) && (me->window == frame.right_grip || + me->window == frame.left_grip)) || + ((me->state & Button3Mask) && (me->state & mod_mask) && + (frame.title == me->window || frame.label == me->window || + frame.handle == me->window || frame.window == me->window))) { unsigned int zones = screen->getResizeZones(); Corner corner; @@ -3719,6 +3732,12 @@ void BlackboxWindow::restore(bool remap) { if (flags.shaded && ! flags.iconic) setState(NormalState); + // erase the netwm stuff that we read when a window maps, so that it + // doesn't persist between mappings. + // (these are the ones read in getNetWMFlags().) + xatom->eraseValue(client.window, XAtom::net_wm_desktop); + xatom->eraseValue(client.window, XAtom::net_wm_state); + restoreGravity(client.rect); XUnmapWindow(blackbox->getXDisplay(), frame.window);