diff options
author | Mark Murawski <markm@intellasoft.net> | 2017-11-19 18:37:37 (GMT) |
---|---|---|
committer | Mathias Gumz <akira@fluxbox.org> | 2017-11-19 19:10:26 (GMT) |
commit | 7cb7bfaa448003466315ccc21d08b71f5c77df70 (patch) | |
tree | 2181cef0a2ec814c9e944502ca0d02ed4c926c48 | |
parent | 0090dc8a6ba4b5c360ecda470b316e630b85c30c (diff) | |
download | fluxbox-7cb7bfaa448003466315ccc21d08b71f5c77df70.zip fluxbox-7cb7bfaa448003466315ccc21d08b71f5c77df70.tar.bz2 |
Support 'vertical' Workspace warping
'Vertical' Workspace warping is a variant of the existing Workspace
warping feature: When a user drags a window to the edge of the Screen,
the window is warped to the next / previous workspace.
'Vertical' Workspace warping detects a drag towards the upper / lower
border of the screen and warps the current workspace about an 'offset'.
Example given, lets say the user has 9 workspaces and considers them to
form a 3x3 grid:
+-+-+-+
|1|2|3|
+-+-+-+
|4|5|6|
+-+-+-+
|7|8|9|
+-+-+-+
An 'offset' of 3 warps from workspaces 2 to workspace 5 (or 8), when a
window is dragged to the bottom / top border.
New configuration ressources:
session.screenN.workspacewarpingvertical: true
session.screenN.workspacewarpingverticaloffset: X
-rw-r--r-- | src/Screen.hh | 2 | ||||
-rw-r--r-- | src/ScreenResource.cc | 2 | ||||
-rw-r--r-- | src/ScreenResource.hh | 4 | ||||
-rw-r--r-- | src/Window.cc | 66 |
4 files changed, 58 insertions, 16 deletions
diff --git a/src/Screen.hh b/src/Screen.hh index 30fbb4a..15eb349 100644 --- a/src/Screen.hh +++ b/src/Screen.hh | |||
@@ -95,6 +95,8 @@ public: | |||
95 | bool isRootColormapInstalled() const { return root_colormap_installed; } | 95 | bool isRootColormapInstalled() const { return root_colormap_installed; } |
96 | bool isScreenManaged() const { return m_state.managed; } | 96 | bool isScreenManaged() const { return m_state.managed; } |
97 | bool isWorkspaceWarping() const { return (m_workspaces_list.size() > 1) && *resource.workspace_warping; } | 97 | bool isWorkspaceWarping() const { return (m_workspaces_list.size() > 1) && *resource.workspace_warping; } |
98 | bool isWorkspaceWarpingVertical() const { return *resource.workspace_warping_vertical; } | ||
99 | int getWorkspaceWarpingVerticalOffset() const { return *resource.workspace_warping_vertical_offset; } | ||
98 | bool doAutoRaise() const { return *resource.auto_raise; } | 100 | bool doAutoRaise() const { return *resource.auto_raise; } |
99 | bool clickRaises() const { return *resource.click_raises; } | 101 | bool clickRaises() const { return *resource.click_raises; } |
100 | bool doOpaqueMove() const { return *resource.opaque_move; } | 102 | bool doOpaqueMove() const { return *resource.opaque_move; } |
diff --git a/src/ScreenResource.cc b/src/ScreenResource.cc index dbf532b..c188648 100644 --- a/src/ScreenResource.cc +++ b/src/ScreenResource.cc | |||
@@ -88,6 +88,8 @@ ScreenResource::ScreenResource(FbTk::ResourceManager& rm, | |||
88 | max_disable_move(rm, false, scrname+".maxDisableMove", altscrname+".MaxDisableMove"), | 88 | max_disable_move(rm, false, scrname+".maxDisableMove", altscrname+".MaxDisableMove"), |
89 | max_disable_resize(rm, false, scrname+".maxDisableResize", altscrname+".MaxDisableResize"), | 89 | max_disable_resize(rm, false, scrname+".maxDisableResize", altscrname+".MaxDisableResize"), |
90 | workspace_warping(rm, true, scrname+".workspacewarping", altscrname+".WorkspaceWarping"), | 90 | workspace_warping(rm, true, scrname+".workspacewarping", altscrname+".WorkspaceWarping"), |
91 | workspace_warping_vertical(rm, true, scrname+".workspacewarpingvertical", altscrname+".WorkspaceWarpingVertical"), | ||
92 | workspace_warping_vertical_offset(rm, 1, scrname+".workspacewarpingverticaloffset", altscrname+".WorkspaceWarpingVerticalOffset"), | ||
91 | show_window_pos(rm, false, scrname+".showwindowposition", altscrname+".ShowWindowPosition"), | 93 | show_window_pos(rm, false, scrname+".showwindowposition", altscrname+".ShowWindowPosition"), |
92 | auto_raise(rm, true, scrname+".autoRaise", altscrname+".AutoRaise"), | 94 | auto_raise(rm, true, scrname+".autoRaise", altscrname+".AutoRaise"), |
93 | click_raises(rm, true, scrname+".clickRaises", altscrname+".ClickRaises"), | 95 | click_raises(rm, true, scrname+".clickRaises", altscrname+".ClickRaises"), |
diff --git a/src/ScreenResource.hh b/src/ScreenResource.hh index 7f1e621..bc782e1 100644 --- a/src/ScreenResource.hh +++ b/src/ScreenResource.hh | |||
@@ -37,6 +37,7 @@ struct ScreenResource { | |||
37 | max_disable_move, | 37 | max_disable_move, |
38 | max_disable_resize, | 38 | max_disable_resize, |
39 | workspace_warping, | 39 | workspace_warping, |
40 | workspace_warping_vertical, | ||
40 | show_window_pos, | 41 | show_window_pos, |
41 | auto_raise, | 42 | auto_raise, |
42 | click_raises; | 43 | click_raises; |
@@ -53,7 +54,8 @@ struct ScreenResource { | |||
53 | menu_alpha, | 54 | menu_alpha, |
54 | menu_delay, | 55 | menu_delay, |
55 | tab_width, | 56 | tab_width, |
56 | tooltip_delay; | 57 | tooltip_delay, |
58 | workspace_warping_vertical_offset; | ||
57 | FbTk::Resource<bool> allow_remote_actions; | 59 | FbTk::Resource<bool> allow_remote_actions; |
58 | FbTk::Resource<bool> clientmenu_use_pixmap; | 60 | FbTk::Resource<bool> clientmenu_use_pixmap; |
59 | FbTk::Resource<bool> tabs_use_pixmap; | 61 | FbTk::Resource<bool> tabs_use_pixmap; |
diff --git a/src/Window.cc b/src/Window.cc index 23c9789..6714d0a 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -2539,6 +2539,10 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { | |||
2539 | 2539 | ||
2540 | // Warp to next or previous workspace?, must have moved sideways some | 2540 | // Warp to next or previous workspace?, must have moved sideways some |
2541 | int moved_x = me.x_root - m_last_resize_x; | 2541 | int moved_x = me.x_root - m_last_resize_x; |
2542 | |||
2543 | // Warp to a workspace offset (if treating workspaces like a grid) | ||
2544 | int moved_y = me.y_root - m_last_resize_y; | ||
2545 | |||
2542 | // save last event point | 2546 | // save last event point |
2543 | m_last_resize_x = me.x_root; | 2547 | m_last_resize_x = me.x_root; |
2544 | m_last_resize_y = me.y_root; | 2548 | m_last_resize_y = me.y_root; |
@@ -2554,25 +2558,57 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { | |||
2554 | } | 2558 | } |
2555 | } | 2559 | } |
2556 | 2560 | ||
2557 | if (moved_x && screen().isWorkspaceWarping()) { | 2561 | |
2562 | // check for warping | ||
2563 | // | ||
2564 | // +--monitor-1--+--monitor-2---+ | ||
2565 | // |w | w| | ||
2566 | // |w | w| | ||
2567 | // +-------------+--------------+ | ||
2568 | // | ||
2569 | // mouse-warping is enabled, the mouse needs to be in the "warp_pad" | ||
2570 | // zone. | ||
2571 | // | ||
2572 | const int warp_pad = screen().getEdgeSnapThreshold(); | ||
2573 | const int workspaces = screen().numberOfWorkspaces(); | ||
2574 | const bool is_warping = screen().isWorkspaceWarping(); | ||
2575 | const bool is_warping_vertical = screen().isWorkspaceWarpingVertical(); | ||
2576 | |||
2577 | if ((moved_x || moved_y) && is_warping) { | ||
2558 | unsigned int cur_id = screen().currentWorkspaceID(); | 2578 | unsigned int cur_id = screen().currentWorkspaceID(); |
2559 | unsigned int new_id = cur_id; | 2579 | unsigned int new_id = cur_id; |
2560 | const int warpPad = screen().getEdgeSnapThreshold(); | 2580 | |
2561 | // 1) if we're inside the border threshold | 2581 | // border threshold |
2562 | // 2) if we moved in the right direction | 2582 | int bt_right = int(screen().width()) - warp_pad - 1; |
2563 | if (me.x_root >= int(screen().width()) - warpPad - 1 && | 2583 | int bt_left = warp_pad; |
2564 | moved_x > 0) { | 2584 | int bt_top = int(screen().height()) - warp_pad - 1; |
2565 | //warp right | 2585 | int bt_bottom = warp_pad; |
2566 | new_id = (cur_id + 1) % screen().numberOfWorkspaces(); | 2586 | |
2567 | m_last_resize_x = 0; // move mouse back to x=0 | 2587 | if (moved_x) { |
2568 | } else if (me.x_root <= warpPad && | 2588 | if (me.x_root >= bt_right && moved_x > 0) { //warp right |
2569 | moved_x < 0) { | 2589 | new_id = (cur_id + 1) % workspaces; |
2570 | //warp left | 2590 | m_last_resize_x = 0; |
2571 | new_id = (cur_id + screen().numberOfWorkspaces() - 1) % screen().numberOfWorkspaces(); | 2591 | } else if (me.x_root <= bt_left && moved_x < 0) { //warp left |
2572 | m_last_resize_x = screen().width() - 1; // move mouse to screen width - 1 | 2592 | new_id = (cur_id + -1) % workspaces; |
2593 | m_last_resize_x = screen().width() - 1; | ||
2594 | } | ||
2573 | } | 2595 | } |
2574 | if (new_id != cur_id) { | ||
2575 | 2596 | ||
2597 | if (moved_y && is_warping_vertical) { | ||
2598 | |||
2599 | const int warp_offset = screen().getWorkspaceWarpingVerticalOffset(); | ||
2600 | |||
2601 | if (me.y_root >= bt_top && moved_y > 0) { // warp down | ||
2602 | new_id = (cur_id + warp_offset) % workspaces; | ||
2603 | m_last_resize_y = 0; | ||
2604 | } else if (me.y_root <= bt_bottom && moved_y < 0) { // warp up | ||
2605 | new_id = (cur_id + workspaces - warp_offset) % workspaces; | ||
2606 | m_last_resize_y = screen().height() - 1; | ||
2607 | } | ||
2608 | } | ||
2609 | |||
2610 | // if we are warping | ||
2611 | if (new_id != cur_id) { | ||
2576 | // remove motion events from queue to avoid repeated warps | 2612 | // remove motion events from queue to avoid repeated warps |
2577 | while (XCheckTypedEvent(display, MotionNotify, &e)) { | 2613 | while (XCheckTypedEvent(display, MotionNotify, &e)) { |
2578 | // might as well update the y-coordinate | 2614 | // might as well update the y-coordinate |