mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	action: Select resize edges for Resize triggered by keybind
This commit is contained in:
		
							parent
							
								
									f112fb636e
								
							
						
					
					
						commit
						bbc6c6bb94
					
				
					 3 changed files with 18 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -545,6 +545,9 @@ struct cursor_context get_cursor_context(struct server *server);
 | 
			
		|||
 */
 | 
			
		||||
void cursor_set(struct seat *seat, const char *cursor_name);
 | 
			
		||||
 | 
			
		||||
uint32_t cursor_get_resize_edges(struct wlr_cursor *cursor,
 | 
			
		||||
	struct cursor_context *ctx);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * cursor_update_focus - update cursor focus, may update the cursor icon
 | 
			
		||||
 * @server - server
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										16
									
								
								src/action.c
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								src/action.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -167,7 +167,7 @@ show_menu(struct server *server, struct view *view, const char *menu_name)
 | 
			
		|||
 | 
			
		||||
static struct view *
 | 
			
		||||
view_for_action(struct view *activator, struct server *server,
 | 
			
		||||
	struct action *action)
 | 
			
		||||
	struct action *action, uint32_t *resize_edges)
 | 
			
		||||
{
 | 
			
		||||
	/* View is explicitly specified for mousebinds */
 | 
			
		||||
	if (activator) {
 | 
			
		||||
| 
						 | 
				
			
			@ -178,8 +178,15 @@ view_for_action(struct view *activator, struct server *server,
 | 
			
		|||
	switch (action->type) {
 | 
			
		||||
	case ACTION_TYPE_FOCUS:
 | 
			
		||||
	case ACTION_TYPE_MOVE:
 | 
			
		||||
	case ACTION_TYPE_RESIZE:
 | 
			
		||||
		return get_cursor_context(server).view;
 | 
			
		||||
	case ACTION_TYPE_RESIZE: {
 | 
			
		||||
		struct cursor_context ctx = get_cursor_context(server);
 | 
			
		||||
		if (action->type == ACTION_TYPE_RESIZE) {
 | 
			
		||||
			/* Select resize edges for the keybind case */
 | 
			
		||||
			*resize_edges = cursor_get_resize_edges(
 | 
			
		||||
				server->seat.cursor, &ctx);
 | 
			
		||||
		}
 | 
			
		||||
		return ctx.view;
 | 
			
		||||
	}
 | 
			
		||||
	default:
 | 
			
		||||
		return desktop_focused_view(server);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -208,7 +215,8 @@ actions_run(struct view *activator, struct server *server,
 | 
			
		|||
		 * Refetch view because it may have been changed due to the
 | 
			
		||||
		 * previous action
 | 
			
		||||
		 */
 | 
			
		||||
		view = view_for_action(activator, server, action);
 | 
			
		||||
		view = view_for_action(activator, server, action,
 | 
			
		||||
			&resize_edges);
 | 
			
		||||
 | 
			
		||||
		switch (action->type) {
 | 
			
		||||
		case ACTION_TYPE_CLOSE:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -378,8 +378,8 @@ cursor_update_common(struct server *server, struct cursor_context *ctx,
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint32_t
 | 
			
		||||
determine_resize_edges(struct wlr_cursor *cursor, struct cursor_context *ctx)
 | 
			
		||||
uint32_t
 | 
			
		||||
cursor_get_resize_edges(struct wlr_cursor *cursor, struct cursor_context *ctx)
 | 
			
		||||
{
 | 
			
		||||
	uint32_t resize_edges = ssd_resize_edges(ctx->type);
 | 
			
		||||
	if (ctx->view && !resize_edges) {
 | 
			
		||||
| 
						 | 
				
			
			@ -783,7 +783,7 @@ cursor_button_press(struct seat *seat, struct wlr_pointer_button_event *event)
 | 
			
		|||
	struct cursor_context ctx = get_cursor_context(server);
 | 
			
		||||
 | 
			
		||||
	/* Determine closest resize edges in case action is Resize */
 | 
			
		||||
	uint32_t resize_edges = determine_resize_edges(seat->cursor, &ctx);
 | 
			
		||||
	uint32_t resize_edges = cursor_get_resize_edges(seat->cursor, &ctx);
 | 
			
		||||
 | 
			
		||||
	if (ctx.view || ctx.surface) {
 | 
			
		||||
		/* Store resize edges for later action processing */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue