Fix workspace warping, move the mouse and window the same amount.
Fix workspace switching. Put old code back that worked better.
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
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();
}
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()) {
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();
else dest = 0;
}
if (! warp)
- return false;
+ return;
endMove();
bool focus = flags.focused; // had focus while moving?
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
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;
}
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);
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();
}
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
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 {
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);
--------------------------------
- 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