X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FWindow.cc;h=8b78d85e9242b61553c52f044289acc2b598dbe2;hb=988461343a14270bf6594c12041eda90447514d8;hp=769e036f8dfc8badcfe4516b2de0d6bb0e7ab74c;hpb=03f9d6170bd97dbbb968746f2841d9fa5cb3e977;p=chaz%2Fopenbox diff --git a/src/Window.cc b/src/Window.cc index 769e036f..8b78d85e 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -57,6 +57,7 @@ extern "C" { #include "Window.hh" #include "Windowmenu.hh" #include "Workspace.hh" +#include "Slit.hh" using std::string; using std::abs; @@ -260,6 +261,10 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) { if (blackbox->hasShapeExtensions() && flags.shaped) configureShape(); #endif // SHAPE + + // get the window's title before adding it to the workspace + getWMName(); + getWMIconName(); if (blackbox_attrib.workspace >= screen->getWorkspaceCount()) screen->getCurrentWorkspace()->addWindow(this, place_window); @@ -311,9 +316,8 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) { // get sticky state from our parent window if we've got one if (isTransient() && client.transient_for != (BlackboxWindow *) ~0ul && client.transient_for->isStuck() != flags.stuck) - stick(); + flags.stuck = True; - // the following flags are set by blackbox native apps only if (flags.shaded) { flags.shaded = False; initial_state = current_state; @@ -448,8 +452,6 @@ Window BlackboxWindow::createChildWindow(Window parent, Cursor cursor) { void BlackboxWindow::associateClientWindow(void) { XSetWindowBorderWidth(blackbox->getXDisplay(), client.window, 0); - getWMName(); - getWMIconName(); XChangeSaveSet(blackbox->getXDisplay(), client.window, SetModeInsert); @@ -1538,9 +1540,8 @@ void BlackboxWindow::configureShape(void) { bool BlackboxWindow::setInputFocus(void) { if (flags.focused) return True; - assert(! flags.iconic && - (flags.stuck || // window must be on the current workspace or sticky - blackbox_attrib.workspace == screen->getCurrentWorkspaceID())); + assert(flags.stuck || // window must be on the current workspace or sticky + blackbox_attrib.workspace == screen->getCurrentWorkspaceID()); /* We only do this check for normal windows and dialogs because other windows @@ -1629,6 +1630,11 @@ void BlackboxWindow::iconify(void) { setState(IconicState); screen->getWorkspace(blackbox_attrib.workspace)->removeWindow(this); + if (flags.stuck) { + for (unsigned int i = 0; i < screen->getNumberOfWorkspaces(); ++i) + if (i != blackbox_attrib.workspace) + screen->getWorkspace(i)->removeWindow(this, True); + } if (isTransient()) { if (client.transient_for != (BlackboxWindow *) ~0ul && @@ -1933,12 +1939,12 @@ void BlackboxWindow::stick(void) { blackbox_attrib.flags ^= AttribOmnipresent; blackbox_attrib.attrib ^= AttribOmnipresent; + flags.stuck = False; + for (unsigned int i = 0; i < screen->getNumberOfWorkspaces(); ++i) if (i != blackbox_attrib.workspace) screen->getWorkspace(i)->removeWindow(this, True); - flags.stuck = False; - if (! flags.iconic) screen->reassociateWindow(this, BSENTINEL, True); // temporary fix since sticky windows suck. set the hint to what we @@ -2221,8 +2227,8 @@ void BlackboxWindow::restoreAttributes(void) { current_state = NormalState; } - if (net->flags & AttribOmnipresent && net->attrib & AttribOmnipresent) { - flags.stuck = False; + if (net->flags & AttribOmnipresent && net->attrib & AttribOmnipresent && + ! flags.stuck) { stick(); // if the window was on another workspace, it was going to be hidden. this @@ -3087,15 +3093,40 @@ void BlackboxWindow::doMove(int x_root, int y_root) { Workspace *w = screen->getWorkspace(getWorkspaceNumber()); assert(w); + RectList winsnaplist; + // try snap to another window - for (unsigned int i = 0, c = w->getCount(); i < c; ++i) { - BlackboxWindow *snapwin = w->getWindow(i); - if (snapwin == this) - continue; // don't snap to self + // add windows on the workspace to the snap list + const BlackboxWindowList& stack_list = w->getStackingList(); + BlackboxWindowList::const_iterator st_it, st_end = stack_list.end(); + for (st_it = stack_list.begin(); st_it != st_end; ++st_it) + winsnaplist.push_back( (*st_it)->frameRect() ); + + // add the toolbar and the slit to the snap list. + // (only if they are not hidden) + Toolbar *tbar = screen->getToolbar(); + Slit *slit = screen->getSlit(); + Rect tbar_rect, slit_rect; + unsigned int bwidth = screen->getBorderWidth() * 2; + + if (! (screen->doHideToolbar() || tbar->isHidden())) { + tbar_rect.setRect(tbar->getX(), tbar->getY(), tbar->getWidth() + bwidth, + tbar->getHeight() + bwidth); + winsnaplist.push_back(tbar_rect); + } + + if (! slit->isHidden()) { + slit_rect.setRect(slit->getX(), slit->getY(), slit->getWidth() + bwidth, + slit->getHeight() + bwidth); + winsnaplist.push_back(slit_rect); + } + + RectList::const_iterator it, end = winsnaplist.end(); + for (it = winsnaplist.begin(); it != end; ++it) { bool snapped = False; - const Rect &winrect = snapwin->frameRect(); + const Rect &winrect = *it; int dleft = abs(wright - winrect.left()), dright = abs(wleft - winrect.right()), dtop = abs(wbottom - winrect.top()), @@ -3163,27 +3194,15 @@ void BlackboxWindow::doMove(int x_root, int y_root) { RectList snaplist; // the list of rects we will try to snap to - // snap to the strut (and screen boundaries for xinerama) + // snap to the screen edges (and screen boundaries for xinerama) #ifdef XINERAMA if (screen->isXineramaActive() && blackbox->doXineramaSnapping()) { - if (! screen->doFullMax()) - snaplist.insert(snaplist.begin(), - screen->allAvailableAreas().begin(), - screen->allAvailableAreas().end()); - - // always snap to the screen edges snaplist.insert(snaplist.begin(), screen->getXineramaAreas().begin(), screen->getXineramaAreas().end()); } else #endif // XINERAMA - { - if (! screen->doFullMax()) - snaplist.push_back(screen->availableArea()); - - // always snap to the screen edges snaplist.push_back(screen->getRect()); - } RectList::const_iterator it, end = snaplist.end(); for (it = snaplist.begin(); it != end; ++it) {