X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FWindow.cc;h=4824a34acadc4b2ded219ea7c32264eef5faac4a;hb=c5d10bd1dda362a41460f91619ae5e85a7665f6f;hp=27c6f9454315dd309117fee1678f01fc563faddc;hpb=0f710360990e6d079116d951295c21664e2e0fce;p=chaz%2Fopenbox diff --git a/src/Window.cc b/src/Window.cc index 27c6f945..4824a34a 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -62,11 +62,6 @@ extern "C" { using std::string; using std::abs; -// change this to change what modifier keys openbox uses for mouse bindings -// for example: Mod1Mask | ControlMask -// or: ControlMask| ShiftMask -const unsigned int ModMask = Mod1Mask; - /* * Initializes the class with default values/the window's set initial values. */ @@ -147,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; @@ -158,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. */ @@ -427,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; @@ -893,6 +887,8 @@ void BlackboxWindow::reconfigure(void) { void BlackboxWindow::grabButtons(void) { + mod_mask = blackbox->getMouseModMask(); + if (! screen->isSloppyFocus() || screen->doClickRaise()) // grab button 1 for changing focus/raising blackbox->grabButton(Button1, 0, frame.plate, True, ButtonPressMask, @@ -900,17 +896,17 @@ void BlackboxWindow::grabButtons(void) { screen->allowScrollLock()); if (functions & Func_Move) - blackbox->grabButton(Button1, ModMask, frame.window, True, + blackbox->grabButton(Button1, mod_mask, frame.window, True, ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, frame.window, None, screen->allowScrollLock()); if (functions & Func_Resize) - blackbox->grabButton(Button3, ModMask, frame.window, True, + blackbox->grabButton(Button3, mod_mask, frame.window, True, ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, frame.window, None, screen->allowScrollLock()); // alt+middle lowers the window - blackbox->grabButton(Button2, ModMask, frame.window, True, + blackbox->grabButton(Button2, mod_mask, frame.window, True, ButtonReleaseMask, GrabModeAsync, GrabModeAsync, frame.window, None, screen->allowScrollLock()); @@ -919,9 +915,9 @@ void BlackboxWindow::grabButtons(void) { void BlackboxWindow::ungrabButtons(void) { blackbox->ungrabButton(Button1, 0, frame.plate); - blackbox->ungrabButton(Button1, ModMask, frame.window); - blackbox->ungrabButton(Button2, ModMask, frame.window); - blackbox->ungrabButton(Button3, ModMask, frame.window); + blackbox->ungrabButton(Button1, mod_mask, frame.window); + blackbox->ungrabButton(Button2, mod_mask, frame.window); + blackbox->ungrabButton(Button3, mod_mask, frame.window); } @@ -1314,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; @@ -1426,7 +1422,7 @@ void BlackboxWindow::getTransientInfo(void) { } // we have no transient_for until we find a new one - client.transient_for = 0; + client.transient_for = (BlackboxWindow *) 0; Window trans_for; if (! XGetTransientForHint(blackbox->getXDisplay(), client.window, @@ -2615,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(); @@ -2633,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) { @@ -2698,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 @@ -2710,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; @@ -2796,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 @@ -2864,7 +2872,7 @@ void BlackboxWindow::buttonPressEvent(const XButtonEvent *be) { if (frame.maximize_button == be->window && be->button <= 3) { redrawMaximizeButton(True); - } else if (be->button == 1 || (be->button == 3 && be->state == ModMask)) { + } else if (be->button == 1 || (be->button == 3 && be->state == mod_mask)) { if (! flags.focused) setInputFocus(); @@ -2990,7 +2998,7 @@ void BlackboxWindow::buttonReleaseEvent(const XButtonEvent *re) { } else if (flags.resizing) { endResize(); } else if (re->window == frame.window) { - if (re->button == 2 && re->state == ModMask) + if (re->button == 2 && re->state == mod_mask) XUngrabPointer(blackbox->getXDisplay(), CurrentTime); } } @@ -3605,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 @@ -3615,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 & ModMask && - 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; @@ -3722,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);