mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	Move some functions from main.c to dbg.c
This commit is contained in:
		
							parent
							
								
									7732869870
								
							
						
					
					
						commit
						6eb362b842
					
				
					 4 changed files with 80 additions and 75 deletions
				
			
		
							
								
								
									
										2
									
								
								Makefile
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
										
									
									
									
								
							| 
						 | 
					@ -15,7 +15,7 @@ WS = `pkg-config --variable=wayland_scanner wayland-scanner`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
all: labwc
 | 
					all: labwc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
labwc: xdg-shell-protocol.o main.o xdg.o view.o xwl.o server.o output.o
 | 
					labwc: xdg-shell-protocol.o main.o xdg.o view.o xwl.o server.o output.o dbg.o
 | 
				
			||||||
	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
 | 
						$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
xdg-shell-protocol.h:
 | 
					xdg-shell-protocol.h:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										76
									
								
								dbg.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								dbg.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,76 @@
 | 
				
			||||||
 | 
					#include "labwc.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void show_one_xdg_view(struct view *view)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						fprintf(stderr, "XDG  ");
 | 
				
			||||||
 | 
						switch (view->xdg_surface->role) {
 | 
				
			||||||
 | 
						case WLR_XDG_SURFACE_ROLE_NONE:
 | 
				
			||||||
 | 
							fprintf(stderr, "- ");
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
 | 
				
			||||||
 | 
							fprintf(stderr, "0 ");
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						case WLR_XDG_SURFACE_ROLE_POPUP:
 | 
				
			||||||
 | 
							fprintf(stderr, "? ");
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						fprintf(stderr, "                   %p %s", (void *)view,
 | 
				
			||||||
 | 
							view->xdg_surface->toplevel->app_id);
 | 
				
			||||||
 | 
						fprintf(stderr, "  {%d, %d, %d, %d}\n", view->xdg_surface->geometry.x,
 | 
				
			||||||
 | 
							view->xdg_surface->geometry.y,
 | 
				
			||||||
 | 
							view->xdg_surface->geometry.height,
 | 
				
			||||||
 | 
							view->xdg_surface->geometry.width);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void show_one_xwl_view(struct view *view)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						fprintf(stderr, "XWL  ");
 | 
				
			||||||
 | 
						if (!view->been_mapped) {
 | 
				
			||||||
 | 
							fprintf(stderr, "- ");
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							fprintf(stderr, "%d ", xwl_nr_parents(view));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						fprintf(stderr, "     %d      ",
 | 
				
			||||||
 | 
							wl_list_length(&view->xwayland_surface->children));
 | 
				
			||||||
 | 
						if (view->mapped) {
 | 
				
			||||||
 | 
							fprintf(stderr, "Y");
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							fprintf(stderr, "-");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						fprintf(stderr, "      %p %s {%d,%d,%d,%d}\n", (void *)view,
 | 
				
			||||||
 | 
							view->xwayland_surface->class, view->xwayland_surface->x,
 | 
				
			||||||
 | 
							view->xwayland_surface->y, view->xwayland_surface->width,
 | 
				
			||||||
 | 
							view->xwayland_surface->height);
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * Other variables to consider printing:
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * view->mapped,
 | 
				
			||||||
 | 
						 * view->been_mapped,
 | 
				
			||||||
 | 
						 * view->xwayland_surface->override_redirect,
 | 
				
			||||||
 | 
						 * wlr_xwayland_or_surface_wants_focus(view->xwayland_surface));
 | 
				
			||||||
 | 
						 * view->xwayland_surface->saved_width,
 | 
				
			||||||
 | 
						 * view->xwayland_surface->saved_height);
 | 
				
			||||||
 | 
						 * view->xwayland_surface->surface->sx,
 | 
				
			||||||
 | 
						 * view->xwayland_surface->surface->sy);
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void show_one_view(struct view *view)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (view->type == LAB_XDG_SHELL_VIEW)
 | 
				
			||||||
 | 
							show_one_xdg_view(view);
 | 
				
			||||||
 | 
						else if (view->type == LAB_XWAYLAND_VIEW)
 | 
				
			||||||
 | 
							show_one_xwl_view(view);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void dbg_show_views(struct server *server)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct view *view;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						fprintf(stderr, "---\n");
 | 
				
			||||||
 | 
						fprintf(stderr, "TYPE NR_PNT NR_CLD MAPPED VIEW-POINTER   NAME\n");
 | 
				
			||||||
 | 
						wl_list_for_each_reverse (view, &server->views, link)
 | 
				
			||||||
 | 
							show_one_view(view);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										2
									
								
								labwc.h
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								labwc.h
									
										
									
									
									
								
							| 
						 | 
					@ -152,4 +152,6 @@ void server_new_output(struct wl_listener *listener, void *data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void output_frame(struct wl_listener *listener, void *data);
 | 
					void output_frame(struct wl_listener *listener, void *data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void dbg_show_views(struct server *server);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* LABWC_H */
 | 
					#endif /* LABWC_H */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										75
									
								
								main.c
									
										
									
									
									
								
							
							
						
						
									
										75
									
								
								main.c
									
										
									
									
									
								
							| 
						 | 
					@ -50,79 +50,6 @@ static void keyboard_handle_modifiers(struct wl_listener *listener, void *data)
 | 
				
			||||||
		keyboard->server->seat, &keyboard->device->keyboard->modifiers);
 | 
							keyboard->server->seat, &keyboard->device->keyboard->modifiers);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void xdg_debug_show_one_view(struct view *view)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	fprintf(stderr, "XDG  ");
 | 
					 | 
				
			||||||
	switch (view->xdg_surface->role) {
 | 
					 | 
				
			||||||
	case WLR_XDG_SURFACE_ROLE_NONE:
 | 
					 | 
				
			||||||
		fprintf(stderr, "- ");
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
 | 
					 | 
				
			||||||
		fprintf(stderr, "0 ");
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case WLR_XDG_SURFACE_ROLE_POPUP:
 | 
					 | 
				
			||||||
		fprintf(stderr, "? ");
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	fprintf(stderr, "                   %p %s", (void *)view,
 | 
					 | 
				
			||||||
		view->xdg_surface->toplevel->app_id);
 | 
					 | 
				
			||||||
	fprintf(stderr, "  {%d, %d, %d, %d}\n", view->xdg_surface->geometry.x,
 | 
					 | 
				
			||||||
		view->xdg_surface->geometry.y,
 | 
					 | 
				
			||||||
		view->xdg_surface->geometry.height,
 | 
					 | 
				
			||||||
		view->xdg_surface->geometry.width);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void xwl_debug_show_one_view(struct view *view)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	fprintf(stderr, "XWL  ");
 | 
					 | 
				
			||||||
	if (!view->been_mapped) {
 | 
					 | 
				
			||||||
		fprintf(stderr, "- ");
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		fprintf(stderr, "%d ", xwl_nr_parents(view));
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	fprintf(stderr, "     %d      ",
 | 
					 | 
				
			||||||
		wl_list_length(&view->xwayland_surface->children));
 | 
					 | 
				
			||||||
	if (view->mapped) {
 | 
					 | 
				
			||||||
		fprintf(stderr, "Y");
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		fprintf(stderr, "-");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	fprintf(stderr, "      %p %s {%d,%d,%d,%d}\n", (void *)view,
 | 
					 | 
				
			||||||
		view->xwayland_surface->class, view->xwayland_surface->x,
 | 
					 | 
				
			||||||
		view->xwayland_surface->y, view->xwayland_surface->width,
 | 
					 | 
				
			||||||
		view->xwayland_surface->height);
 | 
					 | 
				
			||||||
	/*
 | 
					 | 
				
			||||||
	 * Other variables to consider printing:
 | 
					 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * view->mapped,
 | 
					 | 
				
			||||||
	 * view->been_mapped,
 | 
					 | 
				
			||||||
	 * view->xwayland_surface->override_redirect,
 | 
					 | 
				
			||||||
	 * wlr_xwayland_or_surface_wants_focus(view->xwayland_surface));
 | 
					 | 
				
			||||||
	 * view->xwayland_surface->saved_width,
 | 
					 | 
				
			||||||
	 * view->xwayland_surface->saved_height);
 | 
					 | 
				
			||||||
	 * view->xwayland_surface->surface->sx,
 | 
					 | 
				
			||||||
	 * view->xwayland_surface->surface->sy);
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void debug_show_one_view(struct view *view)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (view->type == LAB_XDG_SHELL_VIEW)
 | 
					 | 
				
			||||||
		xdg_debug_show_one_view(view);
 | 
					 | 
				
			||||||
	else if (view->type == LAB_XWAYLAND_VIEW)
 | 
					 | 
				
			||||||
		xwl_debug_show_one_view(view);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void debug_show_views(struct server *server)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct view *view;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	fprintf(stderr, "---\n");
 | 
					 | 
				
			||||||
	fprintf(stderr, "TYPE NR_PNT NR_CLD MAPPED VIEW-POINTER   NAME\n");
 | 
					 | 
				
			||||||
	wl_list_for_each_reverse (view, &server->views, link)
 | 
					 | 
				
			||||||
		debug_show_one_view(view);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static bool handle_keybinding(struct server *server, xkb_keysym_t sym)
 | 
					static bool handle_keybinding(struct server *server, xkb_keysym_t sym)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
| 
						 | 
					@ -150,7 +77,7 @@ static bool handle_keybinding(struct server *server, xkb_keysym_t sym)
 | 
				
			||||||
				  0);
 | 
									  0);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case XKB_KEY_F12:
 | 
						case XKB_KEY_F12:
 | 
				
			||||||
		debug_show_views(server);
 | 
							dbg_show_views(server);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue