mirror of
				https://codeberg.org/dwl/dwl-patches.git
				synced 2025-10-30 19:44:21 +00:00 
			
		
		
		
	add relative-mouse-resize patch
allow you to resize from each corner
This commit is contained in:
		
							parent
							
								
									f6430564c8
								
							
						
					
					
						commit
						976ea5e5b9
					
				
							
								
								
									
										106
									
								
								relative-mouse-resize/relative-mouse-resize.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										106
									
								
								relative-mouse-resize/relative-mouse-resize.patch
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,106 @@ | |||||||
|  | From cd7dec8ff61fef268a5c5053d33eb202b09ea3f6 Mon Sep 17 00:00:00 2001 | ||||||
|  | From: wochap <gean.marroquin@gmail.com> | ||||||
|  | Date: Wed, 6 Mar 2024 09:51:29 -0500 | ||||||
|  | Subject: [PATCH] implement relative mouse resize | ||||||
|  | 
 | ||||||
|  | the mouse willresize the window in the quadrant that the resize starts at | ||||||
|  | inspiration: https://github.com/djpohly/dwl/wiki/relativemouseresize | ||||||
|  | ---
 | ||||||
|  |  dwl.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- | ||||||
|  |  1 file changed, 59 insertions(+), 7 deletions(-) | ||||||
|  | 
 | ||||||
|  | diff --git a/dwl.c b/dwl.c
 | ||||||
|  | index ef27a1d..deb8c76 100644
 | ||||||
|  | --- a/dwl.c
 | ||||||
|  | +++ b/dwl.c
 | ||||||
|  | @@ -370,7 +370,8 @@ static struct wlr_seat *seat;
 | ||||||
|  |  static struct wl_list keyboards; | ||||||
|  |  static unsigned int cursor_mode; | ||||||
|  |  static Client *grabc; | ||||||
|  | -static int grabcx, grabcy; /* client-relative */
 | ||||||
|  | +static Client initial_grabc;
 | ||||||
|  | +static int grabcx, grabcy, grabx, graby, grabcenterx, grabcentery; /* client-relative */
 | ||||||
|  |   | ||||||
|  |  static struct wlr_output_layout *output_layout; | ||||||
|  |  static struct wlr_box sgeom; | ||||||
|  | @@ -1645,8 +1646,27 @@ motionnotify(uint32_t time)
 | ||||||
|  |  			.width = grabc->geom.width, .height = grabc->geom.height}, 1); | ||||||
|  |  		return; | ||||||
|  |  	} else if (cursor_mode == CurResize) { | ||||||
|  | -		resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y,
 | ||||||
|  | -			.width = cursor->x - grabc->geom.x, .height = cursor->y - grabc->geom.y}, 1);
 | ||||||
|  | +		if (grabcenterx < grabx) {
 | ||||||
|  | +			if (grabcentery < graby) {
 | ||||||
|  | +				/* bottom-right */
 | ||||||
|  | +				resize(grabc, (struct wlr_box){.x = initial_grabc.geom.x, .y = initial_grabc.geom.y,
 | ||||||
|  | +					.width = cursor->x - initial_grabc.geom.x, .height = cursor->y - initial_grabc.geom.y}, 1);
 | ||||||
|  | +			} else {
 | ||||||
|  | +				/* top-right */
 | ||||||
|  | +				resize(grabc, (struct wlr_box){.x = initial_grabc.geom.x, .y = cursor->y,
 | ||||||
|  | +					.width = cursor->x - initial_grabc.geom.x, .height = initial_grabc.geom.y + initial_grabc.geom.height - cursor->y}, 1);
 | ||||||
|  | +			}
 | ||||||
|  | +		} else {
 | ||||||
|  | +			if (grabcentery < graby) {
 | ||||||
|  | +				/* bottom-left */
 | ||||||
|  | +				resize(grabc, (struct wlr_box){.x = cursor->x, .y = initial_grabc.geom.y,
 | ||||||
|  | +					.width = initial_grabc.geom.x + initial_grabc.geom.width - cursor->x, .height = cursor->y - initial_grabc.geom.y}, 1);
 | ||||||
|  | +			} else {
 | ||||||
|  | +				/* top-left */
 | ||||||
|  | +				resize(grabc, (struct wlr_box){.x = cursor->x, .y = cursor->y,
 | ||||||
|  | +					.width = initial_grabc.geom.x + initial_grabc.geom.width - cursor->x, .height = initial_grabc.geom.y + initial_grabc.geom.height - cursor->y}, 1);
 | ||||||
|  | +			}
 | ||||||
|  | +		}
 | ||||||
