]> Dogcows Code - chaz/openbox/blobdiff - src/Screen.cc
fix off-by-ones in window-to-window snapping. move the property from the blackbox...
[chaz/openbox] / src / Screen.cc
index 8bdf9480cd4b0d2e051ebadd0fc9519964b39429..ba394bc95e8eb7087f2f0a53d4f633179f57a498 100644 (file)
@@ -66,8 +66,11 @@ extern "C" {
 #endif // HAVE_STDARG_H
 }
 
+#include <assert.h>
+
 #include <algorithm>
 #include <functional>
+#include <string>
 using std::string;
 
 #include "i18n.hh"
@@ -421,6 +424,20 @@ void BScreen::saveHideToolbar(bool h) {
 }
 
 
+void BScreen::saveWindowToWindowSnap(bool s) {
+  resource.window_to_window_snap = s;
+  config->setValue(screenstr + "windowToWindowSnap",
+                   resource.window_to_window_snap);
+}
+
+
+void BScreen::saveWindowCornerSnap(bool s) {
+  resource.window_corner_snap = s;
+  config->setValue(screenstr + "windowCornerSnap",
+                   resource.window_corner_snap);
+}
+
+
 void BScreen::saveWorkspaces(unsigned int w) {
   resource.workspaces = w;
   config->setValue(screenstr + "workspaces", resource.workspaces);
@@ -507,6 +524,8 @@ void BScreen::save_rc(void) {
   saveFocusNew(resource.focus_new);
   saveFocusLast(resource.focus_last);
   saveHideToolbar(resource.hide_toolbar);
+  saveWindowToWindowSnap(resource.window_to_window_snap);
+  saveWindowCornerSnap(resource.window_corner_snap);
   saveWorkspaces(resource.workspaces);
   savePlacementPolicy(resource.placement_policy);
   saveEdgeSnapThreshold(resource.edge_snap_threshold);
@@ -546,6 +565,14 @@ void BScreen::load_rc(void) {
   if (! config->getValue(screenstr + "hideToolbar", resource.hide_toolbar))
     resource.hide_toolbar = false;
 
+  if (! config->getValue(screenstr + "windowToWindowSnap",
+                         resource.window_to_window_snap))
+    resource.window_to_window_snap = true;
+
+  if (! config->getValue(screenstr + "windowCornerSnap",
+                         resource.window_corner_snap))
+    resource.window_corner_snap = true;
+
   if (! config->getValue(screenstr + "imageDither", b))
     b = true;
   image_control->setDither(b);
@@ -1037,10 +1064,14 @@ void BScreen::changeWorkspaceID(unsigned int id) {
 
     workspacemenu->setItemSelected(current_workspace->getID() + 2, False);
 
-    if (blackbox->getFocusedWindow() &&
-        blackbox->getFocusedWindow()->getScreen() == this &&
-        (! blackbox->getFocusedWindow()->isStuck())) {
-      current_workspace->setLastFocusedWindow(blackbox->getFocusedWindow());
+    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);
       blackbox->setFocusedWindow((BlackboxWindow *) 0);
     }
 
@@ -1076,7 +1107,8 @@ void BScreen::manageWindow(Window w) {
 
   XMapRequestEvent mre;
   mre.window = w;
-  win->restoreAttributes();
+  if (blackbox->isStartup())
+    win->restoreAttributes();
   win->mapRequestEvent(&mre);
 }
 
This page took 0.023082 seconds and 4 git commands to generate.