mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	s/cursor_mode/input_mode/
This commit is contained in:
		
							parent
							
								
									dc5d1ab976
								
							
						
					
					
						commit
						d5b9a65978
					
				
					 5 changed files with 24 additions and 24 deletions
				
			
		| 
						 | 
					@ -37,10 +37,10 @@
 | 
				
			||||||
#define XCURSOR_SIZE 24
 | 
					#define XCURSOR_SIZE 24
 | 
				
			||||||
#define XCURSOR_MOVE "grabbing"
 | 
					#define XCURSOR_MOVE "grabbing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum cursor_mode {
 | 
					enum input_mode {
 | 
				
			||||||
	LAB_CURSOR_PASSTHROUGH = 0,
 | 
						LAB_INPUT_STATE_PASSTHROUGH = 0,
 | 
				
			||||||
	LAB_CURSOR_MOVE,
 | 
						LAB_INPUT_STATE_MOVE,
 | 
				
			||||||
	LAB_CURSOR_RESIZE,
 | 
						LAB_INPUT_STATE_RESIZE,
 | 
				
			||||||
	LAB_INPUT_STATE_MENU,
 | 
						LAB_INPUT_STATE_MENU,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -95,7 +95,7 @@ struct server {
 | 
				
			||||||
	struct seat seat;
 | 
						struct seat seat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* cursor interactive */
 | 
						/* cursor interactive */
 | 
				
			||||||
	enum cursor_mode cursor_mode;
 | 
						enum input_mode input_mode;
 | 
				
			||||||
	struct view *grabbed_view;
 | 
						struct view *grabbed_view;
 | 
				
			||||||
	double grab_x, grab_y;
 | 
						double grab_x, grab_y;
 | 
				
			||||||
	struct wlr_box grab_box;
 | 
						struct wlr_box grab_box;
 | 
				
			||||||
| 
						 | 
					@ -245,7 +245,7 @@ void seat_init(struct server *server);
 | 
				
			||||||
void seat_finish(struct server *server);
 | 
					void seat_finish(struct server *server);
 | 
				
			||||||
void seat_focus_surface(struct seat *seat, struct wlr_surface *surface);
 | 
					void seat_focus_surface(struct seat *seat, struct wlr_surface *surface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void interactive_begin(struct view *view, enum cursor_mode mode,
 | 
					void interactive_begin(struct view *view, enum input_mode mode,
 | 
				
			||||||
		       uint32_t edges);
 | 
							       uint32_t edges);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void output_init(struct server *server);
 | 
					void output_init(struct server *server);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										26
									
								
								src/cursor.c
									
										
									
									
									
								
							
							
						
						
									
										26
									
								
								src/cursor.c
									
										
									
									
									
								
							| 
						 | 
					@ -103,13 +103,13 @@ static void
 | 
				
			||||||
process_cursor_motion(struct server *server, uint32_t time)
 | 
					process_cursor_motion(struct server *server, uint32_t time)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/* If the mode is non-passthrough, delegate to those functions. */
 | 
						/* If the mode is non-passthrough, delegate to those functions. */
 | 
				
			||||||
	if (server->cursor_mode == LAB_CURSOR_MOVE) {
 | 
						if (server->input_mode == LAB_INPUT_STATE_MOVE) {
 | 
				
			||||||
		process_cursor_move(server, time);
 | 
							process_cursor_move(server, time);
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	} else if (server->cursor_mode == LAB_CURSOR_RESIZE) {
 | 
						} else if (server->input_mode == LAB_INPUT_STATE_RESIZE) {
 | 
				
			||||||
		process_cursor_resize(server, time);
 | 
							process_cursor_resize(server, time);
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	} else if (server->cursor_mode == LAB_INPUT_STATE_MENU) {
 | 
						} else if (server->input_mode == LAB_INPUT_STATE_MENU) {
 | 
				
			||||||
		menu_set_selected(server->rootmenu,
 | 
							menu_set_selected(server->rootmenu,
 | 
				
			||||||
			server->seat.cursor->x, server->seat.cursor->y);
 | 
								server->seat.cursor->x, server->seat.cursor->y);
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
| 
						 | 
					@ -250,24 +250,24 @@ cursor_button(struct wl_listener *listener, void *data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* handle _release_ */
 | 
						/* handle _release_ */
 | 
				
			||||||
	if (event->state == WLR_BUTTON_RELEASED) {
 | 
						if (event->state == WLR_BUTTON_RELEASED) {
 | 
				
			||||||
		if (server->cursor_mode == LAB_INPUT_STATE_MENU) {
 | 
							if (server->input_mode == LAB_INPUT_STATE_MENU) {
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		/* Exit interactive move/resize/menu mode. */
 | 
							/* Exit interactive move/resize/menu mode. */
 | 
				
			||||||
		server->cursor_mode = LAB_CURSOR_PASSTHROUGH;
 | 
							server->input_mode = LAB_INPUT_STATE_PASSTHROUGH;
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (server->cursor_mode == LAB_INPUT_STATE_MENU) {
 | 
						if (server->input_mode == LAB_INPUT_STATE_MENU) {
 | 
				
			||||||
		menu_action_selected(server, server->rootmenu);
 | 
							menu_action_selected(server, server->rootmenu);
 | 
				
			||||||
		server->cursor_mode = LAB_CURSOR_PASSTHROUGH;
 | 
							server->input_mode = LAB_INPUT_STATE_PASSTHROUGH;
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* handle _press_ on desktop */
 | 
						/* handle _press_ on desktop */
 | 
				
			||||||
	if (!view) {
 | 
						if (!view) {
 | 
				
			||||||
		/* launch root-menu */
 | 
							/* launch root-menu */
 | 
				
			||||||
		server->cursor_mode = LAB_INPUT_STATE_MENU;
 | 
							server->input_mode = LAB_INPUT_STATE_MENU;
 | 
				
			||||||
		menu_move(server->rootmenu, server->seat.cursor->x,
 | 
							menu_move(server->rootmenu, server->seat.cursor->x,
 | 
				
			||||||
			server->seat.cursor->y);
 | 
								server->seat.cursor->y);
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
| 
						 | 
					@ -284,22 +284,22 @@ cursor_button(struct wl_listener *listener, void *data)
 | 
				
			||||||
		view_minimize(view);
 | 
							view_minimize(view);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case LAB_DECO_PART_TITLE:
 | 
						case LAB_DECO_PART_TITLE:
 | 
				
			||||||
		interactive_begin(view, LAB_CURSOR_MOVE, 0);
 | 
							interactive_begin(view, LAB_INPUT_STATE_MOVE, 0);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case LAB_DECO_PART_TOP:
 | 
						case LAB_DECO_PART_TOP:
 | 
				
			||||||
		interactive_begin(view, LAB_CURSOR_RESIZE,
 | 
							interactive_begin(view, LAB_INPUT_STATE_RESIZE,
 | 
				
			||||||
				  WLR_EDGE_TOP);
 | 
									  WLR_EDGE_TOP);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case LAB_DECO_PART_RIGHT:
 | 
						case LAB_DECO_PART_RIGHT:
 | 
				
			||||||
		interactive_begin(view, LAB_CURSOR_RESIZE,
 | 
							interactive_begin(view, LAB_INPUT_STATE_RESIZE,
 | 
				
			||||||
				  WLR_EDGE_RIGHT);
 | 
									  WLR_EDGE_RIGHT);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case LAB_DECO_PART_BOTTOM:
 | 
						case LAB_DECO_PART_BOTTOM:
 | 
				
			||||||
		interactive_begin(view, LAB_CURSOR_RESIZE,
 | 
							interactive_begin(view, LAB_INPUT_STATE_RESIZE,
 | 
				
			||||||
				  WLR_EDGE_BOTTOM);
 | 
									  WLR_EDGE_BOTTOM);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case LAB_DECO_PART_LEFT:
 | 
						case LAB_DECO_PART_LEFT:
 | 
				
			||||||
		interactive_begin(view, LAB_CURSOR_RESIZE,
 | 
							interactive_begin(view, LAB_INPUT_STATE_RESIZE,
 | 
				
			||||||
				  WLR_EDGE_LEFT);
 | 
									  WLR_EDGE_LEFT);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
#include "labwc.h"
 | 
					#include "labwc.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
interactive_begin(struct view *view, enum cursor_mode mode, uint32_t edges)
 | 
					interactive_begin(struct view *view, enum input_mode mode, uint32_t edges)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * This function sets up an interactive move or resize operation, where
 | 
						 * This function sets up an interactive move or resize operation, where
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@ interactive_begin(struct view *view, enum cursor_mode mode, uint32_t edges)
 | 
				
			||||||
	struct seat *seat = &view->server->seat;
 | 
						struct seat *seat = &view->server->seat;
 | 
				
			||||||
	struct server *server = view->server;
 | 
						struct server *server = view->server;
 | 
				
			||||||
	server->grabbed_view = view;
 | 
						server->grabbed_view = view;
 | 
				
			||||||
	server->cursor_mode = mode;
 | 
						server->input_mode = mode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Remember view and cursor positions at start of move/resize */
 | 
						/* Remember view and cursor positions at start of move/resize */
 | 
				
			||||||
	server->grab_x = seat->cursor->x;
 | 
						server->grab_x = seat->cursor->x;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -362,7 +362,7 @@ output_frame_notify(struct wl_listener *listener, void *data)
 | 
				
			||||||
	render_layer(&now, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
 | 
						render_layer(&now, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
 | 
				
			||||||
	render_layer(&now, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
 | 
						render_layer(&now, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (output->server->cursor_mode == LAB_INPUT_STATE_MENU) {
 | 
						if (output->server->input_mode == LAB_INPUT_STATE_MENU) {
 | 
				
			||||||
		render_rootmenu(output);
 | 
							render_rootmenu(output);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -112,7 +112,7 @@ handle_request_move(struct wl_listener *listener, void *data)
 | 
				
			||||||
	 * client, to prevent the client from requesting this whenever they
 | 
						 * client, to prevent the client from requesting this whenever they
 | 
				
			||||||
	 * want. */
 | 
						 * want. */
 | 
				
			||||||
	struct view *view = wl_container_of(listener, view, request_move);
 | 
						struct view *view = wl_container_of(listener, view, request_move);
 | 
				
			||||||
	interactive_begin(view, LAB_CURSOR_MOVE, 0);
 | 
						interactive_begin(view, LAB_INPUT_STATE_MOVE, 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -127,7 +127,7 @@ handle_request_resize(struct wl_listener *listener, void *data)
 | 
				
			||||||
	 * want. */
 | 
						 * want. */
 | 
				
			||||||
	struct wlr_xdg_toplevel_resize_event *event = data;
 | 
						struct wlr_xdg_toplevel_resize_event *event = data;
 | 
				
			||||||
	struct view *view = wl_container_of(listener, view, request_resize);
 | 
						struct view *view = wl_container_of(listener, view, request_resize);
 | 
				
			||||||
	interactive_begin(view, LAB_CURSOR_RESIZE, event->edges);
 | 
						interactive_begin(view, LAB_INPUT_STATE_RESIZE, event->edges);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue