mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	common: flesh out enum lab_edge and prefer over wlr_edges/wlr_direction
I like the new common/edge.h. I don't like how inconsistently we use it. Current situation: - enum wlr_edges and wlr_direction are designed to be used as bitset, and are defined compatibly - enum lab_edge is *also* designed to be used as bitset, but incompatible with the others (LEFT/RIGHT come before UP/DOWN) - we use an inconsistent mix of all three *AND* uint32_t (usually with the WLR_EDGE constants rather than the LAB_EDGE constants), and convert between them on an ad-hoc basis, sometimes implicitly Let's clean this up: - reorder enum lab_edge to be compatible with the two wlr enums (check this by static_assert) - use TOP/BOTTOM naming rather than UP/DOWN (matches wlr_edges) - add constants for the remaining possible combinations of the 4 edges - use lab_edge for all internal edge/direction fields, consistently - add lab_edge_is_cardinal() as a sanity check before casting to enum wlr_direction, and then eliminate all of direction.c/h Instead of "enum wlr_edges direction", we now have "enum lab_edge direction" which is not that much better. At least we are now clear that we're overloading one enum with two meanings.
This commit is contained in:
		
							parent
							
								
									4d1be7eada
								
							
						
					
					
						commit
						ef766d16f0
					
				
					 26 changed files with 294 additions and 320 deletions
				
			
		
							
								
								
									
										37
									
								
								src/xdg.c
									
										
									
									
									
								
							
							
						
						
									
										37
									
								
								src/xdg.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -399,7 +399,7 @@ handle_request_move(struct wl_listener *listener, void *data)
 | 
			
		|||
	 */
 | 
			
		||||
	struct view *view = wl_container_of(listener, view, request_move);
 | 
			
		||||
	if (view == view->server->seat.pressed.view) {
 | 
			
		||||
		interactive_begin(view, LAB_INPUT_STATE_MOVE, 0);
 | 
			
		||||
		interactive_begin(view, LAB_INPUT_STATE_MOVE, LAB_EDGE_NONE);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -653,7 +653,7 @@ xdg_toplevel_view_notify_tiled(struct view *view)
 | 
			
		|||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	enum wlr_edges edge = WLR_EDGE_NONE;
 | 
			
		||||
	enum lab_edge edge = LAB_EDGE_NONE;
 | 
			
		||||
 | 
			
		||||
	bool want_edge = rc.snap_tiling_events_mode & LAB_TILING_EVENTS_EDGE;
 | 
			
		||||
	bool want_region = rc.snap_tiling_events_mode & LAB_TILING_EVENTS_REGION;
 | 
			
		||||
| 
						 | 
				
			
			@ -665,39 +665,32 @@ xdg_toplevel_view_notify_tiled(struct view *view)
 | 
			
		|||
	if (want_edge) {
 | 
			
		||||
		switch (view->tiled) {
 | 
			
		||||
		case LAB_EDGE_LEFT:
 | 
			
		||||
			edge = WLR_EDGE_LEFT | WLR_EDGE_TOP | WLR_EDGE_BOTTOM;
 | 
			
		||||
			edge = LAB_EDGES_EXCEPT_RIGHT;
 | 
			
		||||
			break;
 | 
			
		||||
		case LAB_EDGE_RIGHT:
 | 
			
		||||
			edge = WLR_EDGE_RIGHT | WLR_EDGE_TOP | WLR_EDGE_BOTTOM;
 | 
			
		||||
			edge = LAB_EDGES_EXCEPT_LEFT;
 | 
			
		||||
			break;
 | 
			
		||||
		case LAB_EDGE_UP:
 | 
			
		||||
			edge = WLR_EDGE_TOP | WLR_EDGE_LEFT | WLR_EDGE_RIGHT;
 | 
			
		||||
		case LAB_EDGE_TOP:
 | 
			
		||||
			edge = LAB_EDGES_EXCEPT_BOTTOM;
 | 
			
		||||
			break;
 | 
			
		||||
		case LAB_EDGE_DOWN:
 | 
			
		||||
			edge = WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT;
 | 
			
		||||
		case LAB_EDGE_BOTTOM:
 | 
			
		||||
			edge = LAB_EDGES_EXCEPT_TOP;
 | 
			
		||||
			break;
 | 
			
		||||
		case LAB_EDGE_UPLEFT:
 | 
			
		||||
			edge = WLR_EDGE_TOP | WLR_EDGE_LEFT;
 | 
			
		||||
			break;
 | 
			
		||||
		case LAB_EDGE_UPRIGHT:
 | 
			
		||||
			edge = WLR_EDGE_TOP | WLR_EDGE_RIGHT;
 | 
			
		||||
			break;
 | 
			
		||||
		case LAB_EDGE_DOWNLEFT:
 | 
			
		||||
			edge = WLR_EDGE_BOTTOM | WLR_EDGE_LEFT;
 | 
			
		||||
			break;
 | 
			
		||||
		case LAB_EDGE_DOWNRIGHT:
 | 
			
		||||
			edge = WLR_EDGE_BOTTOM | WLR_EDGE_RIGHT;
 | 
			
		||||
		case LAB_EDGES_TOP_LEFT:
 | 
			
		||||
		case LAB_EDGES_TOP_RIGHT:
 | 
			
		||||
		case LAB_EDGES_BOTTOM_LEFT:
 | 
			
		||||
		case LAB_EDGES_BOTTOM_RIGHT:
 | 
			
		||||
			edge = view->tiled;
 | 
			
		||||
			break;
 | 
			
		||||
		/* TODO: LAB_EDGE_CENTER? */
 | 
			
		||||
		default:
 | 
			
		||||
			edge = WLR_EDGE_NONE;
 | 
			
		||||
			edge = LAB_EDGE_NONE;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (want_region && view->tiled_region) {
 | 
			
		||||
		/* Region-snapped views are considered tiled on all edges */
 | 
			
		||||
		edge = WLR_EDGE_LEFT | WLR_EDGE_RIGHT |
 | 
			
		||||
			WLR_EDGE_TOP | WLR_EDGE_BOTTOM;
 | 
			
		||||
		edge = LAB_EDGES_ALL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	uint32_t serial =
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue