}
-void BScreen::saveWindowToWindowSnap(bool s) {
- resource.window_to_window_snap = s;
- config->setValue(screenstr + "windowToWindowSnap",
- resource.window_to_window_snap);
+void BScreen::saveWindowToEdgeSnap(int s) {
+ resource.snap_to_edges = s;
+
+ const char *snap;
+ switch (resource.snap_to_edges) {
+ case WindowNoSnap: snap = "NoSnap"; break;
+ case WindowResistance: snap = "Resistance"; break;
+ case WindowSnap: default: snap = "Snap"; break;
+ }
+ config->setValue(screenstr + "windowToEdgeSnap", snap);
+}
+
+
+void BScreen::saveWindowToWindowSnap(int s) {
+ resource.snap_to_windows = s;
+
+ const char *snap;
+ switch (resource.snap_to_windows) {
+ case WindowNoSnap: snap = "NoSnap"; break;
+ case WindowResistance: snap = "Resistance"; break;
+ case WindowSnap: default: snap = "Snap"; break;
+ }
+ config->setValue(screenstr + "windowToWindowSnap", snap);
}
}
-void BScreen::saveEdgeSnapThreshold(int t) {
- resource.edge_snap_threshold = t;
+void BScreen::saveResistanceSize(int s) {
+ resource.resistance_size = s;
+ config->setValue(screenstr + "resistanceSize",
+ resource.resistance_size);
+}
+
+
+void BScreen::saveSnapThreshold(int t) {
+ resource.snap_threshold = t;
config->setValue(screenstr + "edgeSnapThreshold",
- resource.edge_snap_threshold);
+ resource.snap_threshold);
+}
+
+
+void BScreen::saveSnapOffset(int t) {
+ resource.snap_offset = t;
+ config->setValue(screenstr + "edgeSnapOffset",
+ resource.snap_offset);
}
saveFocusNew(resource.focus_new);
saveFocusLast(resource.focus_last);
saveHideToolbar(resource.hide_toolbar);
- saveWindowToWindowSnap(resource.window_to_window_snap);
+ saveWindowToWindowSnap(resource.snap_to_windows);
+ saveWindowToEdgeSnap(resource.snap_to_edges);
saveWindowCornerSnap(resource.window_corner_snap);
saveWorkspaces(resource.workspaces);
savePlacementPolicy(resource.placement_policy);
- saveEdgeSnapThreshold(resource.edge_snap_threshold);
+ saveSnapThreshold(resource.snap_threshold);
+ saveSnapOffset(resource.snap_offset);
+ saveResistanceSize(resource.resistance_size);
saveRowPlacementDirection(resource.row_direction);
saveColPlacementDirection(resource.col_direction);
#ifdef HAVE_STRFTIME
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;
+ resource.snap_to_windows = WindowResistance;
+ if (config->getValue(screenstr + "windowToWindowSnap", s)) {
+ if (s == "NoSnap")
+ resource.snap_to_windows = WindowNoSnap;
+ else if (s == "Snap")
+ resource.snap_to_windows = WindowSnap;
+ }
+
+ resource.snap_to_edges = WindowResistance;
+ if (config->getValue(screenstr + "windowToEdgeSnap", s)) {
+ if (s == "NoSnap")
+ resource.snap_to_edges = WindowNoSnap;
+ else if (s == "Snap")
+ resource.snap_to_edges = WindowSnap;
+ }
if (! config->getValue(screenstr + "windowCornerSnap",
resource.window_corner_snap))
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.edge_snap_threshold))
- resource.edge_snap_threshold = 4;
+ resource.snap_threshold))
+ resource.snap_threshold = 4;
+
+ if (! config->getValue(screenstr + "resistanceSize",
+ resource.resistance_size))
+ resource.resistance_size = 18;
if (config->getValue(screenstr + "rowPlacementDirection", s) &&
s == "RightToLeft")
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;
}
void BScreen::changeWorkspaceID(unsigned int id) {
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->hide();
- 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();
}
// 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());
}
// 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();
void BScreen::raiseWindows(Window *workspace_stack, unsigned int num) {
// the 13 represents the number of blackbox windows such as menus
- int bbwins = 13;
+ int bbwins = 15;
#ifdef XINERAMA
++bbwins;
#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());
*(session_stack + i++) = configmenu->getFocusmenu()->getWindowID();
*(session_stack + i++) = configmenu->getPlacementmenu()->getWindowID();
+ *(session_stack + i++) = configmenu->getWindowSnapmenu()->getWindowID();
+ *(session_stack + i++) = configmenu->getEdgeSnapmenu()->getWindowID();
#ifdef XINERAMA
*(session_stack + i++) = configmenu->getXineramamenu()->getWindowID();
#endif // XINERAMA
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);
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) {
output[index] = '\0';
else
output[0] = '\0';
+
+ return i;
}
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;
}
// 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