add rc options for window snapping/resistance
This commit is contained in:
parent
b1a2c014eb
commit
3356db4885
3 changed files with 82 additions and 29 deletions
|
@ -417,10 +417,29 @@ void BScreen::saveHideToolbar(bool h) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BScreen::saveWindowToWindowSnap(bool s) {
|
void BScreen::saveWindowToEdgeSnap(int s) {
|
||||||
resource.window_to_window_snap = s;
|
resource.snap_to_edges = s;
|
||||||
config->setValue(screenstr + "windowToWindowSnap",
|
|
||||||
resource.window_to_window_snap);
|
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_edges) {
|
||||||
|
case WindowNoSnap: snap = "NoSnap"; break;
|
||||||
|
case WindowResistance: snap = "Resistance"; break;
|
||||||
|
case WindowSnap: default: snap = "Snap"; break;
|
||||||
|
}
|
||||||
|
config->setValue(screenstr + "windowToWindowSnap", snap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -457,10 +476,17 @@ void BScreen::savePlacementPolicy(int p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BScreen::saveEdgeSnapThreshold(int t) {
|
void BScreen::saveResistanceSize(int s) {
|
||||||
resource.edge_snap_threshold = t;
|
resource.resistance_size = s;
|
||||||
|
config->setValue(screenstr + "resistanceSize",
|
||||||
|
resource.resistance_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BScreen::saveSnapThreshold(int t) {
|
||||||
|
resource.snap_threshold = t;
|
||||||
config->setValue(screenstr + "edgeSnapThreshold",
|
config->setValue(screenstr + "edgeSnapThreshold",
|
||||||
resource.edge_snap_threshold);
|
resource.snap_threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -567,11 +593,13 @@ void BScreen::save_rc(void) {
|
||||||
saveFocusNew(resource.focus_new);
|
saveFocusNew(resource.focus_new);
|
||||||
saveFocusLast(resource.focus_last);
|
saveFocusLast(resource.focus_last);
|
||||||
saveHideToolbar(resource.hide_toolbar);
|
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);
|
saveWindowCornerSnap(resource.window_corner_snap);
|
||||||
saveWorkspaces(resource.workspaces);
|
saveWorkspaces(resource.workspaces);
|
||||||
savePlacementPolicy(resource.placement_policy);
|
savePlacementPolicy(resource.placement_policy);
|
||||||
saveEdgeSnapThreshold(resource.edge_snap_threshold);
|
saveSnapThreshold(resource.snap_threshold);
|
||||||
|
saveResistanceSize(resource.resistance_size);
|
||||||
saveRowPlacementDirection(resource.row_direction);
|
saveRowPlacementDirection(resource.row_direction);
|
||||||
saveColPlacementDirection(resource.col_direction);
|
saveColPlacementDirection(resource.col_direction);
|
||||||
#ifdef HAVE_STRFTIME
|
#ifdef HAVE_STRFTIME
|
||||||
|
@ -621,9 +649,21 @@ void BScreen::load_rc(void) {
|
||||||
if (! config->getValue(screenstr + "hideToolbar", resource.hide_toolbar))
|
if (! config->getValue(screenstr + "hideToolbar", resource.hide_toolbar))
|
||||||
resource.hide_toolbar = false;
|
resource.hide_toolbar = false;
|
||||||
|
|
||||||
if (! config->getValue(screenstr + "windowToWindowSnap",
|
resource.snap_to_windows = WindowResistance;
|
||||||
resource.window_to_window_snap))
|
if (config->getValue(screenstr + "windowToWindowSnap", s)) {
|
||||||
resource.window_to_window_snap = true;
|
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",
|
if (! config->getValue(screenstr + "windowCornerSnap",
|
||||||
resource.window_corner_snap))
|
resource.window_corner_snap))
|
||||||
|
@ -634,8 +674,12 @@ void BScreen::load_rc(void) {
|
||||||
image_control->setDither(b);
|
image_control->setDither(b);
|
||||||
|
|
||||||
if (! config->getValue(screenstr + "edgeSnapThreshold",
|
if (! config->getValue(screenstr + "edgeSnapThreshold",
|
||||||
resource.edge_snap_threshold))
|
resource.snap_threshold))
|
||||||
resource.edge_snap_threshold = 4;
|
resource.snap_threshold = 4;
|
||||||
|
|
||||||
|
if (! config->getValue(screenstr + "resistanceSize",
|
||||||
|
resource.resistance_size))
|
||||||
|
resource.resistance_size = 12;
|
||||||
|
|
||||||
if (config->getValue(screenstr + "rowPlacementDirection", s) &&
|
if (config->getValue(screenstr + "rowPlacementDirection", s) &&
|
||||||
s == "RightToLeft")
|
s == "RightToLeft")
|
||||||
|
|
|
@ -147,14 +147,17 @@ private:
|
||||||
|
|
||||||
bool sloppy_focus, auto_raise, auto_edge_balance, ordered_dither,
|
bool sloppy_focus, auto_raise, auto_edge_balance, ordered_dither,
|
||||||
opaque_move, full_max, focus_new, focus_last, click_raise,
|
opaque_move, full_max, focus_new, focus_last, click_raise,
|
||||||
allow_scroll_lock, hide_toolbar, window_to_window_snap,
|
allow_scroll_lock, hide_toolbar, window_corner_snap, aa_fonts,
|
||||||
window_corner_snap, aa_fonts, ignore_shaded, ignore_maximized,
|
ignore_shaded, ignore_maximized, workspace_warping;
|
||||||
workspace_warping;
|
|
||||||
|
int snap_to_windows, snap_to_edges;
|
||||||
|
|
||||||
BColor border_color;
|
BColor border_color;
|
||||||
|
|
||||||
unsigned int workspaces;
|
unsigned int workspaces;
|
||||||
int toolbar_placement, toolbar_width_percent, placement_policy,
|
int toolbar_placement, toolbar_width_percent, placement_policy,
|
||||||
edge_snap_threshold, row_direction, col_direction, root_scroll;
|
snap_threshold, row_direction, col_direction, root_scroll,
|
||||||
|
resistance_size;
|
||||||
|
|
||||||
unsigned int handle_width, bevel_width, frame_width, border_width,
|
unsigned int handle_width, bevel_width, frame_width, border_width,
|
||||||
resize_zones;
|
resize_zones;
|
||||||
|
@ -216,8 +219,10 @@ public:
|
||||||
inline bool doFocusNew(void) const { return resource.focus_new; }
|
inline bool doFocusNew(void) const { return resource.focus_new; }
|
||||||
inline bool doFocusLast(void) const { return resource.focus_last; }
|
inline bool doFocusLast(void) const { return resource.focus_last; }
|
||||||
inline bool doHideToolbar(void) const { return resource.hide_toolbar; }
|
inline bool doHideToolbar(void) const { return resource.hide_toolbar; }
|
||||||
inline bool getWindowToWindowSnap(void) const
|
inline int getWindowToWindowSnap(void) const
|
||||||
{ return resource.window_to_window_snap; }
|
{ return resource.snap_to_windows; }
|
||||||
|
inline int getWindowToEdgeSnap(void) const
|
||||||
|
{ return resource.snap_to_edges; }
|
||||||
inline bool getWindowCornerSnap(void) const
|
inline bool getWindowCornerSnap(void) const
|
||||||
{ return resource.window_corner_snap; }
|
{ return resource.window_corner_snap; }
|
||||||
inline bool allowScrollLock(void) const { return resource.allow_scroll_lock; }
|
inline bool allowScrollLock(void) const { return resource.allow_scroll_lock; }
|
||||||
|
@ -265,8 +270,10 @@ public:
|
||||||
{ return resource.workspaces; }
|
{ return resource.workspaces; }
|
||||||
inline int getPlacementPolicy(void) const
|
inline int getPlacementPolicy(void) const
|
||||||
{ return resource.placement_policy; }
|
{ return resource.placement_policy; }
|
||||||
inline int getEdgeSnapThreshold(void) const
|
inline int getSnapThreshold(void) const
|
||||||
{ return resource.edge_snap_threshold; }
|
{ return resource.snap_threshold; }
|
||||||
|
inline int getResistanceSize(void) const
|
||||||
|
{ return resource.resistance_size; }
|
||||||
inline int getRowPlacementDirection(void) const
|
inline int getRowPlacementDirection(void) const
|
||||||
{ return resource.row_direction; }
|
{ return resource.row_direction; }
|
||||||
inline int getColPlacementDirection(void) const
|
inline int getColPlacementDirection(void) const
|
||||||
|
@ -282,7 +289,8 @@ public:
|
||||||
void savePlacementPolicy(int p);
|
void savePlacementPolicy(int p);
|
||||||
void saveRowPlacementDirection(int d);
|
void saveRowPlacementDirection(int d);
|
||||||
void saveColPlacementDirection(int d);
|
void saveColPlacementDirection(int d);
|
||||||
void saveEdgeSnapThreshold(int t);
|
void saveSnapThreshold(int t);
|
||||||
|
void saveResistanceSize(int s);
|
||||||
void saveImageDither(bool d);
|
void saveImageDither(bool d);
|
||||||
void saveAAFonts(bool f);
|
void saveAAFonts(bool f);
|
||||||
void saveOpaqueMove(bool o);
|
void saveOpaqueMove(bool o);
|
||||||
|
@ -290,7 +298,8 @@ public:
|
||||||
void saveFocusNew(bool f);
|
void saveFocusNew(bool f);
|
||||||
void saveFocusLast(bool f);
|
void saveFocusLast(bool f);
|
||||||
void saveHideToolbar(bool h);
|
void saveHideToolbar(bool h);
|
||||||
void saveWindowToWindowSnap(bool s);
|
void saveWindowToEdgeSnap(int s);
|
||||||
|
void saveWindowToWindowSnap(int s);
|
||||||
void saveWindowCornerSnap(bool s);
|
void saveWindowCornerSnap(bool s);
|
||||||
void saveResizeZones(unsigned int z);
|
void saveResizeZones(unsigned int z);
|
||||||
void savePlaceIgnoreShaded(bool i);
|
void savePlaceIgnoreShaded(bool i);
|
||||||
|
|
|
@ -3115,16 +3115,16 @@ bool BlackboxWindow::doWorkspaceWarping(int x_root, int y_root,
|
||||||
|
|
||||||
void BlackboxWindow::doWindowSnapping(int &dx, int &dy) {
|
void BlackboxWindow::doWindowSnapping(int &dx, int &dy) {
|
||||||
// how much resistance to edges to provide
|
// how much resistance to edges to provide
|
||||||
const int resistance_size = screen->getEdgeSnapThreshold();
|
const int resistance_size = screen->getResistanceSize();
|
||||||
|
|
||||||
// how far away to snap
|
// how far away to snap
|
||||||
const int snap_distance = screen->getEdgeSnapThreshold();
|
const int snap_distance = screen->getSnapThreshold();
|
||||||
|
|
||||||
// how to snap windows
|
// how to snap windows
|
||||||
const int snap_to_windows = BScreen::WindowResistance;
|
const int snap_to_windows = screen->getWindowToWindowSnap();
|
||||||
const int snap_to_edges = BScreen::WindowResistance;
|
const int snap_to_edges = screen->getWindowToEdgeSnap();
|
||||||
// the amount of space away from the edge to provide resistance/snap
|
// the amount of space away from the edge to provide resistance/snap
|
||||||
const int snap_offset = screen->getEdgeSnapThreshold();
|
// const int snap_offset = screen->getSnapThreshold();
|
||||||
|
|
||||||
// find the geomeetery where the moving window currently is
|
// find the geomeetery where the moving window currently is
|
||||||
const Rect &moving = screen->doOpaqueMove() ? frame.rect : frame.changing;
|
const Rect &moving = screen->doOpaqueMove() ? frame.rect : frame.changing;
|
||||||
|
|
Loading…
Reference in a new issue