aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-08-02 23:49:25 +0100
committerLibravatar GitHub <noreply@github.com>2018-08-02 23:49:25 +0100
commit3a54e2291c017397ceff60511c29fe70d229bc8b (patch)
treed340b7776f945462f5ecffc830ada4d5fbe82f51 /include
parentEnable wlr-gamma-control-unstable-v1 (diff)
parentMerge pull request #2411 from emersion/fullscreen-pointer-input (diff)
downloadsway-3a54e2291c017397ceff60511c29fe70d229bc8b.tar.gz
sway-3a54e2291c017397ceff60511c29fe70d229bc8b.tar.zst
sway-3a54e2291c017397ceff60511c29fe70d229bc8b.zip
Merge branch 'master' into wlr-gamma-control
Diffstat (limited to 'include')
-rw-r--r--include/ipc.h5
-rw-r--r--include/sway/commands.h4
-rw-r--r--include/sway/config.h38
-rw-r--r--include/sway/criteria.h3
-rw-r--r--include/sway/desktop/transaction.h13
-rw-r--r--include/sway/input/cursor.h10
-rw-r--r--include/sway/input/input-manager.h3
-rw-r--r--include/sway/input/keyboard.h3
-rw-r--r--include/sway/input/seat.h35
-rw-r--r--include/sway/ipc-server.h2
-rw-r--r--include/sway/output.h52
-rw-r--r--include/sway/scratchpad.h26
-rw-r--r--include/sway/server.h10
-rw-r--r--include/sway/tree/container.h66
-rw-r--r--include/sway/tree/layout.h15
-rw-r--r--include/sway/tree/view.h59
-rw-r--r--include/sway/tree/workspace.h6
-rw-r--r--include/swaygrab/json.h10
-rw-r--r--include/swaynag/config.h13
-rw-r--r--include/swaynag/render.h7
-rw-r--r--include/swaynag/swaynag.h100
-rw-r--r--include/swaynag/types.h39
-rw-r--r--include/util.h9
23 files changed, 425 insertions, 103 deletions
diff --git a/include/ipc.h b/include/ipc.h
index 0010718b..a3f60e19 100644
--- a/include/ipc.h
+++ b/include/ipc.h
@@ -15,6 +15,7 @@ enum ipc_command_type {
15 IPC_GET_VERSION = 7, 15 IPC_GET_VERSION = 7,
16 IPC_GET_BINDING_MODES = 8, 16 IPC_GET_BINDING_MODES = 8,
17 IPC_GET_CONFIG = 9, 17 IPC_GET_CONFIG = 9,
18 IPC_SEND_TICK = 10,
18 19
19 // sway-specific command types 20 // sway-specific command types
20 IPC_GET_INPUTS = 100, 21 IPC_GET_INPUTS = 100,
@@ -27,8 +28,8 @@ enum ipc_command_type {
27 IPC_EVENT_WINDOW = ((1<<31) | 3), 28 IPC_EVENT_WINDOW = ((1<<31) | 3),
28 IPC_EVENT_BARCONFIG_UPDATE = ((1<<31) | 4), 29 IPC_EVENT_BARCONFIG_UPDATE = ((1<<31) | 4),
29 IPC_EVENT_BINDING = ((1<<31) | 5), 30 IPC_EVENT_BINDING = ((1<<31) | 5),
30 IPC_EVENT_MODIFIER = ((1<<31) | 6), 31 IPC_EVENT_SHUTDOWN = ((1<<31) | 6),
31 IPC_EVENT_INPUT = ((1<<31) | 7), 32 IPC_EVENT_TICK = ((1<<31) | 7),
32}; 33};
33 34
34#endif 35#endif
diff --git a/include/sway/commands.h b/include/sway/commands.h
index e71a7228..41858ccc 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -106,7 +106,7 @@ sway_cmd cmd_exit;
106sway_cmd cmd_floating; 106sway_cmd cmd_floating;
107sway_cmd cmd_floating_maximum_size; 107sway_cmd cmd_floating_maximum_size;
108sway_cmd cmd_floating_minimum_size; 108sway_cmd cmd_floating_minimum_size;
109sway_cmd cmd_floating_mod; 109sway_cmd cmd_floating_modifier;
110sway_cmd cmd_floating_scroll; 110sway_cmd cmd_floating_scroll;
111sway_cmd cmd_focus; 111sway_cmd cmd_focus;
112sway_cmd cmd_focus_follows_mouse; 112sway_cmd cmd_focus_follows_mouse;
@@ -213,8 +213,10 @@ sway_cmd input_cmd_scroll_button;
213sway_cmd input_cmd_scroll_method; 213sway_cmd input_cmd_scroll_method;
214sway_cmd input_cmd_tap; 214sway_cmd input_cmd_tap;
215sway_cmd input_cmd_tap_button_map; 215sway_cmd input_cmd_tap_button_map;
216sway_cmd input_cmd_xkb_capslock;
216sway_cmd input_cmd_xkb_layout; 217sway_cmd input_cmd_xkb_layout;
217sway_cmd input_cmd_xkb_model; 218sway_cmd input_cmd_xkb_model;
219sway_cmd input_cmd_xkb_numlock;
218sway_cmd input_cmd_xkb_options; 220sway_cmd input_cmd_xkb_options;
219sway_cmd input_cmd_xkb_rules; 221sway_cmd input_cmd_xkb_rules;
220sway_cmd input_cmd_xkb_variant; 222sway_cmd input_cmd_xkb_variant;
diff --git a/include/sway/config.h b/include/sway/config.h
index b8da29c5..909b6827 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -1,6 +1,5 @@
1#ifndef _SWAY_CONFIG_H 1#ifndef _SWAY_CONFIG_H
2#define _SWAY_CONFIG_H 2#define _SWAY_CONFIG_H
3#define PID_WORKSPACE_TIMEOUT 60
4#include <libinput.h> 3#include <libinput.h>
5#include <stdint.h> 4#include <stdint.h>
6#include <string.h> 5#include <string.h>
@@ -22,14 +21,28 @@ struct sway_variable {
22 char *value; 21 char *value;
23}; 22};
24 23
24
25enum binding_input_type {
26 BINDING_KEYCODE,
27 BINDING_KEYSYM,
28 BINDING_MOUSE,
29};
30
31enum binding_flags {
32 BINDING_RELEASE=1,
33 BINDING_LOCKED=2, // keyboard only
34 BINDING_BORDER=4, // mouse only; trigger on container border
35 BINDING_CONTENTS=8, // mouse only; trigger on container contents
36 BINDING_TITLEBAR=16 // mouse only; trigger on container titlebar
37};
38
25/** 39/**
26 * A key binding and an associated command. 40 * A key binding and an associated command.
27 */ 41 */
28struct sway_binding { 42struct sway_binding {
43 enum binding_input_type type;
29 int order; 44 int order;
30 bool release; 45 uint32_t flags;
31 bool locked;
32 bool bindcode;
33 list_t *keys; // sorted in ascending order 46 list_t *keys; // sorted in ascending order
34 uint32_t modifiers; 47 uint32_t modifiers;
35 char *command; 48 char *command;
@@ -50,6 +63,7 @@ struct sway_mode {
50 char *name; 63 char *name;
51 list_t *keysym_bindings; 64 list_t *keysym_bindings;
52 list_t *keycode_bindings; 65 list_t *keycode_bindings;
66 list_t *mouse_bindings;
53 bool pango; 67 bool pango;
54}; 68};
55 69
@@ -87,6 +101,9 @@ struct input_config {
87 char *xkb_rules; 101 char *xkb_rules;
88 char *xkb_variant; 102 char *xkb_variant;
89 103
104 int xkb_numlock;
105 int xkb_capslock;
106
90 struct input_config_mapped_from_region *mapped_from_region; 107 struct input_config_mapped_from_region *mapped_from_region;
91 char *mapped_to_output; 108 char *mapped_to_output;
92 109
@@ -146,12 +163,6 @@ struct workspace_output {
146 char *workspace; 163 char *workspace;
147}; 164};
148 165
149struct pid_workspace {
150 pid_t *pid;
151 char *workspace;
152 time_t *time_added;
153};
154
155struct bar_config { 166struct bar_config {
156 /** 167 /**
157 * One of "dock", "hide", "invisible" 168 * One of "dock", "hide", "invisible"
@@ -302,7 +313,6 @@ struct sway_config {
302 list_t *bars; 313 list_t *bars;
303 list_t *cmd_queue; 314 list_t *cmd_queue;
304 list_t *workspace_outputs; 315 list_t *workspace_outputs;
305 list_t *pid_workspaces;
306 list_t *output_configs; 316 list_t *output_configs;
307 list_t *input_configs; 317 list_t *input_configs;
308 list_t *seat_configs; 318 list_t *seat_configs;
@@ -313,6 +323,7 @@ struct sway_config {
313 struct bar_config *current_bar; 323 struct bar_config *current_bar;
314 char *swaybg_command; 324 char *swaybg_command;
315 uint32_t floating_mod; 325 uint32_t floating_mod;
326 bool floating_mod_inverse;
316 uint32_t dragging_key; 327 uint32_t dragging_key;
317 uint32_t resizing_key; 328 uint32_t resizing_key;
318 char *floating_scroll_up_cmd; 329 char *floating_scroll_up_cmd;
@@ -388,9 +399,6 @@ struct sway_config {
388 } handler_context; 399 } handler_context;
389}; 400};
390 401
391void pid_workspace_add(struct pid_workspace *pw);
392void free_pid_workspace(struct pid_workspace *pw);
393
394/** 402/**
395 * Loads the main config from the given path. is_active should be true when 403 * Loads the main config from the given path. is_active should be true when
396 * reloading the config. 404 * reloading the config.
@@ -480,7 +488,7 @@ int sway_binding_cmp_keys(const void *a, const void *b);
480 488
481void free_sway_binding(struct sway_binding *sb); 489void free_sway_binding(struct sway_binding *sb);
482 490
483struct sway_binding *sway_binding_dup(struct sway_binding *sb); 491void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding);
484 492
485void load_swaybars(); 493void load_swaybars();
486 494
diff --git a/include/sway/criteria.h b/include/sway/criteria.h
index 6a8337c5..b4ff7d49 100644
--- a/include/sway/criteria.h
+++ b/include/sway/criteria.h
@@ -2,6 +2,7 @@
2#define _SWAY_CRITERIA_H 2#define _SWAY_CRITERIA_H
3 3
4#include <pcre.h> 4#include <pcre.h>
5#include "config.h"
5#include "list.h" 6#include "list.h"
6#include "tree/view.h" 7#include "tree/view.h"
7 8
@@ -25,7 +26,9 @@ struct criteria {
25 pcre *instance; 26 pcre *instance;
26 pcre *con_mark; 27 pcre *con_mark;
27 uint32_t con_id; // internal ID 28 uint32_t con_id; // internal ID
29#ifdef HAVE_XWAYLAND
28 uint32_t id; // X11 window ID 30 uint32_t id; // X11 window ID
31#endif
29 pcre *window_role; 32 pcre *window_role;
30 uint32_t window_type; 33 uint32_t window_type;
31 bool floating; 34 bool floating;
diff --git a/include/sway/desktop/transaction.h b/include/sway/desktop/transaction.h
index cee4afed..56361d94 100644
--- a/include/sway/desktop/transaction.h
+++ b/include/sway/desktop/transaction.h
@@ -42,17 +42,4 @@ void transaction_notify_view_ready(struct sway_view *view, uint32_t serial);
42void transaction_notify_view_ready_by_size(struct sway_view *view, 42void transaction_notify_view_ready_by_size(struct sway_view *view,
43 int width, int height); 43 int width, int height);
44 44
45/**
46 * Get the saved texture that should be rendered for a view.
47 *
48 * The addresses pointed at by the width and height pointers will be populated
49 * with the surface's dimensions, which may be different to the texture's
50 * dimensions if output scaling is used.
51 *
52 * This function should only be called if it is known that the view has
53 * instructions.
54 */
55struct wlr_texture *transaction_get_saved_texture(struct sway_view *view,
56 int *width, int *height);
57
58#endif 45#endif
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h
index 5dd109ca..7ec45120 100644
--- a/include/sway/input/cursor.h
+++ b/include/sway/input/cursor.h
@@ -3,6 +3,8 @@
3#include <stdint.h> 3#include <stdint.h>
4#include "sway/input/seat.h" 4#include "sway/input/seat.h"
5 5
6#define SWAY_CURSOR_PRESSED_BUTTONS_CAP 32
7
6struct sway_cursor { 8struct sway_cursor {
7 struct sway_seat *seat; 9 struct sway_seat *seat;
8 struct wlr_cursor *cursor; 10 struct wlr_cursor *cursor;
@@ -11,6 +13,7 @@ struct sway_cursor {
11 } previous; 13 } previous;
12 struct wlr_xcursor_manager *xcursor_manager; 14 struct wlr_xcursor_manager *xcursor_manager;
13 15
16 const char *image;
14 struct wl_client *image_client; 17 struct wl_client *image_client;
15 18
16 struct wl_listener motion; 19 struct wl_listener motion;
@@ -28,6 +31,10 @@ struct sway_cursor {
28 uint32_t tool_buttons; 31 uint32_t tool_buttons;
29 32
30 struct wl_listener request_set_cursor; 33 struct wl_listener request_set_cursor;
34
35 // Mouse binding state
36 uint32_t pressed_buttons[SWAY_CURSOR_PRESSED_BUTTONS_CAP];
37 size_t pressed_button_count;
31}; 38};
32 39
33void sway_cursor_destroy(struct sway_cursor *cursor); 40void sway_cursor_destroy(struct sway_cursor *cursor);
@@ -37,4 +44,7 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
37void dispatch_cursor_button(struct sway_cursor *cursor, uint32_t time_msec, 44void dispatch_cursor_button(struct sway_cursor *cursor, uint32_t time_msec,
38 uint32_t button, enum wlr_button_state state); 45 uint32_t button, enum wlr_button_state state);
39 46
47void cursor_set_image(struct sway_cursor *cursor, const char *image,
48 struct wl_client *client);
49
40#endif 50#endif
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h
index 89a3ac71..aa2f6f19 100644
--- a/include/sway/input/input-manager.h
+++ b/include/sway/input/input-manager.h
@@ -2,6 +2,7 @@
2#define _SWAY_INPUT_INPUT_MANAGER_H 2#define _SWAY_INPUT_INPUT_MANAGER_H
3#include <libinput.h> 3#include <libinput.h>
4#include <wlr/types/wlr_input_inhibitor.h> 4#include <wlr/types/wlr_input_inhibitor.h>
5#include <wlr/types/wlr_virtual_keyboard_v1.h>
5#include "sway/server.h" 6#include "sway/server.h"
6#include "sway/config.h" 7#include "sway/config.h"
7#include "list.h" 8#include "list.h"
@@ -25,10 +26,12 @@ struct sway_input_manager {
25 struct wl_list seats; 26 struct wl_list seats;
26 27
27 struct wlr_input_inhibit_manager *inhibit; 28 struct wlr_input_inhibit_manager *inhibit;
29 struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard;
28 30
29 struct wl_listener new_input; 31 struct wl_listener new_input;
30 struct wl_listener inhibit_activate; 32 struct wl_listener inhibit_activate;
31 struct wl_listener inhibit_deactivate; 33 struct wl_listener inhibit_deactivate;
34 struct wl_listener virtual_keyboard_new;
32}; 35};
33 36
34struct sway_input_manager *input_manager_create(struct sway_server *server); 37struct sway_input_manager *input_manager_create(struct sway_server *server);
diff --git a/include/sway/input/keyboard.h b/include/sway/input/keyboard.h
index 6713398e..6d28454c 100644
--- a/include/sway/input/keyboard.h
+++ b/include/sway/input/keyboard.h
@@ -38,6 +38,9 @@ struct sway_keyboard {
38 struct sway_shortcut_state state_keysyms_raw; 38 struct sway_shortcut_state state_keysyms_raw;
39 struct sway_shortcut_state state_keycodes; 39 struct sway_shortcut_state state_keycodes;
40 struct sway_binding *held_binding; 40 struct sway_binding *held_binding;
41
42 struct wl_event_source *key_repeat_source;
43 struct sway_binding *repeat_binding;
41}; 44};
42 45
43struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat, 46struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat,
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h
index eac1626b..92387601 100644
--- a/include/sway/input/seat.h
+++ b/include/sway/input/seat.h
@@ -3,6 +3,7 @@
3 3
4#include <wlr/types/wlr_layer_shell.h> 4#include <wlr/types/wlr_layer_shell.h>
5#include <wlr/types/wlr_seat.h> 5#include <wlr/types/wlr_seat.h>
6#include <wlr/util/edges.h>
6#include "sway/input/input-manager.h" 7#include "sway/input/input-manager.h"
7 8
8struct sway_seat_device { 9struct sway_seat_device {
@@ -52,6 +53,24 @@ struct sway_seat {
52 int32_t touch_id; 53 int32_t touch_id;
53 double touch_x, touch_y; 54 double touch_x, touch_y;
54 55
56 // Operations (drag and resize)
57 enum {
58 OP_NONE,
59 OP_MOVE,
60 OP_RESIZE,
61 } operation;
62
63 struct sway_container *op_container;
64 enum wlr_edges op_resize_edge;
65 uint32_t op_button;
66 bool op_resize_preserve_ratio;
67 double op_ref_lx, op_ref_ly; // cursor's x/y at start of op
68 double op_ref_width, op_ref_height; // container's size at start of op
69 double op_ref_con_lx, op_ref_con_ly; // container's x/y at start of op
70
71 uint32_t last_button;
72 uint32_t last_button_serial;
73
55 struct wl_listener focus_destroy; 74 struct wl_listener focus_destroy;
56 struct wl_listener new_container; 75 struct wl_listener new_container;
57 struct wl_listener new_drag_icon; 76 struct wl_listener new_drag_icon;
@@ -80,7 +99,7 @@ void seat_configure_xcursor(struct sway_seat *seat);
80void seat_set_focus(struct sway_seat *seat, struct sway_container *container); 99void seat_set_focus(struct sway_seat *seat, struct sway_container *container);
81 100
82void seat_set_focus_warp(struct sway_seat *seat, 101void seat_set_focus_warp(struct sway_seat *seat,
83 struct sway_container *container, bool warp); 102 struct sway_container *container, bool warp, bool notify);
84 103
85void seat_set_focus_surface(struct sway_seat *seat, 104void seat_set_focus_surface(struct sway_seat *seat,
86 struct wlr_surface *surface, bool unfocus); 105 struct wlr_surface *surface, bool unfocus);
@@ -105,6 +124,9 @@ struct sway_container *seat_get_focus(struct sway_seat *seat);
105struct sway_container *seat_get_focus_inactive(struct sway_seat *seat, 124struct sway_container *seat_get_focus_inactive(struct sway_seat *seat,
106 struct sway_container *container); 125 struct sway_container *container);
107 126
127struct sway_container *seat_get_focus_inactive_tiling(struct sway_seat *seat,
128 struct sway_container *container);
129
108/** 130/**
109 * Descend into the focus stack to find the focus-inactive view. Useful for 131 * Descend into the focus stack to find the focus-inactive view. Useful for
110 * container placement when they change position in the tree. 132 * container placement when they change position in the tree.
@@ -134,4 +156,15 @@ bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface);
134 156
135void drag_icon_update_position(struct sway_drag_icon *icon); 157void drag_icon_update_position(struct sway_drag_icon *icon);
136 158
159void seat_begin_move(struct sway_seat *seat, struct sway_container *con,
160 uint32_t button);
161
162void seat_begin_resize(struct sway_seat *seat, struct sway_container *con,
163 uint32_t button, enum wlr_edges edge);
164
165void seat_end_mouse_operation(struct sway_seat *seat);
166
167void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec,
168 uint32_t button, enum wlr_button_state state);
169
137#endif 170#endif
diff --git a/include/sway/ipc-server.h b/include/sway/ipc-server.h
index 6469f097..4b6d0e25 100644
--- a/include/sway/ipc-server.h
+++ b/include/sway/ipc-server.h
@@ -16,5 +16,7 @@ void ipc_event_workspace(struct sway_container *old,
16void ipc_event_window(struct sway_container *window, const char *change); 16void ipc_event_window(struct sway_container *window, const char *change);
17void ipc_event_barconfig_update(struct bar_config *bar); 17void ipc_event_barconfig_update(struct bar_config *bar);
18void ipc_event_mode(const char *mode, bool pango); 18void ipc_event_mode(const char *mode, bool pango);
19void ipc_event_shutdown(const char *reason);
20void ipc_event_binding(struct sway_binding *binding);
19 21
20#endif 22#endif
diff --git a/include/sway/output.h b/include/sway/output.h
index b6cda83c..80dcd37b 100644
--- a/include/sway/output.h
+++ b/include/sway/output.h
@@ -5,6 +5,7 @@
5#include <wayland-server.h> 5#include <wayland-server.h>
6#include <wlr/types/wlr_box.h> 6#include <wlr/types/wlr_box.h>
7#include <wlr/types/wlr_output.h> 7#include <wlr/types/wlr_output.h>
8#include "config.h"
8#include "sway/tree/view.h" 9#include "sway/tree/view.h"
9 10
10struct sway_server; 11struct sway_server;
@@ -38,15 +39,9 @@ struct sway_output {
38 } events; 39 } events;
39}; 40};
40 41
41/** 42typedef void (*sway_surface_iterator_func_t)(struct sway_output *output,
42 * Contains a surface's root geometry information. For instance, when rendering 43 struct wlr_surface *surface, struct wlr_box *box, float rotation,
43 * a popup, this will contain the parent view's position and size. 44 void *user_data);
44 */
45struct root_geometry {
46 double x, y;
47 int width, height;
48 float rotation;
49};
50 45
51void output_damage_whole(struct sway_output *output); 46void output_damage_whole(struct sway_output *output);
52 47
@@ -65,36 +60,37 @@ struct sway_container *output_by_name(const char *name);
65 60
66void output_enable(struct sway_output *output); 61void output_enable(struct sway_output *output);
67 62
68bool output_has_opaque_lockscreen(struct sway_output *output, 63bool output_has_opaque_overlay_layer_surface(struct sway_output *output);
69 struct sway_seat *seat);
70 64
71struct sway_container *output_get_active_workspace(struct sway_output *output); 65struct sway_container *output_get_active_workspace(struct sway_output *output);
72 66
73void output_render(struct sway_output *output, struct timespec *when, 67void output_render(struct sway_output *output, struct timespec *when,
74 pixman_region32_t *damage); 68 pixman_region32_t *damage);
75 69
76bool output_get_surface_box(struct root_geometry *geo, 70void output_surface_for_each_surface(struct sway_output *output,
77 struct sway_output *output, struct wlr_surface *surface, int sx, int sy, 71 struct wlr_surface *surface, double ox, double oy,
78 struct wlr_box *surface_box); 72 sway_surface_iterator_func_t iterator, void *user_data);
79 73
80void output_surface_for_each_surface(struct wlr_surface *surface, 74void output_view_for_each_surface(struct sway_output *output,
81 double ox, double oy, struct root_geometry *geo, 75 struct sway_view *view, sway_surface_iterator_func_t iterator,
82 wlr_surface_iterator_func_t iterator, void *user_data); 76 void *user_data);
83 77
84void output_view_for_each_surface(struct sway_view *view, 78void output_view_for_each_popup(struct sway_output *output,
85 struct sway_output *output, struct root_geometry *geo, 79 struct sway_view *view, sway_surface_iterator_func_t iterator,
86 wlr_surface_iterator_func_t iterator, void *user_data); 80 void *user_data);
87 81
88void output_layer_for_each_surface(struct wl_list *layer_surfaces, 82void output_layer_for_each_surface(struct sway_output *output,
89 struct root_geometry *geo, wlr_surface_iterator_func_t iterator, 83 struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
90 void *user_data); 84 void *user_data);
91 85
92void output_unmanaged_for_each_surface(struct wl_list *unmanaged, 86#ifdef HAVE_XWAYLAND
93 struct sway_output *output, struct root_geometry *geo, 87void output_unmanaged_for_each_surface(struct sway_output *output,
94 wlr_surface_iterator_func_t iterator, void *user_data); 88 struct wl_list *unmanaged, sway_surface_iterator_func_t iterator,
89 void *user_data);
90#endif
95 91
96void output_drag_icons_for_each_surface(struct wl_list *drag_icons, 92void output_drag_icons_for_each_surface(struct sway_output *output,
97 struct sway_output *output, struct root_geometry *geo, 93 struct wl_list *drag_icons, sway_surface_iterator_func_t iterator,
98 wlr_surface_iterator_func_t iterator, void *user_data); 94 void *user_data);
99 95
100#endif 96#endif
diff --git a/include/sway/scratchpad.h b/include/sway/scratchpad.h
new file mode 100644
index 00000000..5af5256f
--- /dev/null
+++ b/include/sway/scratchpad.h
@@ -0,0 +1,26 @@
1#ifndef _SWAY_SCRATCHPAD_H
2#define _SWAY_SCRATCHPAD_H
3
4#include "tree/container.h"
5
6/**
7 * Move a container to the scratchpad.
8 */
9void scratchpad_add_container(struct sway_container *con);
10
11/**
12 * Remove a container from the scratchpad.
13 */
14void scratchpad_remove_container(struct sway_container *con);
15
16/**
17 * Show or hide the next container on the scratchpad.
18 */
19void scratchpad_toggle_auto(void);
20
21/**
22 * Show or hide a specific container on the scratchpad.
23 */
24void scratchpad_toggle_container(struct sway_container *con);
25
26#endif
diff --git a/include/sway/server.h b/include/sway/server.h
index 70bde6d4..a3782f91 100644
--- a/include/sway/server.h
+++ b/include/sway/server.h
@@ -12,7 +12,10 @@
12#include <wlr/render/wlr_renderer.h> 12#include <wlr/render/wlr_renderer.h>
13// TODO WLR: make Xwayland optional 13// TODO WLR: make Xwayland optional
14#include "list.h" 14#include "list.h"
15#include "config.h"
16#ifdef HAVE_XWAYLAND
15#include "sway/xwayland.h" 17#include "sway/xwayland.h"
18#endif
16 19
17struct sway_server { 20struct sway_server {
18 struct wl_display *wl_display; 21 struct wl_display *wl_display;
@@ -39,11 +42,11 @@ struct sway_server {
39 42
40 struct wlr_xdg_shell *xdg_shell; 43 struct wlr_xdg_shell *xdg_shell;
41 struct wl_listener xdg_shell_surface; 44 struct wl_listener xdg_shell_surface;
42 45#ifdef HAVE_XWAYLAND
43 struct sway_xwayland xwayland; 46 struct sway_xwayland xwayland;
44 struct wl_listener xwayland_surface; 47 struct wl_listener xwayland_surface;
45 struct wl_listener xwayland_ready; 48 struct wl_listener xwayland_ready;
46 49#endif
47 bool debug_txn_timings; 50 bool debug_txn_timings;
48 51
49 list_t *transactions; 52 list_t *transactions;
@@ -65,6 +68,7 @@ void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data);
65void handle_layer_shell_surface(struct wl_listener *listener, void *data); 68void handle_layer_shell_surface(struct wl_listener *listener, void *data);
66void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data); 69void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
67void handle_xdg_shell_surface(struct wl_listener *listener, void *data); 70void handle_xdg_shell_surface(struct wl_listener *listener, void *data);
71#ifdef HAVE_XWAYLAND
68void handle_xwayland_surface(struct wl_listener *listener, void *data); 72void handle_xwayland_surface(struct wl_listener *listener, void *data);
69 73#endif
70#endif 74#endif
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index ca7a3288..c3942e9e 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -60,6 +60,8 @@ struct sway_container_state {
60 double swayc_x, swayc_y; 60 double swayc_x, swayc_y;
61 double swayc_width, swayc_height; 61 double swayc_width, swayc_height;
62 62
63 bool is_fullscreen;
64
63 bool has_gaps; 65 bool has_gaps;
64 double current_gaps; 66 double current_gaps;
65 double gaps_inner; 67 double gaps_inner;
@@ -74,7 +76,6 @@ struct sway_container_state {
74 // View properties 76 // View properties
75 double view_x, view_y; 77 double view_x, view_y;
76 double view_width, view_height; 78 double view_width, view_height;
77 bool is_fullscreen;
78 79
79 enum sway_container_border border; 80 enum sway_container_border border;
80 int border_thickness; 81 int border_thickness;
@@ -84,7 +85,7 @@ struct sway_container_state {
84 bool border_right; 85 bool border_right;
85 86
86 // Workspace properties 87 // Workspace properties
87 struct sway_view *ws_fullscreen; 88 struct sway_container *ws_fullscreen;
88 struct sway_container *ws_floating; 89 struct sway_container *ws_floating;
89}; 90};
90 91
@@ -124,6 +125,8 @@ struct sway_container {
124 double saved_x, saved_y; 125 double saved_x, saved_y;
125 double saved_width, saved_height; 126 double saved_width, saved_height;
126 127
128 bool is_fullscreen;
129
127 // The gaps currently applied to the container. 130 // The gaps currently applied to the container.
128 double current_gaps; 131 double current_gaps;
129 132
@@ -135,6 +138,11 @@ struct sway_container {
135 138
136 struct sway_container *parent; 139 struct sway_container *parent;
137 140
141 // Indicates that the container is a scratchpad container.
142 // Both hidden and visible scratchpad containers have scratchpad=true.
143 // Hidden scratchpad containers have a NULL parent.
144 bool scratchpad;
145
138 float alpha; 146 float alpha;
139 147
140 struct wlr_texture *title_focused; 148 struct wlr_texture *title_focused;
@@ -222,16 +230,13 @@ struct sway_container *container_parent(struct sway_container *container,
222 * surface-local coordinates of the given layout coordinates if the container 230 * surface-local coordinates of the given layout coordinates if the container
223 * is a view and the view contains a surface at those coordinates. 231 * is a view and the view contains a surface at those coordinates.
224 */ 232 */
225struct sway_container *container_at(struct sway_container *container, 233struct sway_container *container_at(struct sway_container *workspace,
226 double ox, double oy, struct wlr_surface **surface, 234 double lx, double ly, struct wlr_surface **surface,
227 double *sx, double *sy); 235 double *sx, double *sy);
228 236
229/** 237struct sway_container *container_at_view(struct sway_container *view,
230 * Same as container_at, but only checks floating views and expects coordinates 238 double lx, double ly, struct wlr_surface **surface,
231 * to be layout coordinates, as that's what floating views use. 239 double *sx, double *sy);
232 */
233struct sway_container *floating_container_at(double lx, double ly,
234 struct wlr_surface **surface, double *sx, double *sy);
235 240
236/** 241/**
237 * Apply the function for each descendant of the container breadth first. 242 * Apply the function for each descendant of the container breadth first.
@@ -262,6 +267,8 @@ int container_count_descendants_of_type(struct sway_container *con,
262 267
263void container_create_notify(struct sway_container *container); 268void container_create_notify(struct sway_container *container);
264 269
270void container_update_textures_recursive(struct sway_container *con);
271
265void container_damage_whole(struct sway_container *container); 272void container_damage_whole(struct sway_container *container);
266 273
267bool container_reap_empty(struct sway_container *con); 274bool container_reap_empty(struct sway_container *con);
@@ -289,6 +296,11 @@ void container_notify_subtree_changed(struct sway_container *container);
289 */ 296 */
290size_t container_titlebar_height(void); 297size_t container_titlebar_height(void);
291 298
299/**
300 * Resize and center the container in its workspace.
301 */
302void container_init_floating(struct sway_container *container);
303
292void container_set_floating(struct sway_container *container, bool enable); 304void container_set_floating(struct sway_container *container, bool enable);
293 305
294void container_set_geometry_from_floating_view(struct sway_container *con); 306void container_set_geometry_from_floating_view(struct sway_container *con);
@@ -305,6 +317,12 @@ bool container_is_floating(struct sway_container *container);
305void container_get_box(struct sway_container *container, struct wlr_box *box); 317void container_get_box(struct sway_container *container, struct wlr_box *box);
306 318
307/** 319/**
320 * Move a floating container by the specified amount.
321 */
322void container_floating_translate(struct sway_container *con,
323 double x_amount, double y_amount);
324
325/**
308 * Move a floating container to a new layout-local position. 326 * Move a floating container to a new layout-local position.
309 */ 327 */
310void container_floating_move_to(struct sway_container *con, 328void container_floating_move_to(struct sway_container *con,
@@ -318,4 +336,32 @@ void container_set_dirty(struct sway_container *container);
318 336
319bool container_has_urgent_child(struct sway_container *container); 337bool container_has_urgent_child(struct sway_container *container);
320 338
339/**
340 * If the container is involved in a drag or resize operation via a mouse, this
341 * ends the operation.
342 */
343void container_end_mouse_operation(struct sway_container *container);
344
345void container_set_fullscreen(struct sway_container *container, bool enable);
346
347/**
348 * Return true if the container is floating, or a child of a floating split
349 * container.
350 */
351bool container_is_floating_or_child(struct sway_container *container);
352
353/**
354 * Return true if the container is fullscreen, or a child of a fullscreen split
355 * container.
356 */
357bool container_is_fullscreen_or_child(struct sway_container *container);
358
359/**
360 * Wrap the children of parent in a new container. The new container will be the
361 * only child of parent.
362 *
363 * The new container is returned.
364 */
365struct sway_container *container_wrap_children(struct sway_container *parent);
366
321#endif 367#endif
diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h
index ba265623..a4c31bf6 100644
--- a/include/sway/tree/layout.h
+++ b/include/sway/tree/layout.h
@@ -3,6 +3,7 @@
3#include <wlr/types/wlr_output_layout.h> 3#include <wlr/types/wlr_output_layout.h>
4#include <wlr/render/wlr_texture.h> 4#include <wlr/render/wlr_texture.h>
5#include "sway/tree/container.h" 5#include "sway/tree/container.h"
6#include "config.h"
6 7
7enum movement_direction { 8enum movement_direction {
8 MOVE_LEFT, 9 MOVE_LEFT,
@@ -14,10 +15,11 @@ enum movement_direction {
14}; 15};
15 16
16enum resize_edge { 17enum resize_edge {
17 RESIZE_EDGE_LEFT, 18 RESIZE_EDGE_NONE = 0,
18 RESIZE_EDGE_RIGHT, 19 RESIZE_EDGE_LEFT = 1,
19 RESIZE_EDGE_TOP, 20 RESIZE_EDGE_RIGHT = 2,
20 RESIZE_EDGE_BOTTOM, 21 RESIZE_EDGE_TOP = 4,
22 RESIZE_EDGE_BOTTOM = 8,
21}; 23};
22 24
23struct sway_container; 25struct sway_container;
@@ -26,14 +28,17 @@ struct sway_root {
26 struct wlr_output_layout *output_layout; 28 struct wlr_output_layout *output_layout;
27 29
28 struct wl_listener output_layout_change; 30 struct wl_listener output_layout_change;
29 31#ifdef HAVE_XWAYLAND
30 struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link 32 struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link
33#endif
31 struct wl_list drag_icons; // sway_drag_icon::link 34 struct wl_list drag_icons; // sway_drag_icon::link
32 35
33 struct wlr_texture *debug_tree; 36 struct wlr_texture *debug_tree;
34 37
35 struct wl_list outputs; // sway_output::link 38 struct wl_list outputs; // sway_output::link
36 39
40 list_t *scratchpad; // struct sway_container
41
37 struct { 42 struct {
38 struct wl_signal new_container; 43 struct wl_signal new_container;
39 } events; 44 } events;
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 068d92c6..37fd02bc 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -3,7 +3,10 @@
3#include <wayland-server.h> 3#include <wayland-server.h>
4#include <wlr/types/wlr_surface.h> 4#include <wlr/types/wlr_surface.h>
5#include <wlr/types/wlr_xdg_shell_v6.h> 5#include <wlr/types/wlr_xdg_shell_v6.h>
6#include "config.h"
7#ifdef HAVE_XWAYLAND
6#include <wlr/xwayland.h> 8#include <wlr/xwayland.h>
9#endif
7#include "sway/input/input-manager.h" 10#include "sway/input/input-manager.h"
8#include "sway/input/seat.h" 11#include "sway/input/seat.h"
9 12
@@ -12,7 +15,9 @@ struct sway_container;
12enum sway_view_type { 15enum sway_view_type {
13 SWAY_VIEW_XDG_SHELL_V6, 16 SWAY_VIEW_XDG_SHELL_V6,
14 SWAY_VIEW_XDG_SHELL, 17 SWAY_VIEW_XDG_SHELL,
18#ifdef HAVE_XWAYLAND
15 SWAY_VIEW_XWAYLAND, 19 SWAY_VIEW_XWAYLAND,
20#endif
16}; 21};
17 22
18enum sway_view_prop { 23enum sway_view_prop {
@@ -22,10 +27,14 @@ enum sway_view_prop {
22 VIEW_PROP_INSTANCE, 27 VIEW_PROP_INSTANCE,
23 VIEW_PROP_WINDOW_TYPE, 28 VIEW_PROP_WINDOW_TYPE,
24 VIEW_PROP_WINDOW_ROLE, 29 VIEW_PROP_WINDOW_ROLE,
30#ifdef HAVE_XWAYLAND
25 VIEW_PROP_X11_WINDOW_ID, 31 VIEW_PROP_X11_WINDOW_ID,
32#endif
26}; 33};
27 34
28struct sway_view_impl { 35struct sway_view_impl {
36 void (*get_constraints)(struct sway_view *view, double *min_width,
37 double *max_width, double *min_height, double *max_height);
29 const char *(*get_string_prop)(struct sway_view *view, 38 const char *(*get_string_prop)(struct sway_view *view,
30 enum sway_view_prop prop); 39 enum sway_view_prop prop);
31 uint32_t (*get_int_prop)(struct sway_view *view, enum sway_view_prop prop); 40 uint32_t (*get_int_prop)(struct sway_view *view, enum sway_view_prop prop);
@@ -38,7 +47,10 @@ struct sway_view_impl {
38 bool (*has_client_side_decorations)(struct sway_view *view); 47 bool (*has_client_side_decorations)(struct sway_view *view);
39 void (*for_each_surface)(struct sway_view *view, 48 void (*for_each_surface)(struct sway_view *view,
40 wlr_surface_iterator_func_t iterator, void *user_data); 49 wlr_surface_iterator_func_t iterator, void *user_data);
50 void (*for_each_popup)(struct sway_view *view,
51 wlr_surface_iterator_func_t iterator, void *user_data);
41 void (*close)(struct sway_view *view); 52 void (*close)(struct sway_view *view);
53 void (*close_popups)(struct sway_view *view);
42 void (*destroy)(struct sway_view *view); 54 void (*destroy)(struct sway_view *view);
43}; 55};
44 56
@@ -60,8 +72,6 @@ struct sway_view {
60 // Used when changing a view from tiled to floating. 72 // Used when changing a view from tiled to floating.
61 int natural_width, natural_height; 73 int natural_width, natural_height;
62 74
63 bool is_fullscreen;
64
65 char *title_format; 75 char *title_format;
66 enum sway_container_border border; 76 enum sway_container_border border;
67 int border_thickness; 77 int border_thickness;
@@ -75,6 +85,9 @@ struct sway_view {
75 bool allow_request_urgent; 85 bool allow_request_urgent;
76 struct wl_event_source *urgent_timer; 86 struct wl_event_source *urgent_timer;
77 87
88 struct wlr_buffer *saved_buffer;
89 int saved_buffer_width, saved_buffer_height;
90
78 bool destroying; 91 bool destroying;
79 92
80 list_t *executed_criteria; // struct criteria * 93 list_t *executed_criteria; // struct criteria *
@@ -88,7 +101,9 @@ struct sway_view {
88 union { 101 union {
89 struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6; 102 struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
90 struct wlr_xdg_surface *wlr_xdg_surface; 103 struct wlr_xdg_surface *wlr_xdg_surface;
104#ifdef HAVE_XWAYLAND
91 struct wlr_xwayland_surface *wlr_xwayland_surface; 105 struct wlr_xwayland_surface *wlr_xwayland_surface;
106#endif
92 struct wlr_wl_shell_surface *wlr_wl_shell_surface; 107 struct wlr_wl_shell_surface *wlr_wl_shell_surface;
93 }; 108 };
94 109
@@ -108,6 +123,8 @@ struct sway_xdg_shell_v6_view {
108 struct wl_listener request_resize; 123 struct wl_listener request_resize;
109 struct wl_listener request_maximize; 124 struct wl_listener request_maximize;
110 struct wl_listener request_fullscreen; 125 struct wl_listener request_fullscreen;
126 struct wl_listener set_title;
127 struct wl_listener set_app_id;
111 struct wl_listener new_popup; 128 struct wl_listener new_popup;
112 struct wl_listener map; 129 struct wl_listener map;
113 struct wl_listener unmap; 130 struct wl_listener unmap;
@@ -122,12 +139,14 @@ struct sway_xdg_shell_view {
122 struct wl_listener request_resize; 139 struct wl_listener request_resize;
123 struct wl_listener request_maximize; 140 struct wl_listener request_maximize;
124 struct wl_listener request_fullscreen; 141 struct wl_listener request_fullscreen;
142 struct wl_listener set_title;
143 struct wl_listener set_app_id;
125 struct wl_listener new_popup; 144 struct wl_listener new_popup;
126 struct wl_listener map; 145 struct wl_listener map;
127 struct wl_listener unmap; 146 struct wl_listener unmap;
128 struct wl_listener destroy; 147 struct wl_listener destroy;
129}; 148};
130 149#ifdef HAVE_XWAYLAND
131struct sway_xwayland_view { 150struct sway_xwayland_view {
132 struct sway_view view; 151 struct sway_view view;
133 152
@@ -159,7 +178,7 @@ struct sway_xwayland_unmanaged {
159 struct wl_listener unmap; 178 struct wl_listener unmap;
160 struct wl_listener destroy; 179 struct wl_listener destroy;
161}; 180};
162 181#endif
163struct sway_view_child; 182struct sway_view_child;
164 183
165struct sway_view_child_impl { 184struct sway_view_child_impl {
@@ -215,15 +234,13 @@ uint32_t view_get_window_type(struct sway_view *view);
215 234
216const char *view_get_shell(struct sway_view *view); 235const char *view_get_shell(struct sway_view *view);
217 236
237void view_get_constraints(struct sway_view *view, double *min_width,
238 double *max_width, double *min_height, double *max_height);
239
218uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, 240uint32_t view_configure(struct sway_view *view, double lx, double ly, int width,
219 int height); 241 int height);
220 242
221/** 243/**
222 * Center the view in its workspace and build the swayc decorations around it.
223 */
224void view_init_floating(struct sway_view *view);
225
226/**
227 * Configure the view's position and size based on the swayc's position and 244 * Configure the view's position and size based on the swayc's position and
228 * size, taking borders into consideration. 245 * size, taking borders into consideration.
229 */ 246 */
@@ -233,17 +250,24 @@ void view_set_activated(struct sway_view *view, bool activated);
233 250
234void view_set_tiled(struct sway_view *view, bool tiled); 251void view_set_tiled(struct sway_view *view, bool tiled);
235 252
236void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen);
237
238void view_set_fullscreen(struct sway_view *view, bool fullscreen);
239
240void view_close(struct sway_view *view); 253void view_close(struct sway_view *view);
241 254
255void view_close_popups(struct sway_view *view);
256
242void view_damage_from(struct sway_view *view); 257void view_damage_from(struct sway_view *view);
243 258
259/**
260 * Iterate all surfaces of a view (toplevels + popups).
261 */
244void view_for_each_surface(struct sway_view *view, 262void view_for_each_surface(struct sway_view *view,
245 wlr_surface_iterator_func_t iterator, void *user_data); 263 wlr_surface_iterator_func_t iterator, void *user_data);
246 264
265/**
266 * Iterate all popups recursively.
267 */
268void view_for_each_popup(struct sway_view *view,
269 wlr_surface_iterator_func_t iterator, void *user_data);
270
247// view implementation 271// view implementation
248 272
249void view_init(struct sway_view *view, enum sway_view_type type, 273void view_init(struct sway_view *view, enum sway_view_type type,
@@ -272,9 +296,10 @@ struct sway_view *view_from_wlr_xdg_surface(
272 struct wlr_xdg_surface *xdg_surface); 296 struct wlr_xdg_surface *xdg_surface);
273struct sway_view *view_from_wlr_xdg_surface_v6( 297struct sway_view *view_from_wlr_xdg_surface_v6(
274 struct wlr_xdg_surface_v6 *xdg_surface_v6); 298 struct wlr_xdg_surface_v6 *xdg_surface_v6);
299#ifdef HAVE_XWAYLAND
275struct sway_view *view_from_wlr_xwayland_surface( 300struct sway_view *view_from_wlr_xwayland_surface(
276 struct wlr_xwayland_surface *xsurface); 301 struct wlr_xwayland_surface *xsurface);
277 302#endif
278struct sway_view *view_from_wlr_surface(struct wlr_surface *surface); 303struct sway_view *view_from_wlr_surface(struct wlr_surface *surface);
279 304
280/** 305/**
@@ -303,6 +328,8 @@ void view_clear_marks(struct sway_view *view);
303 328
304bool view_has_mark(struct sway_view *view, char *mark); 329bool view_has_mark(struct sway_view *view, char *mark);
305 330
331void view_add_mark(struct sway_view *view, char *mark);
332
306void view_update_marks_textures(struct sway_view *view); 333void view_update_marks_textures(struct sway_view *view);
307 334
308/** 335/**
@@ -315,4 +342,8 @@ void view_set_urgent(struct sway_view *view, bool enable);
315 342
316bool view_is_urgent(struct sway_view *view); 343bool view_is_urgent(struct sway_view *view);
317 344
345void view_remove_saved_buffer(struct sway_view *view);
346
347void view_save_buffer(struct sway_view *view);
348
318#endif 349#endif
diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h
index bc95317a..5ae0ae3a 100644
--- a/include/sway/tree/workspace.h
+++ b/include/sway/tree/workspace.h
@@ -7,7 +7,7 @@ struct sway_view;
7 7
8struct sway_workspace { 8struct sway_workspace {
9 struct sway_container *swayc; 9 struct sway_container *swayc;
10 struct sway_view *fullscreen; 10 struct sway_container *fullscreen;
11 struct sway_container *floating; 11 struct sway_container *floating;
12 list_t *output_priority; 12 list_t *output_priority;
13 bool urgent; 13 bool urgent;
@@ -44,6 +44,10 @@ void workspace_output_add_priority(struct sway_container *workspace,
44struct sway_container *workspace_output_get_highest_available( 44struct sway_container *workspace_output_get_highest_available(
45 struct sway_container *ws, struct sway_container *exclude); 45 struct sway_container *ws, struct sway_container *exclude);
46 46
47struct sway_container *workspace_for_pid(pid_t pid);
48
49void workspace_record_pid(pid_t pid);
50
47void workspace_detect_urgent(struct sway_container *workspace); 51void workspace_detect_urgent(struct sway_container *workspace);
48 52
49#endif 53#endif
diff --git a/include/swaygrab/json.h b/include/swaygrab/json.h
deleted file mode 100644
index c1093ef1..00000000
--- a/include/swaygrab/json.h
+++ /dev/null
@@ -1,10 +0,0 @@
1#include <json-c/json.h>
2#include "wlc/wlc.h"
3
4void init_json_tree(int socketfd);
5void free_json_tree();
6char *get_focused_output();
7char *create_payload(const char *output, struct wlc_geometry *g);
8struct wlc_geometry *get_container_geometry(json_object *container);
9json_object *get_focused_container();
10json_object *get_output_container(const char *output);
diff --git a/include/swaynag/config.h b/include/swaynag/config.h
new file mode 100644
index 00000000..0d8889de
--- /dev/null
+++ b/include/swaynag/config.h
@@ -0,0 +1,13 @@
1#ifndef _SWAYNAG_CONFIG_H
2#define _SWAYNAG_CONFIG_H
3#include "swaynag/swaynag.h"
4#include "list.h"
5
6int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
7 list_t *types, struct swaynag_type *type, char **config, bool *debug);
8
9char *swaynag_get_config_path(void);
10
11int swaynag_load_config(char *path, struct swaynag *swaynag, list_t *types);
12
13#endif
diff --git a/include/swaynag/render.h b/include/swaynag/render.h
new file mode 100644
index 00000000..d09e5929
--- /dev/null
+++ b/include/swaynag/render.h
@@ -0,0 +1,7 @@
1#ifndef _SWAYNAG_RENDER_H
2#define _SWAYNAG_RENDER_H
3#include "swaynag/swaynag.h"
4
5void render_frame(struct swaynag *swaynag);
6
7#endif
diff --git a/include/swaynag/swaynag.h b/include/swaynag/swaynag.h
new file mode 100644
index 00000000..1bf8b640
--- /dev/null
+++ b/include/swaynag/swaynag.h
@@ -0,0 +1,100 @@
1#ifndef _SWAYNAG_SWAYNAG_H
2#define _SWAYNAG_SWAYNAG_H
3#include <stdint.h>
4#include <strings.h>
5#include "list.h"
6#include "pool-buffer.h"
7#include "swaynag/types.h"
8#include "xdg-output-unstable-v1-client-protocol.h"
9
10#define SWAYNAG_MAX_HEIGHT 500
11
12struct swaynag;
13
14enum swaynag_action_type {
15 SWAYNAG_ACTION_DISMISS,
16 SWAYNAG_ACTION_EXPAND,
17 SWAYNAG_ACTION_COMMAND,
18};
19
20struct swaynag_pointer {
21 struct wl_pointer *pointer;
22 uint32_t serial;
23 struct wl_cursor_theme *cursor_theme;
24 struct wl_cursor_image *cursor_image;
25 struct wl_surface *cursor_surface;
26 int x;
27 int y;
28};
29
30struct swaynag_output {
31 char *name;
32 struct wl_output *wl_output;
33 uint32_t wl_name;
34 uint32_t scale;
35 struct swaynag *swaynag;
36 struct wl_list link;
37};
38
39struct swaynag_button {
40 char *text;
41 enum swaynag_action_type type;
42 char *action;
43 int x;
44 int y;
45 int width;
46 int height;
47};
48
49struct swaynag_details {
50 bool visible;
51 char *message;
52
53 int x;
54 int y;
55 int width;
56 int height;
57
58 int offset;
59 int visible_lines;
60 int total_lines;
61 struct swaynag_button button_details;
62 struct swaynag_button button_up;
63 struct swaynag_button button_down;
64};
65
66struct swaynag {
67 bool run_display;
68 int querying_outputs;
69
70 struct wl_display *display;
71 struct wl_compositor *compositor;
72 struct wl_seat *seat;
73 struct wl_shm *shm;
74 struct swaynag_pointer pointer;
75 struct zxdg_output_manager_v1 *xdg_output_manager;
76 struct wl_list outputs; // swaynag_output::link
77 struct swaynag_output *output;
78 struct zwlr_layer_shell_v1 *layer_shell;
79 struct zwlr_layer_surface_v1 *layer_surface;
80 struct wl_surface *surface;
81
82 uint32_t width;
83 uint32_t height;
84 int32_t scale;
85 struct pool_buffer buffers[2];
86 struct pool_buffer *current_buffer;
87
88 struct swaynag_type *type;
89 char *message;
90 list_t *buttons;
91 struct swaynag_details details;
92};
93
94void swaynag_setup(struct swaynag *swaynag);
95
96void swaynag_run(struct swaynag *swaynag);
97
98void swaynag_destroy(struct swaynag *swaynag);
99
100#endif
diff --git a/include/swaynag/types.h b/include/swaynag/types.h
new file mode 100644
index 00000000..2183ce22
--- /dev/null
+++ b/include/swaynag/types.h
@@ -0,0 +1,39 @@
1#ifndef _SWAYNAG_TYPES_H
2#define _SWAYNAG_TYPES_H
3
4struct swaynag_type {
5 char *name;
6
7 char *font;
8 char *output;
9 uint32_t anchors;
10
11 uint32_t button_background;
12 uint32_t background;
13 uint32_t text;
14 uint32_t border;
15 uint32_t border_bottom;
16
17 uint32_t bar_border_thickness;
18 uint32_t message_padding;
19 uint32_t details_border_thickness;
20 uint32_t button_border_thickness;
21 uint32_t button_gap;
22 uint32_t button_gap_close;
23 uint32_t button_margin_right;
24 uint32_t button_padding;
25};
26
27void swaynag_types_add_default(list_t *types);
28
29struct swaynag_type *swaynag_type_get(list_t *types, char *name);
30
31struct swaynag_type *swaynag_type_clone(struct swaynag_type *type);
32
33void swaynag_type_merge(struct swaynag_type *dest, struct swaynag_type *src);
34
35void swaynag_type_free(struct swaynag_type *type);
36
37void swaynag_types_free(list_t *types);
38
39#endif
diff --git a/include/util.h b/include/util.h
index f68deae8..9277fa6e 100644
--- a/include/util.h
+++ b/include/util.h
@@ -2,6 +2,7 @@
2#define _SWAY_UTIL_H 2#define _SWAY_UTIL_H
3 3
4#include <stdint.h> 4#include <stdint.h>
5#include <stdbool.h>
5#include <unistd.h> 6#include <unistd.h>
6#include <sys/types.h> 7#include <sys/types.h>
7#include <xkbcommon/xkbcommon.h> 8#include <xkbcommon/xkbcommon.h>
@@ -51,6 +52,14 @@ pid_t get_parent_pid(pid_t pid);
51uint32_t parse_color(const char *color); 52uint32_t parse_color(const char *color);
52 53
53/** 54/**
55 * Given a string that represents a boolean, return the boolean value. This
56 * function also takes in the current boolean value to support toggling. If
57 * toggling is not desired, pass in true for current so that toggling values
58 * get parsed as not true.
59 */
60bool parse_boolean(const char *boolean, bool current);
61
62/**
54 * Given a path string, recurseively resolves any symlinks to their targets 63 * Given a path string, recurseively resolves any symlinks to their targets
55 * (which may be a file, directory) and returns the result. 64 * (which may be a file, directory) and returns the result.
56 * argument is returned. Caller must free the returned buffer. 65 * argument is returned. Caller must free the returned buffer.