summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2002-07-29 15:06:46 +0000
committerDana Jansens <danakj@orodu.net>2002-07-29 15:06:46 +0000
commit06b160db5106a28b76ca0eee139393696d119135 (patch)
treeab9d61611e9da162b9ad99c2bf7a636a8978f647 /src
parentd86284c07b29817b93db1875fa1430d221b94a63 (diff)
use a list of rects instead of windows for window-to-window snapping. Also, snap directly to the slit and toolbar, instead of snapping to the strut.
Diffstat (limited to 'src')
-rw-r--r--src/Window.cc50
-rw-r--r--src/Workspace.hh3
2 files changed, 35 insertions, 18 deletions
diff --git a/src/Window.cc b/src/Window.cc
index 4b8efc8c..1c49346c 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;
@@ -3089,15 +3090,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()),
@@ -3165,27 +3191,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) {
diff --git a/src/Workspace.hh b/src/Workspace.hh
index 819b6391..72203f2d 100644
--- a/src/Workspace.hh
+++ b/src/Workspace.hh
@@ -85,6 +85,9 @@ public:
inline void setLastFocusedWindow(BlackboxWindow *w) { lastfocus = w; }
+ inline const BlackboxWindowList& getStackingList() const
+ { return stackingList; }
+
BlackboxWindow* getWindow(unsigned int index);
BlackboxWindow* getNextWindowInList(BlackboxWindow *w);
BlackboxWindow* getPrevWindowInList(BlackboxWindow *w);