]> Dogcows Code - chaz/openbox/blobdiff - src/Screen.cc
making warping work.. hopefully.
[chaz/openbox] / src / Screen.cc
index 8512b3dc3cc05dce8eb5d3e5534bff377679681e..31811fe63d740996b8745d9846e53006d57509cb 100644 (file)
@@ -490,6 +490,13 @@ void BScreen::saveSnapThreshold(int t) {
 }
 
 
+void BScreen::saveSnapOffset(int t) {
+  resource.snap_offset = t;
+  config->setValue(screenstr + "edgeSnapOffset",
+                   resource.snap_offset);
+}
+
+
 void BScreen::saveRowPlacementDirection(int d) {
   resource.row_direction = d;
   config->setValue(screenstr + "rowPlacementDirection",
@@ -599,6 +606,7 @@ void BScreen::save_rc(void) {
   saveWorkspaces(resource.workspaces);
   savePlacementPolicy(resource.placement_policy);
   saveSnapThreshold(resource.snap_threshold);
+  saveSnapOffset(resource.snap_offset);
   saveResistanceSize(resource.resistance_size);
   saveRowPlacementDirection(resource.row_direction);
   saveColPlacementDirection(resource.col_direction);
@@ -673,13 +681,19 @@ void BScreen::load_rc(void) {
     b = true;
   image_control->setDither(b);
 
+  if (! config->getValue(screenstr + "edgeSnapOffset",
+                        resource.snap_offset))
+    resource.snap_offset = 0;
+  if (resource.snap_offset > 50)  // sanity check, setting this huge would
+    resource.snap_offset = 50;    // seriously suck.
+  
   if (! config->getValue(screenstr + "edgeSnapThreshold",
                         resource.snap_threshold))
     resource.snap_threshold = 4;
   
   if (! config->getValue(screenstr + "resistanceSize",
                         resource.resistance_size))
-    resource.resistance_size = 12;
+    resource.resistance_size = 18;
   
   if (config->getValue(screenstr + "rowPlacementDirection", s) &&
       s == "RightToLeft")
@@ -1115,7 +1129,8 @@ void BScreen::removeIcon(BlackboxWindow *w) {
 BlackboxWindow *BScreen::getIcon(unsigned int index) {
   if (index < iconList.size()) {
     BlackboxWindowList::iterator it = iconList.begin();
-    for (; index > 0; --index, ++it) ; /* increment to index */
+    while (index-- > 0) // increment to index
+      ++it;
     return *it;
   }
 
@@ -1184,7 +1199,7 @@ void BScreen::changeWorkspaceID(unsigned int id) {
 
   // when we switch workspaces, unfocus whatever was focused
   blackbox->setFocusedWindow((BlackboxWindow *) 0);
-    
+
   current_workspace->hideAll();
   workspacemenu->setItemSelected(current_workspace->getID() + 2, False);
 
@@ -1316,6 +1331,9 @@ void BScreen::manageWindow(Window w) {
     // don't list non-normal windows as managed windows
     windowList.push_back(win);
     updateClientList();
+  
+    if (win->isTopmost())
+      specialWindowList.push_back(win->getFrameWindow());
   } else if (win->isDesktop()) {
     desktopWindowList.push_back(win->getFrameWindow());
   }
@@ -1348,6 +1366,17 @@ void BScreen::unmanageWindow(BlackboxWindow *w, bool remap) {
     // we don't list non-normal windows as managed windows
     windowList.remove(w);
     updateClientList();
+
+    if (w->isTopmost()) {
+      WindowList::iterator it = specialWindowList.begin();
+      const WindowList::iterator end = specialWindowList.end();
+      for (; it != end; ++it)
+        if (*it == w->getFrameWindow()) {
+          specialWindowList.erase(it);
+          break;
+        }
+      assert(it != end);  // the window wasnt a special window?
+    }
   } else if (w->isDesktop()) {
     WindowList::iterator it = desktopWindowList.begin();
     const WindowList::iterator end = desktopWindowList.end();
@@ -1498,7 +1527,8 @@ void BScreen::raiseWindows(Window *workspace_stack, unsigned int num) {
 #endif // XINERAMA
 
   Window *session_stack = new
-    Window[(num + workspacesList.size() + rootmenuList.size() + bbwins)];
+    Window[(num + workspacesList.size() + rootmenuList.size() +
+            specialWindowList.size() + bbwins)];
   unsigned int i = 0, k = num;
 
   XRaiseWindow(blackbox->getXDisplay(), iconmenu->getWindowID());
@@ -1539,6 +1569,10 @@ void BScreen::raiseWindows(Window *workspace_stack, unsigned int num) {
   if (slit->isOnTop())
     *(session_stack + i++) = slit->getWindowID();
 
+  WindowList::iterator sit, send = specialWindowList.end();
+  for (sit = specialWindowList.begin(); sit != send; ++sit)
+    *(session_stack + i++) = *sit;
+
   while (k--)
     *(session_stack + i++) = *(workspace_stack + k);
 
@@ -1776,12 +1810,13 @@ void BScreen::InitMenu(void) {
 
 
 static
-void string_within(char begin, char end, const char *input, size_t length,
-                   char *output) {
+size_t string_within(char begin, char end,
+                     const char *input, size_t start_at, size_t length,
+                     char *output) {
   bool parse = False;
   size_t index = 0;
-
-  for (size_t i = 0; i < length; ++i) {
+  size_t i = start_at;
+  for (; i < length; ++i) {
     if (input[i] == begin) {
       parse = True;
     } else if (input[i] == end) {
@@ -1796,6 +1831,8 @@ void string_within(char begin, char end, const char *input, size_t length,
     output[index] = '\0';
   else
     output[0] = '\0';
+
+  return i;
 }
 
 
@@ -1818,7 +1855,7 @@ bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) {
     unsigned int key = 0;
 
     // get the keyword enclosed in []'s
-    string_within('[', ']', line, line_length, keyword);
+    size_t pos = string_within('[', ']', line, 0, line_length, keyword);
 
     if (keyword[0] == '\0') {  // no keyword, no menu entry
       continue;
@@ -1831,10 +1868,10 @@ bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) {
     }
 
     // get the label enclosed in ()'s
-    string_within('(', ')', line, line_length, label);
+    pos = string_within('(', ')', line, pos, line_length, label);
 
     // get the command enclosed in {}'s
-    string_within('{', '}', line, line_length, command);
+    pos = string_within('{', '}', line, pos, line_length, command);
 
     switch (key) {
     case 311: // end
This page took 0.027285 seconds and 4 git commands to generate.