summaryrefslogtreecommitdiffstats
path: root/sway/extensions.c
diff options
context:
space:
mode:
authorLibravatar S. Christoffer Eliesen <christoffer@eliesen.no>2015-12-20 12:49:11 +0100
committerLibravatar S. Christoffer Eliesen <christoffer@eliesen.no>2015-12-20 12:54:34 +0100
commite45fd9b6c5dfb858c6f86277351bc216574d8200 (patch)
tree8d70e85b1e1f1dcca401429c95b9b8ee9bde8890 /sway/extensions.c
parentextensions: panel_config->resource => wl_surface_res. (diff)
downloadsway-e45fd9b6c5dfb858c6f86277351bc216574d8200.tar.gz
sway-e45fd9b6c5dfb858c6f86277351bc216574d8200.tar.zst
sway-e45fd9b6c5dfb858c6f86277351bc216574d8200.zip
extensions: Track panels by wl_resource, position per panel.
Track each panel separately via its wl_resource. `set_panel_position` might be called before `set_panel`, so reuse panel config. Place the position in panel_config so that each panel has its own position.
Diffstat (limited to 'sway/extensions.c')
-rw-r--r--sway/extensions.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/sway/extensions.c b/sway/extensions.c
index d37eaddd..00a72a80 100644
--- a/sway/extensions.c
+++ b/sway/extensions.c
@@ -9,6 +9,21 @@
9 9
10struct desktop_shell_state desktop_shell; 10struct desktop_shell_state desktop_shell;
11 11
12static struct panel_config *find_or_create_panel_config(struct wl_resource *resource) {
13 for (int i = 0; i < desktop_shell.panels->length; i++) {
14 struct panel_config *conf = desktop_shell.panels->items[i];
15 if (conf->wl_resource == resource) {
16 sway_log(L_DEBUG, "Found existing panel config for resource %p", resource);
17 return conf;
18 }
19 }
20 sway_log(L_DEBUG, "Creating panel config for resource %p", resource);
21 struct panel_config *config = calloc(1, sizeof(struct panel_config));
22 list_add(desktop_shell.panels, config);
23 config->wl_resource = resource;
24 return config;
25}
26
12void background_surface_destructor(struct wl_resource *resource) { 27void background_surface_destructor(struct wl_resource *resource) {
13 sway_log(L_DEBUG, "Background surface killed"); 28 sway_log(L_DEBUG, "Background surface killed");
14 int i; 29 int i;
@@ -69,12 +84,11 @@ static void set_panel(struct wl_client *client, struct wl_resource *resource,
69 if (!output) { 84 if (!output) {
70 return; 85 return;
71 } 86 }
72 sway_log(L_DEBUG, "Setting surface %p as panel for output %d", surface, (int)output); 87 sway_log(L_DEBUG, "Setting surface %p as panel for output %d (wl_resource: %p)", surface, (int)output, resource);
73 struct panel_config *config = malloc(sizeof(struct panel_config)); 88 struct panel_config *config = find_or_create_panel_config(resource);
74 config->output = output; 89 config->output = output;
75 config->surface = wlc_resource_from_wl_surface_resource(surface); 90 config->surface = wlc_resource_from_wl_surface_resource(surface);
76 config->wl_surface_res = surface; 91 config->wl_surface_res = surface;
77 list_add(desktop_shell.panels, config);
78 wl_resource_set_destructor(surface, panel_surface_destructor); 92 wl_resource_set_destructor(surface, panel_surface_destructor);
79 desktop_shell.panel_size = *wlc_surface_get_size(config->surface); 93 desktop_shell.panel_size = *wlc_surface_get_size(config->surface);
80 arrange_windows(&root_container, -1, -1); 94 arrange_windows(&root_container, -1, -1);
@@ -121,7 +135,9 @@ static void desktop_ready(struct wl_client *client, struct wl_resource *resource
121} 135}
122 136
123static void set_panel_position(struct wl_client *client, struct wl_resource *resource, uint32_t position) { 137static void set_panel_position(struct wl_client *client, struct wl_resource *resource, uint32_t position) {
124 desktop_shell.panel_position = position; 138 struct panel_config *config = find_or_create_panel_config(resource);
139 sway_log(L_DEBUG, "Panel position for wl_resource %p changed %d => %d", resource, config->panel_position, position);
140 config->panel_position = position;
125 arrange_windows(&root_container, -1, -1); 141 arrange_windows(&root_container, -1, -1);
126} 142}
127 143
@@ -174,7 +190,6 @@ void register_extensions(void) {
174 wl_global_create(wlc_get_wl_display(), &desktop_shell_interface, 3, NULL, desktop_shell_bind); 190 wl_global_create(wlc_get_wl_display(), &desktop_shell_interface, 3, NULL, desktop_shell_bind);
175 desktop_shell.backgrounds = create_list(); 191 desktop_shell.backgrounds = create_list();
176 desktop_shell.panels = create_list(); 192 desktop_shell.panels = create_list();
177 desktop_shell.panel_position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM;
178 desktop_shell.lock_surfaces = create_list(); 193 desktop_shell.lock_surfaces = create_list();
179 desktop_shell.is_locked = false; 194 desktop_shell.is_locked = false;
180 wl_global_create(wlc_get_wl_display(), &lock_interface, 1, NULL, swaylock_bind); 195 wl_global_create(wlc_get_wl_display(), &lock_interface, 1, NULL, swaylock_bind);