|  |  		return; | ||||||
|  |  	} | ||||||
|  |   | ||||||
|  | @@ -1707,10 +1727,42 @@ moveresize(const Arg *arg)
 | ||||||
|  |  	case CurResize: | ||||||
|  |  		/* Doesn't work for X11 output - the next absolute motion event | ||||||
|  |  		 * returns the cursor to where it started */ | ||||||
|  | -		wlr_cursor_warp_closest(cursor, NULL,
 | ||||||
|  | -				grabc->geom.x + grabc->geom.width,
 | ||||||
|  | -				grabc->geom.y + grabc->geom.height);
 | ||||||
|  | -		wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
 | ||||||
|  | +		initial_grabc = *grabc;
 | ||||||
|  | +		grabx = cursor->x;
 | ||||||
|  | +		graby = cursor->y;
 | ||||||
|  | +		grabcx = cursor->x - grabc->geom.x;
 | ||||||
|  | +		grabcy = cursor->y - grabc->geom.y;
 | ||||||
|  | +		grabcenterx = grabc->geom.width / 2 + grabc->geom.x;
 | ||||||
|  | +		grabcentery = grabc->geom.height / 2 + grabc->geom.y;
 | ||||||
|  | +		if (grabcenterx < grabx) {
 | ||||||
|  | +			if (grabcentery < graby) {
 | ||||||
|  | +				/* bottom-right */
 | ||||||
|  | +				wlr_cursor_warp_closest(cursor, NULL,
 | ||||||
|  | +					grabc->geom.x + grabc->geom.width,
 | ||||||
|  | +					grabc->geom.y + grabc->geom.height);
 | ||||||
|  | +				wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
 | ||||||
|  | +			} else {
 | ||||||
|  | +				/* top-right */
 | ||||||
|  | +				wlr_cursor_warp_closest(cursor, NULL,
 | ||||||
|  | +					grabc->geom.x + grabc->geom.width,
 | ||||||
|  | +					grabc->geom.y);
 | ||||||
|  | +				wlr_cursor_set_xcursor(cursor, cursor_mgr, "ne-resize");
 | ||||||
|  | +			}
 | ||||||
|  | +		} else {
 | ||||||
|  | +			if (grabcentery < graby) {
 | ||||||
|  | +				/* bottom-left */
 | ||||||
|  | +				wlr_cursor_warp_closest(cursor, NULL,
 | ||||||
|  | +					grabc->geom.x,
 | ||||||
|  | +					grabc->geom.y + grabc->geom.height);
 | ||||||
|  | +				wlr_cursor_set_xcursor(cursor, cursor_mgr, "sw-resize");
 | ||||||
|  | +			} else {
 | ||||||
|  | +				/* top-left */
 | ||||||
|  | +				wlr_cursor_warp_closest(cursor, NULL,
 | ||||||
|  | +					grabc->geom.x,
 | ||||||
|  | +					grabc->geom.y);
 | ||||||
|  | +				wlr_cursor_set_xcursor(cursor, cursor_mgr, "nw-resize");
 | ||||||
|  | +			}
 | ||||||
|  | +		}
 | ||||||
|  |  		break; | ||||||
|  |  	} | ||||||
|  |  } | ||||||
|  | -- 
 | ||||||
|  | 2.42.0 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 wochap
						wochap