mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	Add action.c
This commit is contained in:
		
							parent
							
								
									1e342f8976
								
							
						
					
					
						commit
						7440919452
					
				
					 10 changed files with 30 additions and 28 deletions
				
			
		| 
						 | 
				
			
			@ -29,6 +29,8 @@
 | 
			
		|||
#include <wlr/xwayland.h>
 | 
			
		||||
#include <xkbcommon/xkbcommon.h>
 | 
			
		||||
 | 
			
		||||
#include "rcxml.h"
 | 
			
		||||
 | 
			
		||||
#define XCURSOR_DEFAULT "left_ptr"
 | 
			
		||||
#define XCURSOR_SIZE 24
 | 
			
		||||
#define XCURSOR_MOVE "grabbing"
 | 
			
		||||
| 
						 | 
				
			
			@ -176,6 +178,8 @@ struct wlr_box deco_max_extents(struct view *view);
 | 
			
		|||
struct wlr_box deco_box(struct view *view, enum deco_part deco_part);
 | 
			
		||||
enum deco_part deco_at(struct view *view, double lx, double ly);
 | 
			
		||||
 | 
			
		||||
void action(struct server *server, struct keybind *keybind);
 | 
			
		||||
 | 
			
		||||
void dbg_show_one_view(struct view *view);
 | 
			
		||||
void dbg_show_views(struct server *server);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										22
									
								
								src/action.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/action.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,22 @@
 | 
			
		|||
#include "labwc.h"
 | 
			
		||||
 | 
			
		||||
#include <strings.h>
 | 
			
		||||
 | 
			
		||||
void action(struct server *server, struct keybind *keybind)
 | 
			
		||||
{
 | 
			
		||||
	if (!keybind || !keybind->action)
 | 
			
		||||
		return;
 | 
			
		||||
	if (!strcasecmp(keybind->action, "Exit")) {
 | 
			
		||||
		wl_display_terminate(server->wl_display);
 | 
			
		||||
	} else if (!strcasecmp(keybind->action, "NextWindow")) {
 | 
			
		||||
		server->cycle_view = next_toplevel(view_front_toplevel(server));
 | 
			
		||||
	} else if (!strcasecmp(keybind->action, "Execute")) {
 | 
			
		||||
		if (!fork())
 | 
			
		||||
			execl("/bin/dmenu_run", "/bin/dmenu_run", (void *)NULL);
 | 
			
		||||
	} else if (!strcasecmp(keybind->action, "debug-views")) {
 | 
			
		||||
		dbg_show_views(server);
 | 
			
		||||
	} else {
 | 
			
		||||
		fprintf(stderr, "warn: action (%s) not supported\n",
 | 
			
		||||
			keybind->action);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -56,9 +56,9 @@ void keybind_add(struct wl_list *keybinds, const char *keybind,
 | 
			
		|||
 | 
			
		||||
void keybind_init()
 | 
			
		||||
{
 | 
			
		||||
	keybind_add(&rc.keybinds, "A-Escape", "exit");
 | 
			
		||||
	keybind_add(&rc.keybinds, "A-Tab", "cycle");
 | 
			
		||||
	keybind_add(&rc.keybinds, "A-F3", "exec");
 | 
			
		||||
	keybind_add(&rc.keybinds, "A-Escape", "Exit");
 | 
			
		||||
	keybind_add(&rc.keybinds, "A-Tab", "NextWindow");
 | 
			
		||||
	keybind_add(&rc.keybinds, "A-F3", "Execute");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void keybind_print()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,4 @@
 | 
			
		|||
#include "labwc.h"
 | 
			
		||||
#include "rcxml.h"
 | 
			
		||||
 | 
			
		||||
static void keyboard_handle_modifiers(struct wl_listener *listener, void *data)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -21,25 +20,6 @@ static void keyboard_handle_modifiers(struct wl_listener *listener, void *data)
 | 
			
		|||
		keyboard->server->seat, &keyboard->device->keyboard->modifiers);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void action(struct server *server, struct keybind *keybind)
 | 
			
		||||
{
 | 
			
		||||
	if (!keybind || !keybind->action)
 | 
			
		||||
		return;
 | 
			
		||||
	if (!strcmp(keybind->action, "exit")) {
 | 
			
		||||
		wl_display_terminate(server->wl_display);
 | 
			
		||||
	} else if (!strcmp(keybind->action, "cycle")) {
 | 
			
		||||
		server->cycle_view = next_toplevel(view_front_toplevel(server));
 | 
			
		||||
	} else if (!strcmp(keybind->action, "exec")) {
 | 
			
		||||
		if (!fork())
 | 
			
		||||
			execl("/bin/dmenu_run", "/bin/dmenu_run", (void *)NULL);
 | 
			
		||||
	} else if (!strcmp(keybind->action, "debug-views")) {
 | 
			
		||||
		dbg_show_views(server);
 | 
			
		||||
	} else {
 | 
			
		||||
		fprintf(stderr, "warn: action (%s) not supported\n",
 | 
			
		||||
			keybind->action);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool handle_keybinding(struct server *server, uint32_t modifiers,
 | 
			
		||||
			      xkb_keysym_t sym)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,4 @@
 | 
			
		|||
#include "labwc.h"
 | 
			
		||||
#include "rcxml.h"
 | 
			
		||||
#include "theme.h"
 | 
			
		||||
 | 
			
		||||
struct server server = { 0 };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
labwc_sources = files(
 | 
			
		||||
  'action.c',
 | 
			
		||||
  'cursor.c',
 | 
			
		||||
  'deco.c',
 | 
			
		||||
  'interactive.c',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,4 @@
 | 
			
		|||
#include "labwc.h"
 | 
			
		||||
#include "rcxml.h"
 | 
			
		||||
#include "theme.h"
 | 
			
		||||
 | 
			
		||||
struct draw_data {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,4 @@
 | 
			
		|||
#include "labwc.h"
 | 
			
		||||
#include "rcxml.h"
 | 
			
		||||
 | 
			
		||||
#include <wlr/types/wlr_export_dmabuf_v1.h>
 | 
			
		||||
#include <wlr/types/wlr_screencopy_v1.h>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,4 @@
 | 
			
		|||
#include "labwc.h"
 | 
			
		||||
#include "rcxml.h"
 | 
			
		||||
 | 
			
		||||
static bool is_toplevel(struct view *view)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,4 @@
 | 
			
		|||
#include "labwc.h"
 | 
			
		||||
#include "rcxml.h"
 | 
			
		||||
 | 
			
		||||
struct xdg_deco {
 | 
			
		||||
	struct wlr_xdg_toplevel_decoration_v1 *wlr_decoration;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue