X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FWindow.cc;h=3a9821157ea585643672cd379cfd3beb729c469f;hb=72a2e98738d87b89620bafd15141690aa4be8fab;hp=2e465a0bb87f88936f37ef963930e6079b355408;hpb=e81162397896f1d6b954ac849bd636afc177f90e;p=chaz%2Fopenbox diff --git a/src/Window.cc b/src/Window.cc index 2e465a0b..3a982115 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -40,7 +40,7 @@ extern "C" { #endif // DEBUG #ifdef HAVE_STDLIB_H - #include +# include #endif // HAVE_STDLIB_H } @@ -475,7 +475,13 @@ Window BlackboxWindow::createToplevelWindow(void) { attrib_create.background_pixmap = None; attrib_create.colormap = screen->getColormap(); attrib_create.override_redirect = True; - attrib_create.event_mask = EnterWindowMask | LeaveWindowMask; + attrib_create.event_mask = EnterWindowMask | LeaveWindowMask | + ButtonPress; + /* + We catch button presses because other wise they get passed down to the + root window, which will then cause root menus to show when you click the + window's frame. + */ return XCreateWindow(blackbox->getXDisplay(), screen->getRootWindow(), 0, 0, 1, 1, frame.border_w, screen->getDepth(), @@ -722,7 +728,7 @@ void BlackboxWindow::destroyTitlebar(void) { if (frame.stick_button) destroyStickyButton(); - + if (frame.ftitle) screen->getImageControl()->removeImage(frame.ftitle); @@ -2608,12 +2614,31 @@ void BlackboxWindow::redrawIconifyButton(bool pressed) const { XSetWindowBackground(blackbox->getXDisplay(), frame.iconify_button, frame.pbutton_pixel); } - XClearWindow(blackbox->getXDisplay(), frame.iconify_button); + XClearWindow(blackbox->getXDisplay(), frame.iconify_button); BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : - screen->getWindowStyle()->b_pic_unfocus); - XDrawRectangle(blackbox->getXDisplay(), frame.iconify_button, pen.gc(), - 2, (frame.button_w - 5), (frame.button_w - 5), 2); + screen->getWindowStyle()->b_pic_unfocus); +#ifdef BITMAPBUTTONS + PixmapMask pm = screen->getWindowStyle()->icon_button; + + if (screen->getWindowStyle()->icon_button.mask != None) { + XSetClipMask(blackbox->getXDisplay(), pen.gc(), pm.mask); + XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), + (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2); + + XFillRectangle(blackbox->getXDisplay(), frame.iconify_button, pen.gc(), + (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2, + (frame.button_w + pm.w)/2, (frame.button_w + pm.h)/2); + + XSetClipMask(blackbox->getXDisplay(), pen.gc(), None); + XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0); + } else { +#endif // BITMAPBUTTONS + XDrawRectangle(blackbox->getXDisplay(), frame.iconify_button, pen.gc(), + 2, (frame.button_w - 5), (frame.button_w - 5), 2); +#ifdef BITMAPBUTTONS + } +#endif // BITMAPBUTTONS } @@ -2646,10 +2671,30 @@ void BlackboxWindow::redrawMaximizeButton(bool pressed) const { BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : screen->getWindowStyle()->b_pic_unfocus); - XDrawRectangle(blackbox->getXDisplay(), frame.maximize_button, pen.gc(), - 2, 2, (frame.button_w - 5), (frame.button_w - 5)); - XDrawLine(blackbox->getXDisplay(), frame.maximize_button, pen.gc(), - 2, 3, (frame.button_w - 3), 3); + +#ifdef BITMAPBUTTONS + PixmapMask pm = screen->getWindowStyle()->max_button; + + if (pm.mask != None) { + XSetClipMask(blackbox->getXDisplay(), pen.gc(), pm.mask); + XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), + (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2); + + XFillRectangle(blackbox->getXDisplay(), frame.maximize_button, pen.gc(), + (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2, + (frame.button_w + pm.w)/2, (frame.button_w + pm.h)/2); + + XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 ); + XSetClipMask( blackbox->getXDisplay(), pen.gc(), None ); + } else { +#endif // BITMAPBUTTONS + XDrawRectangle(blackbox->getXDisplay(), frame.maximize_button, pen.gc(), + 2, 2, (frame.button_w - 5), (frame.button_w - 5)); + XDrawLine(blackbox->getXDisplay(), frame.maximize_button, pen.gc(), + 2, 3, (frame.button_w - 3), 3); +#ifdef BITMAPBUTTONS + } +#endif // BITMAPBUTTONS } @@ -2657,8 +2702,8 @@ void BlackboxWindow::redrawCloseButton(bool pressed) const { if (! pressed) { if (flags.focused) { if (frame.fbutton) - XSetWindowBackgroundPixmap(blackbox->getXDisplay(), frame.close_button, - frame.fbutton); + XSetWindowBackgroundPixmap(blackbox->getXDisplay(), + frame.close_button, frame.fbutton); else XSetWindowBackground(blackbox->getXDisplay(), frame.close_button, frame.fbutton_pixel); @@ -2681,13 +2726,33 @@ void BlackboxWindow::redrawCloseButton(bool pressed) const { XClearWindow(blackbox->getXDisplay(), frame.close_button); BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : - screen->getWindowStyle()->b_pic_unfocus, 0, 2); - XDrawLine(blackbox->getXDisplay(), frame.close_button, pen.gc(), - 2, 2, (frame.button_w - 3), (frame.button_w - 3)); - XDrawLine(blackbox->getXDisplay(), frame.close_button, pen.gc(), - 2, (frame.button_w - 3), (frame.button_w - 3), 2); -} + screen->getWindowStyle()->b_pic_unfocus); + +#ifdef BITMAPBUTTONS + PixmapMask pm = screen->getWindowStyle()->close_button; + if (pm.mask != None) { + XSetClipMask(blackbox->getXDisplay(), pen.gc(), pm.mask); + XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), + (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2); + + XFillRectangle(blackbox->getXDisplay(), frame.close_button, pen.gc(), + (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2, + (frame.button_w + pm.w)/2, (frame.button_w + pm.h)/2); + + + XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 ); + XSetClipMask( blackbox->getXDisplay(), pen.gc(), None ); + } else { +#endif // BITMAPBUTTONS + XDrawLine(blackbox->getXDisplay(), frame.close_button, pen.gc(), + 2, 2, (frame.button_w - 3), (frame.button_w - 3)); + XDrawLine(blackbox->getXDisplay(), frame.close_button, pen.gc(), + 2, (frame.button_w - 3), (frame.button_w - 3), 2); +#ifdef BITMAPBUTTONS + } +#endif // BITMAPBUTTONS +} void BlackboxWindow::redrawStickyButton(bool pressed) const { if (! pressed) { @@ -2719,8 +2784,28 @@ void BlackboxWindow::redrawStickyButton(bool pressed) const { BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : screen->getWindowStyle()->b_pic_unfocus); - XFillRectangle(blackbox->getXDisplay(), frame.stick_button, pen.gc(), - frame.button_w/2 - 1, frame.button_w/2 -1, 2, 2 ); +#ifdef BITMAPBUTTONS + PixmapMask pm = screen->getWindowStyle()->stick_button; + + if (pm.mask != None) { + XSetClipMask(blackbox->getXDisplay(), pen.gc(), pm.mask); + XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), + (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2); + + XFillRectangle(blackbox->getXDisplay(), frame.stick_button, pen.gc(), + (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2, + (frame.button_w + pm.w)/2, (frame.button_w + pm.h)/2); + + + XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 ); + XSetClipMask( blackbox->getXDisplay(), pen.gc(), None ); + } else { +#endif // BITMAPBUTTONS + XFillRectangle(blackbox->getXDisplay(), frame.stick_button, pen.gc(), + frame.button_w/2 - 1, frame.button_w/2 -1, 2, 2 ); +#ifdef BITMAPBUTTONS + } +#endif } void BlackboxWindow::mapRequestEvent(const XMapRequestEvent *re) { @@ -2736,7 +2821,8 @@ void BlackboxWindow::mapRequestEvent(const XMapRequestEvent *re) { 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() && + if (! flags.stuck && + blackbox_attrib.workspace != screen->getCurrentWorkspaceID() && blackbox_attrib.workspace < screen->getWorkspaceCount()) if (current_state == NormalState) current_state = WithdrawnState; @@ -2971,10 +3057,10 @@ void BlackboxWindow::configureRequestEvent(const XConfigureRequestEvent *cr) { frame.margin.top + frame.margin.bottom); /* - if a position change ha been specified, then that position will be used - instead of determining a position based on the window's gravity. + if a position change has been specified, then that position will be + used instead of determining a position based on the window's gravity. */ - if (cr->value_mask & (CWX | CWY)) { + if (! (cr->value_mask & (CWX | CWY))) { Corner corner; switch (client.win_gravity) { case NorthEastGravity: @@ -3087,13 +3173,19 @@ void BlackboxWindow::buttonPressEvent(const XButtonEvent *be) { if (mx < left_edge) mx = left_edge; - if (mx > right_edge) + else if (mx > right_edge) mx = right_edge; if (my < top_edge) my = top_edge; - if (my > bottom_edge) + else if (my > bottom_edge) my = bottom_edge; + + if (my + windowmenu->getHeight() > screen->getHeight()) + my = screen->getHeight() - windowmenu->getHeight() - + (screen->getBorderWidth() * 2); + + cout << my << endl; windowmenu->move(mx, my); windowmenu->show(); XRaiseWindow(blackbox->getXDisplay(), windowmenu->getWindowID()); @@ -3278,7 +3370,7 @@ void BlackboxWindow::doWorkspaceWarping(int x_root, int y_root, int &dx) { bool focus = flags.focused; // had focus while moving? int dest_x = x_root; - if (x_root <= 0) { + if (x_root < 0) { dest_x += screen->getRect().width() - 1; dx += screen->getRect().width() - 1; } else { @@ -3808,11 +3900,14 @@ void BlackboxWindow::motionNotifyEvent(const XMotionEvent *me) { 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 & 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))) { + frame.handle == me->window || frame.window == me->window || + frame.right_grip == me->window || + frame.left_grip == me->window))) { unsigned int zones = screen->getResizeZones(); Corner corner; @@ -3859,10 +3954,15 @@ void BlackboxWindow::enterNotifyEvent(const XCrossingEvent* ce) { bool success = setInputFocus(); if (success) // if focus succeeded install the colormap installColormap(True); // XXX: shouldnt we honour no install? - } - if (screen->doAutoRaise()) - timer->start(); + /* + We only auto-raise when the window wasn't focused because otherwise + we run into problems with gtk+ drop-down lists. The window ends up + raising over the list. + */ + if (screen->doAutoRaise()) + timer->start(); + } } } @@ -4119,11 +4219,17 @@ void BlackboxWindow::constrain(Corner anchor, base_height = (client.base_height) ? client.base_height : client.min_height; - // constrain - 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; + // constrain, but only if the min/max are being used. if they aren't, then + // this resize is going to be from a ConfigureRequest because the window + // isn't allowed to be resized by the user. And in that case, we don't want + // to limit what the app can do + if (client.max_width > client.min_width || + client.max_height > client.min_height) { + 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; + } assert(dw >= base_width && dh >= base_height);