aboutsummaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc66
1 files changed, 51 insertions, 15 deletions
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