From 551a17d2563679eb6ef7c650f1384ee7e48dbc29 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 20 Aug 2002 15:38:51 +0000 Subject: [PATCH] Fix send to menu, having deleted workspaces in it. Fix workspace warping, move the mouse and window the same amount. Fix workspace switching. Put old code back that worked better. --- CHANGELOG | 11 +++++++ src/Screen.cc | 24 ++++++++++++-- src/Window.cc | 36 ++++++++++----------- src/Window.hh | 2 +- src/Windowmenu.cc | 5 ++- src/Workspace.cc | 81 ++++++++++++++++++----------------------------- src/Workspace.hh | 4 +-- util/epist/DESIGN | 5 +-- 8 files changed, 88 insertions(+), 80 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5cbd45e2..426b53ed 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,16 @@ Changelog for Openbox: +2.0.1: + * Fix SendTo menus. They would keep workspaces that + had been deleted. (Ben Jansens) + + * Fixes for workspace switching. Putting old code (Ben Jansens) + back. + + * Fixes for workspace warping. Window and mouse would (Ben Jansens) + move slightly out of sync, as one motion event would + get dropped. + 2.0.0: * Add an rc option (modiferMask) to allow changing (Ben Jansens) which modifier combo Openbox uses for mouse diff --git a/src/Screen.cc b/src/Screen.cc index d49e418a..31811fe6 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -1186,20 +1186,38 @@ unsigned int BScreen::removeLastWorkspace(void) { void BScreen::changeWorkspaceID(unsigned int id) { if (! current_workspace || id == current_workspace->getID()) return; - current_workspace->hide(); + BlackboxWindow *focused = blackbox->getFocusedWindow(); + if (focused && focused->getScreen() == this) { + assert(focused->isStuck() || + focused->getWorkspaceNumber() == current_workspace->getID()); + + current_workspace->setLastFocusedWindow(focused); + } else { + // if no window had focus, no need to store a last focus + current_workspace->setLastFocusedWindow((BlackboxWindow *) 0); + } + + // when we switch workspaces, unfocus whatever was focused + blackbox->setFocusedWindow((BlackboxWindow *) 0); + current_workspace->hideAll(); workspacemenu->setItemSelected(current_workspace->getID() + 2, False); current_workspace = getWorkspace(id); - current_workspace->show(); - xatom->setValue(getRootWindow(), XAtom::net_current_desktop, XAtom::cardinal, id); workspacemenu->setItemSelected(current_workspace->getID() + 2, True); toolbar->redrawWorkspaceLabel(True); + current_workspace->showAll(); + + if (resource.focus_last && current_workspace->getLastFocusedWindow()) { + XSync(blackbox->getXDisplay(), False); + current_workspace->getLastFocusedWindow()->setInputFocus(); + } + updateNetizenCurrentWorkspace(); } diff --git a/src/Window.cc b/src/Window.cc index 4824a34a..b73af2b5 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -3058,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()) { @@ -3084,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(); @@ -3106,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? @@ -3116,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 @@ -3123,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; } diff --git a/src/Window.hh b/src/Window.hh index 49182bb2..695d3e1c 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -296,7 +296,7 @@ private: void setState(unsigned long new_state); void upsize(void); void doMove(int x_root, int y_root); - bool doWorkspaceWarping(int x_root, int y_root, int dx, int dy); + void doWorkspaceWarping(int x_root, int y_root, int &dx, int dy); void doWindowSnapping(int &dx, int &dy); void endMove(void); void doResize(int x_root, int y_root); diff --git a/src/Windowmenu.cc b/src/Windowmenu.cc index 374925be..c49a6f91 100644 --- a/src/Windowmenu.cc +++ b/src/Windowmenu.cc @@ -182,9 +182,8 @@ void Windowmenu::SendtoWorkspacemenu::itemSelected(int button, void Windowmenu::SendtoWorkspacemenu::update(void) { unsigned int i, r = getCount(), workspace_count = getScreen()->getWorkspaceCount(); - if (r > workspace_count) { - for (i = r; i < workspace_count; ++i) - remove(0); + while (r > workspace_count) { + remove(0); r = getCount(); } diff --git a/src/Workspace.cc b/src/Workspace.cc index 11d5187d..97a7ee73 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -225,6 +225,36 @@ void Workspace::removeAll(void) { windowList.front()->iconify(); } +void Workspace::showAll(void) { + BlackboxWindowList::iterator it = stackingList.begin(); + const BlackboxWindowList::iterator end = stackingList.end(); + for (; it != end; ++it) { + BlackboxWindow *bw = *it; + // not normal windows cant focus from mouse enters anyways, so we dont + // need to unmap/remap them on workspace changes + if (! bw->isStuck() || bw->isNormal()) + bw->show(); + } +} + + +void Workspace::hideAll(void) { + // withdraw in reverse order to minimize the number of Expose events + + BlackboxWindowList lst(stackingList.rbegin(), stackingList.rend()); + + BlackboxWindowList::iterator it = lst.begin(); + const BlackboxWindowList::iterator end = lst.end(); + for (; it != end; ++it) { + BlackboxWindow *bw = *it; + // not normal windows cant focus from mouse enters anyways, so we dont + // need to unmap/remap them on workspace changes + if (! bw->isStuck() || bw->isNormal()) + bw->withdraw(); + } +} + + /* * returns the number of transients for win, plus the number of transients @@ -428,57 +458,6 @@ void Workspace::appendStackOrder(BlackboxWindowList &stack_order) const { if ((*it)->isNormal()) stack_order.push_back(*it); } - - -void Workspace::hide(void) { - BlackboxWindow *focused = screen->getBlackbox()->getFocusedWindow(); - if (focused && focused->getScreen() == screen) { - assert(focused->isStuck() || focused->getWorkspaceNumber() == id); - - lastfocus = focused; - } else { - // if no window had focus, no need to store a last focus - lastfocus = (BlackboxWindow *) 0; - } - - // when we switch workspaces, unfocus whatever was focused - screen->getBlackbox()->setFocusedWindow((BlackboxWindow *) 0); - - // withdraw windows in reverse order to minimize the number of Expose events - - BlackboxWindowList::reverse_iterator it = stackingList.rbegin(); - const BlackboxWindowList::reverse_iterator end = stackingList.rend(); - for (; it != end; ++it) { - BlackboxWindow *bw = *it; - // not normal windows cant focus from mouse enters anyways, so we dont - // need to unmap/remap them on workspace changes - if (! bw->isStuck() || bw->isNormal()) - bw->withdraw(); - } -} - - -void Workspace::show(void) { - BlackboxWindowList::iterator it = stackingList.begin(); - const BlackboxWindowList::iterator end = stackingList.end(); - for (; it != end; ++it) { - BlackboxWindow *bw = *it; - // not normal windows cant focus from mouse enters anyways, so we dont - // need to unmap/remap them on workspace changes - if (! bw->isStuck() || bw->isNormal()) - bw->show(); - } - - XSync(screen->getBlackbox()->getXDisplay(), False); - - if (screen->doFocusLast()) { - if (! screen->isSloppyFocus() && ! lastfocus && ! stackingList.empty()) - lastfocus = stackingList.front(); - - if (lastfocus) - lastfocus->setInputFocus(); - } -} bool Workspace::isCurrent(void) const { diff --git a/src/Workspace.hh b/src/Workspace.hh index e0295e29..72203f2d 100644 --- a/src/Workspace.hh +++ b/src/Workspace.hh @@ -104,8 +104,8 @@ public: unsigned int getCount(void) const; void appendStackOrder(BlackboxWindowList &stack_order) const; - void show(void); - void hide(void); + void showAll(void); + void hideAll(void); void removeAll(void); void raiseWindow(BlackboxWindow *w); void lowerWindow(BlackboxWindow *w); diff --git a/util/epist/DESIGN b/util/epist/DESIGN index 545c9edf..a02a7bbd 100644 --- a/util/epist/DESIGN +++ b/util/epist/DESIGN @@ -2,8 +2,9 @@ Epist design notes, by woodblock -------------------------------- - Chained keybindings like emacs, and I suppose vi if you're wierd like that. - - most actions can take extra parameters. probably only numbers, or strings, maybe both. - - no interactive string inputs +- most actions can take extra parameters. probably only numbers, + or strings, maybe both. +- no interactive string inputs - A config file that doesn't suck -- 2.39.2