- if (! current_workspace) return;
-
- if (id != current_workspace->getID()) {
- BlackboxWindow *focused = blackbox->getFocusedWindow();
- if (focused && focused->getScreen() == this && ! focused->isStuck()) {
- if (focused->getWorkspaceNumber() != current_workspace->getID()) {
- fprintf(stderr, "%s is on the wrong workspace, aborting\n",
- focused->getTitle());
- abort();
- }
- 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);
+ if (! current_workspace || id == current_workspace->getID()) return;
+
+ 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);