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