diff options
Diffstat (limited to 'include/sway/server.h')
-rw-r--r-- | include/sway/server.h | 103 |
1 files changed, 85 insertions, 18 deletions
diff --git a/include/sway/server.h b/include/sway/server.h index 0f5e3ab2..adb62cda 100644 --- a/include/sway/server.h +++ b/include/sway/server.h | |||
@@ -3,38 +3,59 @@ | |||
3 | #include <stdbool.h> | 3 | #include <stdbool.h> |
4 | #include <wayland-server-core.h> | 4 | #include <wayland-server-core.h> |
5 | #include <wlr/backend.h> | 5 | #include <wlr/backend.h> |
6 | #include <wlr/backend/session.h> | 6 | #include <wlr/render/allocator.h> |
7 | #include <wlr/render/wlr_renderer.h> | 7 | #include <wlr/render/wlr_renderer.h> |
8 | #include <wlr/types/wlr_compositor.h> | 8 | #include <wlr/types/wlr_compositor.h> |
9 | #include <wlr/types/wlr_data_device.h> | 9 | #include <wlr/types/wlr_data_device.h> |
10 | #include <wlr/types/wlr_input_method_v2.h> | 10 | #include <wlr/types/wlr_input_method_v2.h> |
11 | #include <wlr/types/wlr_foreign_toplevel_management_v1.h> | 11 | #include <wlr/types/wlr_foreign_toplevel_management_v1.h> |
12 | #include <wlr/types/wlr_drm_lease_v1.h> | ||
12 | #include <wlr/types/wlr_layer_shell_v1.h> | 13 | #include <wlr/types/wlr_layer_shell_v1.h> |
13 | #include <wlr/types/wlr_output_management_v1.h> | 14 | #include <wlr/types/wlr_output_management_v1.h> |
14 | #include <wlr/types/wlr_output_power_management_v1.h> | 15 | #include <wlr/types/wlr_output_power_management_v1.h> |
15 | #include <wlr/types/wlr_presentation_time.h> | 16 | #include <wlr/types/wlr_presentation_time.h> |
16 | #include <wlr/types/wlr_relative_pointer_v1.h> | 17 | #include <wlr/types/wlr_relative_pointer_v1.h> |
18 | #include <wlr/types/wlr_session_lock_v1.h> | ||
17 | #include <wlr/types/wlr_server_decoration.h> | 19 | #include <wlr/types/wlr_server_decoration.h> |
18 | #include <wlr/types/wlr_text_input_v3.h> | 20 | #include <wlr/types/wlr_text_input_v3.h> |
19 | #include <wlr/types/wlr_xdg_shell.h> | 21 | #include <wlr/types/wlr_xdg_shell.h> |
20 | #include "config.h" | 22 | #include "config.h" |
21 | #include "list.h" | 23 | #include "list.h" |
24 | #include "sway/desktop/idle_inhibit_v1.h" | ||
22 | #if HAVE_XWAYLAND | 25 | #if HAVE_XWAYLAND |
23 | #include "sway/xwayland.h" | 26 | #include "sway/xwayland.h" |
24 | #endif | 27 | #endif |
25 | 28 | ||
29 | struct sway_transaction; | ||
30 | |||
31 | struct sway_session_lock { | ||
32 | struct wlr_session_lock_v1 *lock; | ||
33 | struct wlr_surface *focused; | ||
34 | bool abandoned; | ||
35 | |||
36 | struct wl_list outputs; // struct sway_session_lock_output | ||
37 | |||
38 | // invalid if the session is abandoned | ||
39 | struct wl_listener new_surface; | ||
40 | struct wl_listener unlock; | ||
41 | struct wl_listener destroy; | ||
42 | }; | ||
43 | |||
26 | struct sway_server { | 44 | struct sway_server { |
27 | struct wl_display *wl_display; | 45 | struct wl_display *wl_display; |
28 | struct wl_event_loop *wl_event_loop; | 46 | struct wl_event_loop *wl_event_loop; |
29 | const char *socket; | 47 | const char *socket; |
30 | 48 | ||
31 | struct wlr_backend *backend; | 49 | struct wlr_backend *backend; |
32 | struct wlr_backend *noop_backend; | 50 | struct wlr_session *session; |
33 | // secondary headless backend used for creating virtual outputs on-the-fly | 51 | // secondary headless backend used for creating virtual outputs on-the-fly |
34 | struct wlr_backend *headless_backend; | 52 | struct wlr_backend *headless_backend; |
53 | struct wlr_renderer *renderer; | ||
54 | struct wlr_allocator *allocator; | ||
35 | 55 | ||
36 | struct wlr_compositor *compositor; | 56 | struct wlr_compositor *compositor; |
37 | struct wl_listener compositor_new_surface; | 57 | |
58 | struct wlr_linux_dmabuf_v1 *linux_dmabuf_v1; | ||
38 | 59 | ||
39 | struct wlr_data_device_manager *data_device_manager; | 60 | struct wlr_data_device_manager *data_device_manager; |
40 | 61 | ||
@@ -43,14 +64,14 @@ struct sway_server { | |||
43 | struct wl_listener new_output; | 64 | struct wl_listener new_output; |
44 | struct wl_listener output_layout_change; | 65 | struct wl_listener output_layout_change; |
45 | 66 | ||
46 | struct wlr_idle *idle; | 67 | struct wlr_idle_notifier_v1 *idle_notifier_v1; |
47 | struct sway_idle_inhibit_manager_v1 *idle_inhibit_manager_v1; | 68 | struct sway_idle_inhibit_manager_v1 idle_inhibit_manager_v1; |
48 | 69 | ||
49 | struct wlr_layer_shell_v1 *layer_shell; | 70 | struct wlr_layer_shell_v1 *layer_shell; |
50 | struct wl_listener layer_shell_surface; | 71 | struct wl_listener layer_shell_surface; |
51 | 72 | ||
52 | struct wlr_xdg_shell *xdg_shell; | 73 | struct wlr_xdg_shell *xdg_shell; |
53 | struct wl_listener xdg_shell_surface; | 74 | struct wl_listener xdg_shell_toplevel; |
54 | 75 | ||
55 | struct wlr_tablet_manager_v2 *tablet_v2; | 76 | struct wlr_tablet_manager_v2 *tablet_v2; |
56 | 77 | ||
@@ -70,7 +91,8 @@ struct sway_server { | |||
70 | struct wl_listener xdg_decoration; | 91 | struct wl_listener xdg_decoration; |
71 | struct wl_list xdg_decorations; // sway_xdg_decoration::link | 92 | struct wl_list xdg_decorations; // sway_xdg_decoration::link |
72 | 93 | ||
73 | struct wlr_presentation *presentation; | 94 | struct wlr_drm_lease_v1_manager *drm_lease_manager; |
95 | struct wl_listener drm_lease_request; | ||
74 | 96 | ||
75 | struct wlr_pointer_constraints_v1 *pointer_constraints; | 97 | struct wlr_pointer_constraints_v1 *pointer_constraints; |
76 | struct wl_listener pointer_constraint; | 98 | struct wl_listener pointer_constraint; |
@@ -79,14 +101,52 @@ struct sway_server { | |||
79 | struct wl_listener output_manager_apply; | 101 | struct wl_listener output_manager_apply; |
80 | struct wl_listener output_manager_test; | 102 | struct wl_listener output_manager_test; |
81 | 103 | ||
104 | struct wlr_gamma_control_manager_v1 *gamma_control_manager_v1; | ||
105 | struct wl_listener gamma_control_set_gamma; | ||
106 | |||
107 | struct { | ||
108 | struct sway_session_lock *lock; | ||
109 | struct wlr_session_lock_manager_v1 *manager; | ||
110 | |||
111 | struct wl_listener new_lock; | ||
112 | struct wl_listener manager_destroy; | ||
113 | } session_lock; | ||
114 | |||
82 | struct wlr_output_power_manager_v1 *output_power_manager_v1; | 115 | struct wlr_output_power_manager_v1 *output_power_manager_v1; |
83 | struct wl_listener output_power_manager_set_mode; | 116 | struct wl_listener output_power_manager_set_mode; |
84 | struct wlr_input_method_manager_v2 *input_method; | 117 | struct wlr_input_method_manager_v2 *input_method; |
85 | struct wlr_text_input_manager_v3 *text_input; | 118 | struct wlr_text_input_manager_v3 *text_input; |
86 | struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager; | 119 | struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager; |
120 | struct wlr_content_type_manager_v1 *content_type_manager_v1; | ||
121 | struct wlr_data_control_manager_v1 *data_control_manager_v1; | ||
122 | struct wlr_screencopy_manager_v1 *screencopy_manager_v1; | ||
123 | struct wlr_export_dmabuf_manager_v1 *export_dmabuf_manager_v1; | ||
124 | struct wlr_security_context_manager_v1 *security_context_manager_v1; | ||
125 | |||
126 | struct wlr_xdg_activation_v1 *xdg_activation_v1; | ||
127 | struct wl_listener xdg_activation_v1_request_activate; | ||
128 | struct wl_listener xdg_activation_v1_new_token; | ||
87 | 129 | ||
130 | struct wl_listener request_set_cursor_shape; | ||
131 | |||
132 | struct wl_list pending_launcher_ctxs; // launcher_ctx::link | ||
133 | |||
134 | // The timeout for transactions, after which a transaction is applied | ||
135 | // regardless of readiness. | ||
88 | size_t txn_timeout_ms; | 136 | size_t txn_timeout_ms; |
89 | list_t *transactions; | 137 | |
138 | // Stores a transaction after it has been committed, but is waiting for | ||
139 | // views to ack the new dimensions before being applied. A queued | ||
140 | // transaction is frozen and must not have new instructions added to it. | ||
141 | struct sway_transaction *queued_transaction; | ||
142 | |||
143 | // Stores a pending transaction that will be committed once the existing | ||
144 | // queued transaction is applied and freed. The pending transaction can be | ||
145 | // updated with new instructions as needed. | ||
146 | struct sway_transaction *pending_transaction; | ||
147 | |||
148 | // Stores the nodes that have been marked as "dirty" and will be put into | ||
149 | // the pending transaction. | ||
90 | list_t *dirty_nodes; | 150 | list_t *dirty_nodes; |
91 | }; | 151 | }; |
92 | 152 | ||
@@ -96,34 +156,41 @@ struct sway_debug { | |||
96 | bool noatomic; // Ignore atomic layout updates | 156 | bool noatomic; // Ignore atomic layout updates |
97 | bool txn_timings; // Log verbose messages about transactions | 157 | bool txn_timings; // Log verbose messages about transactions |
98 | bool txn_wait; // Always wait for the timeout before applying | 158 | bool txn_wait; // Always wait for the timeout before applying |
99 | 159 | bool legacy_wl_drm; // Enable the legacy wl_drm interface | |
100 | enum { | ||
101 | DAMAGE_DEFAULT, // Default behaviour | ||
102 | DAMAGE_HIGHLIGHT, // Highlight regions of the screen being damaged | ||
103 | DAMAGE_RERENDER, // Render the full output when any damage occurs | ||
104 | } damage; | ||
105 | }; | 160 | }; |
106 | 161 | ||
107 | extern struct sway_debug debug; | 162 | extern struct sway_debug debug; |
108 | 163 | ||
109 | /* Prepares an unprivileged server_init by performing all privileged operations in advance */ | 164 | extern bool allow_unsupported_gpu; |
110 | bool server_privileged_prepare(struct sway_server *server); | 165 | |
111 | bool server_init(struct sway_server *server); | 166 | bool server_init(struct sway_server *server); |
112 | void server_fini(struct sway_server *server); | 167 | void server_fini(struct sway_server *server); |
113 | bool server_start(struct sway_server *server); | 168 | bool server_start(struct sway_server *server); |
114 | void server_run(struct sway_server *server); | 169 | void server_run(struct sway_server *server); |
115 | 170 | ||
116 | void handle_compositor_new_surface(struct wl_listener *listener, void *data); | 171 | void restore_nofile_limit(void); |
172 | |||
117 | void handle_new_output(struct wl_listener *listener, void *data); | 173 | void handle_new_output(struct wl_listener *listener, void *data); |
118 | 174 | ||
119 | void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data); | 175 | void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data); |
120 | void handle_layer_shell_surface(struct wl_listener *listener, void *data); | 176 | void handle_layer_shell_surface(struct wl_listener *listener, void *data); |
121 | void handle_xdg_shell_surface(struct wl_listener *listener, void *data); | 177 | void sway_session_lock_init(void); |
178 | void sway_session_lock_add_output(struct sway_session_lock *lock, | ||
179 | struct sway_output *output); | ||
180 | bool sway_session_lock_has_surface(struct sway_session_lock *lock, | ||
181 | struct wlr_surface *surface); | ||
182 | void handle_xdg_shell_toplevel(struct wl_listener *listener, void *data); | ||
122 | #if HAVE_XWAYLAND | 183 | #if HAVE_XWAYLAND |
123 | void handle_xwayland_surface(struct wl_listener *listener, void *data); | 184 | void handle_xwayland_surface(struct wl_listener *listener, void *data); |
124 | #endif | 185 | #endif |
125 | void handle_server_decoration(struct wl_listener *listener, void *data); | 186 | void handle_server_decoration(struct wl_listener *listener, void *data); |
126 | void handle_xdg_decoration(struct wl_listener *listener, void *data); | 187 | void handle_xdg_decoration(struct wl_listener *listener, void *data); |
127 | void handle_pointer_constraint(struct wl_listener *listener, void *data); | 188 | void handle_pointer_constraint(struct wl_listener *listener, void *data); |
189 | void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, | ||
190 | void *data); | ||
191 | void xdg_activation_v1_handle_new_token(struct wl_listener *listener, | ||
192 | void *data); | ||
193 | |||
194 | void set_rr_scheduling(void); | ||
128 | 195 | ||
129 | #endif | 196 | #endif |