|
|
@@ -572,6 +572,12 @@ pub fn resizemouse(wm: *WindowManager) void { |
| 572 |
572 |
|
| 573 |
573 |
core.restack(monitor, wm); |
| 574 |
574 |
|
|
575 |
+ // If tiled_resize_mode is enabled and window is tiled, adjust mfact instead |
|
576 |
+ if (wm.config.tiled_resize_mode and !client.is_floating) { |
|
577 |
+ resizemouseTiled(wm, monitor); |
|
578 |
+ return; |
|
579 |
+ } |
|
580 |
+ |
| 575 |
581 |
if (!client.is_floating) { |
| 576 |
582 |
client.is_floating = true; |
| 577 |
583 |
} |
|
|
@@ -635,6 +641,85 @@ pub fn resizemouse(wm: *WindowManager) void { |
| 635 |
641 |
core.arrange(monitor, wm); |
| 636 |
642 |
} |
| 637 |
643 |
|
|
644 |
+/// Resize tiled windows by adjusting mfact with mouse drag (like Super+H/L but with mouse) |
|
645 |
+fn resizemouseTiled(wm: *WindowManager, monitor: *Monitor) void { |
|
646 |
+ const grab_result = xlib.XGrabPointer( |
|
647 |
+ wm.display.handle, |
|
648 |
+ wm.display.root, |
|
649 |
+ xlib.False, |
|
650 |
+ xlib.ButtonPressMask | xlib.ButtonReleaseMask | xlib.PointerMotionMask, |
|
651 |
+ xlib.GrabModeAsync, |
|
652 |
+ xlib.GrabModeAsync, |
|
653 |
+ xlib.None, |
|
654 |
+ wm.cursors.resize, |
|
655 |
+ xlib.CurrentTime, |
|
656 |
+ ); |
|
657 |
+ |
|
658 |
+ if (grab_result != xlib.GrabSuccess) { |
|
659 |
+ return; |
|
660 |
+ } |
|
661 |
+ |
|
662 |
+ // Get initial pointer position |
|
663 |
+ var root_return: xlib.Window = undefined; |
|
664 |
+ var child_return: xlib.Window = undefined; |
|
665 |
+ var root_x: c_int = undefined; |
|
666 |
+ var root_y: c_int = undefined; |
|
667 |
+ var win_x: c_int = undefined; |
|
668 |
+ var win_y: c_int = undefined; |
|
669 |
+ var mask_return: c_uint = undefined; |
|
670 |
+ |
|
671 |
+ _ = xlib.XQueryPointer( |
|
672 |
+ wm.display.handle, |
|
673 |
+ wm.display.root, |
|
674 |
+ &root_return, |
|
675 |
+ &child_return, |
|
676 |
+ &root_x, |
|
677 |
+ &root_y, |
|
678 |
+ &win_x, |
|
679 |
+ &win_y, |
|
680 |
+ &mask_return, |
|
681 |
+ ); |
|
682 |
+ |
|
683 |
+ const start_x = root_x; |
|
684 |
+ const initial_mfact = monitor.mfact; |
|
685 |
+ |
|
686 |
+ const total_width: f32 = @floatFromInt(monitor.win_w - 2 * monitor.gap_outer_v - monitor.gap_inner_v); |
|
687 |
+ |
|
688 |
+ var event: xlib.XEvent = undefined; |
|
689 |
+ var done = false; |
|
690 |
+ var last_time: c_ulong = 0; |
|
691 |
+ |
|
692 |
+ while (!done) { |
|
693 |
+ _ = xlib.XNextEvent(wm.display.handle, &event); |
|
694 |
+ |
|
695 |
+ switch (event.type) { |
|
696 |
+ xlib.MotionNotify => { |
|
697 |
+ const motion = &event.xmotion; |
|
698 |
+ if ((motion.time - last_time) < (1000 / 60)) { |
|
699 |
+ continue; |
|
700 |
+ } |
|
701 |
+ last_time = motion.time; |
|
702 |
+ |
|
703 |
+ const delta_x: f32 = @floatFromInt(motion.x_root - start_x); |
|
704 |
+ const mfact_delta = delta_x / total_width; |
|
705 |
+ const new_mfact = initial_mfact + mfact_delta; |
|
706 |
+ |
|
707 |
+ if (new_mfact >= 0.05 and new_mfact <= 0.95) { |
|
708 |
+ monitor.mfact = new_mfact; |
|
709 |
+ monitor.pertag.mfacts[monitor.pertag.curtag] = new_mfact; |
|
710 |
+ core.arrange(monitor, wm); |
|
711 |
+ } |
|
712 |
+ }, |
|
713 |
+ xlib.ButtonRelease => { |
|
714 |
+ done = true; |
|
715 |
+ }, |
|
716 |
+ else => {}, |
|
717 |
+ } |
|
718 |
+ } |
|
719 |
+ |
|
720 |
+ _ = xlib.XUngrabPointer(wm.display.handle, xlib.CurrentTime); |
|
721 |
+} |
|
722 |
+ |
| 638 |
723 |
/// Config-loading callback for wm.reloadConfig(). |
| 639 |
724 |
/// Re-initialises Lua and loads the config file (or falls back to defaults). |
| 640 |
725 |
pub fn reloadLoadConfig(wm: *WindowManager) void { |