diff options
-rw-r--r-- | include/extensions.h | 9 | ||||
-rw-r--r-- | sway/extensions.c | 51 | ||||
-rw-r--r-- | sway/handlers.c | 34 | ||||
-rw-r--r-- | sway/layout.c | 22 | ||||
-rw-r--r-- | swaybar/main.c | 36 |
5 files changed, 130 insertions, 22 deletions
diff --git a/include/extensions.h b/include/extensions.h index 2fca23c1..1ef7d920 100644 --- a/include/extensions.h +++ b/include/extensions.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef _SWAY_EXTENSIONS_H | 1 | #ifndef _SWAY_EXTENSIONS_H |
2 | #define _SWAY_EXTENSIONS_H | 2 | #define _SWAY_EXTENSIONS_H |
3 | 3 | ||
4 | #include "wayland-desktop-shell-server-protocol.h" | ||
4 | #include "list.h" | 5 | #include "list.h" |
5 | #include "wlc/wlc-wayland.h" | 6 | #include "wlc/wlc-wayland.h" |
6 | 7 | ||
@@ -9,8 +10,16 @@ struct background_config { | |||
9 | wlc_resource surface; | 10 | wlc_resource surface; |
10 | }; | 11 | }; |
11 | 12 | ||
13 | struct panel_config { | ||
14 | wlc_handle output; | ||
15 | wlc_resource surface; | ||
16 | }; | ||
17 | |||
12 | struct desktop_shell_state { | 18 | struct desktop_shell_state { |
13 | list_t *backgrounds; | 19 | list_t *backgrounds; |
20 | list_t *panels; | ||
21 | enum desktop_shell_panel_position panel_position; | ||
22 | struct wlc_size panel_size; | ||
14 | }; | 23 | }; |
15 | 24 | ||
16 | extern struct desktop_shell_state desktop_shell; | 25 | extern struct desktop_shell_state desktop_shell; |
diff --git a/sway/extensions.c b/sway/extensions.c index aa51b474..1f8e9a7c 100644 --- a/sway/extensions.c +++ b/sway/extensions.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <wlc/wlc.h> | 2 | #include <wlc/wlc.h> |
3 | #include <wlc/wlc-wayland.h> | 3 | #include <wlc/wlc-wayland.h> |
4 | #include "wayland-desktop-shell-server-protocol.h" | 4 | #include "wayland-desktop-shell-server-protocol.h" |
5 | #include "layout.h" | ||
5 | #include "log.h" | 6 | #include "log.h" |
6 | #include "extensions.h" | 7 | #include "extensions.h" |
7 | 8 | ||
@@ -20,13 +21,55 @@ static void set_background(struct wl_client *client, struct wl_resource *resourc | |||
20 | list_add(desktop_shell.backgrounds, config); | 21 | list_add(desktop_shell.backgrounds, config); |
21 | } | 22 | } |
22 | 23 | ||
24 | static void set_panel(struct wl_client *client, struct wl_resource *resource, | ||
25 | struct wl_resource *_output, struct wl_resource *surface) { | ||
26 | wlc_handle output = wlc_handle_from_wl_output_resource(_output); | ||
27 | if (!output) { | ||
28 | return; | ||
29 | } | ||
30 | sway_log(L_DEBUG, "Setting surface %p as panel for output %d", surface, (int)output); | ||
31 | struct panel_config *config = malloc(sizeof(struct panel_config)); | ||
32 | config->output = output; | ||
33 | config->surface = wlc_resource_from_wl_surface_resource(surface); | ||
34 | list_add(desktop_shell.panels, config); | ||
35 | desktop_shell.panel_size = *wlc_surface_get_size(config->surface); | ||
36 | arrange_windows(&root_container, -1, -1); | ||
37 | } | ||
38 | |||
39 | static void set_lock_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) { | ||
40 | sway_log(L_ERROR, "desktop_set_lock_surface is not currently supported"); | ||
41 | } | ||
42 | |||
43 | static void unlock(struct wl_client *client, struct wl_resource *resource) { | ||
44 | sway_log(L_ERROR, "desktop_unlock is not currently supported"); | ||
45 | } | ||
46 | |||
47 | static void set_grab_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) { | ||
48 | sway_log(L_ERROR, "desktop_set_grab_surface is not currently supported"); | ||
49 | } | ||
50 | |||
51 | static void desktop_ready(struct wl_client *client, struct wl_resource *resource) { | ||
52 | // nop | ||
53 | } | ||
54 | |||
55 | static void set_panel_position(struct wl_client *client, struct wl_resource *resource, uint32_t position) { | ||
56 | desktop_shell.panel_position = position; | ||
57 | arrange_windows(&root_container, -1, -1); | ||
58 | } | ||
59 | |||
23 | static struct desktop_shell_interface desktop_shell_implementation = { | 60 | static struct desktop_shell_interface desktop_shell_implementation = { |
24 | .set_background = set_background | 61 | .set_background = set_background, |
62 | .set_panel = set_panel, | ||
63 | .set_lock_surface = set_lock_surface, | ||
64 | .unlock = unlock, | ||
65 | .set_grab_surface = set_grab_surface, | ||
66 | .desktop_ready = desktop_ready, | ||
67 | .set_panel_position = set_panel_position | ||
25 | }; | 68 | }; |
26 | 69 | ||
27 | static void desktop_shell_bind(struct wl_client *client, void *data, | 70 | static void desktop_shell_bind(struct wl_client *client, void *data, |
28 | unsigned int version, unsigned int id) { | 71 | unsigned int version, unsigned int id) { |
29 | if (version > 1) { | 72 | if (version > 3) { |
30 | // Unsupported version | 73 | // Unsupported version |
31 | return; | 74 | return; |
32 | } | 75 | } |
@@ -40,6 +83,8 @@ static void desktop_shell_bind(struct wl_client *client, void *data, | |||
40 | } | 83 | } |
41 | 84 | ||
42 | void register_extensions(void) { | 85 | void register_extensions(void) { |
43 | wl_global_create(wlc_get_wl_display(), &desktop_shell_interface, 1, NULL, desktop_shell_bind); | 86 | wl_global_create(wlc_get_wl_display(), &desktop_shell_interface, 3, NULL, desktop_shell_bind); |
44 | desktop_shell.backgrounds = create_list(); | 87 | desktop_shell.backgrounds = create_list(); |
88 | desktop_shell.panels = create_list(); | ||
89 | desktop_shell.panel_position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; | ||
45 | } | 90 | } |
diff --git a/sway/handlers.c b/sway/handlers.c index 267a8f3a..2029ae84 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -72,11 +72,43 @@ static void handle_output_destroyed(wlc_handle output) { | |||
72 | } | 72 | } |
73 | 73 | ||
74 | static void handle_output_pre_render(wlc_handle output) { | 74 | static void handle_output_pre_render(wlc_handle output) { |
75 | struct wlc_size resolution = *wlc_output_get_resolution(output); | ||
76 | |||
75 | int i; | 77 | int i; |
76 | for (i = 0; i < desktop_shell.backgrounds->length; ++i) { | 78 | for (i = 0; i < desktop_shell.backgrounds->length; ++i) { |
77 | struct background_config *config = desktop_shell.backgrounds->items[i]; | 79 | struct background_config *config = desktop_shell.backgrounds->items[i]; |
78 | if (config->output == output) { | 80 | if (config->output == output) { |
79 | wlc_surface_render(config->surface, &(struct wlc_geometry){ wlc_origin_zero, *wlc_output_get_resolution(output) }); | 81 | wlc_surface_render(config->surface, &(struct wlc_geometry){ wlc_origin_zero, resolution }); |
82 | break; | ||
83 | } | ||
84 | } | ||
85 | |||
86 | for (i = 0; i < desktop_shell.panels->length; ++i) { | ||
87 | struct panel_config *config = desktop_shell.panels->items[i]; | ||
88 | if (config->output == output) { | ||
89 | struct wlc_size size = *wlc_surface_get_size(config->surface); | ||
90 | struct wlc_geometry geo = { | ||
91 | .size = size | ||
92 | }; | ||
93 | switch (desktop_shell.panel_position) { | ||
94 | case DESKTOP_SHELL_PANEL_POSITION_TOP: | ||
95 | geo.origin = (struct wlc_origin){ 0, 0 }; | ||
96 | break; | ||
97 | case DESKTOP_SHELL_PANEL_POSITION_BOTTOM: | ||
98 | geo.origin = (struct wlc_origin){ 0, resolution.h - size.h }; | ||
99 | break; | ||
100 | case DESKTOP_SHELL_PANEL_POSITION_LEFT: | ||
101 | geo.origin = (struct wlc_origin){ 0, 0 }; | ||
102 | break; | ||
103 | case DESKTOP_SHELL_PANEL_POSITION_RIGHT: | ||
104 | geo.origin = (struct wlc_origin){ resolution.w - size.w, 0 }; | ||
105 | break; | ||
106 | } | ||
107 | wlc_surface_render(config->surface, &geo); | ||
108 | if (size.w != desktop_shell.panel_size.w || size.h != desktop_shell.panel_size.h) { | ||
109 | desktop_shell.panel_size = size; | ||
110 | arrange_windows(&root_container, -1, -1); | ||
111 | } | ||
80 | break; | 112 | break; |
81 | } | 113 | } |
82 | } | 114 | } |
diff --git a/sway/layout.c b/sway/layout.c index de186886..70980ec3 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <stdbool.h> | 2 | #include <stdbool.h> |
3 | #include <wlc/wlc.h> | 3 | #include <wlc/wlc.h> |
4 | #include "extensions.h" | ||
4 | #include "layout.h" | 5 | #include "layout.h" |
5 | #include "log.h" | 6 | #include "log.h" |
6 | #include "list.h" | 7 | #include "list.h" |
@@ -426,6 +427,27 @@ static void arrange_windows_r(swayc_t *container, double width, double height) { | |||
426 | } | 427 | } |
427 | return; | 428 | return; |
428 | case C_OUTPUT: | 429 | case C_OUTPUT: |
430 | for (i = 0; i < desktop_shell.panels->length; ++i) { | ||
431 | struct panel_config *config = desktop_shell.panels->items[i]; | ||
432 | if (config->output == container->handle) { | ||
433 | struct wlc_size size = *wlc_surface_get_size(config->surface); | ||
434 | switch (desktop_shell.panel_position) { | ||
435 | case DESKTOP_SHELL_PANEL_POSITION_TOP: | ||
436 | y += size.h; height -= size.h; | ||
437 | break; | ||
438 | case DESKTOP_SHELL_PANEL_POSITION_BOTTOM: | ||
439 | height -= size.h; | ||
440 | break; | ||
441 | case DESKTOP_SHELL_PANEL_POSITION_LEFT: | ||
442 | x += size.w; width -= size.w; | ||
443 | break; | ||
444 | case DESKTOP_SHELL_PANEL_POSITION_RIGHT: | ||
445 | width -= size.w; | ||
446 | break; | ||
447 | } | ||
448 | } | ||
449 | } | ||
450 | |||
429 | container->width = width; | 451 | container->width = width; |
430 | container->height = height; | 452 | container->height = height; |
431 | x = 0, y = 0; | 453 | x = 0, y = 0; |
diff --git a/swaybar/main.c b/swaybar/main.c index dfdda9ca..b25d8252 100644 --- a/swaybar/main.c +++ b/swaybar/main.c | |||
@@ -25,34 +25,34 @@ struct colors { | |||
25 | struct registry *registry; | 25 | struct registry *registry; |
26 | struct window *window; | 26 | struct window *window; |
27 | struct colors colors = { | 27 | struct colors colors = { |
28 | .background = 0x00000000, | 28 | .background = 0x000000FF, |
29 | .statusline = 0xffffffff, | 29 | .statusline = 0xFFFFFFFF, |
30 | .seperator = 0x666666ff, | 30 | .seperator = 0x666666FF, |
31 | 31 | ||
32 | .focused_workspace = { | 32 | .focused_workspace = { |
33 | .border = 0x4c7899ff, | 33 | .border = 0x4C7899FF, |
34 | .background = 0x285577ff, | 34 | .background = 0x285577FF, |
35 | .text = 0xffffffff | 35 | .text = 0xFFFFFFFF |
36 | }, | 36 | }, |
37 | .active_workspace = { | 37 | .active_workspace = { |
38 | .border = 0x333333ff, | 38 | .border = 0x333333FF, |
39 | .background = 0x5f676aff, | 39 | .background = 0x5F676AFF, |
40 | .text = 0xffffffff | 40 | .text = 0xFFFFFFFF |
41 | }, | 41 | }, |
42 | .inactive_workspace = { | 42 | .inactive_workspace = { |
43 | .border = 0x333333ff, | 43 | .border = 0x333333FF, |
44 | .background = 0x222222ff, | 44 | .background = 0x222222FF, |
45 | .text = 0x888888ff | 45 | .text = 0x888888FF |
46 | }, | 46 | }, |
47 | .urgent_workspace = { | 47 | .urgent_workspace = { |
48 | .border = 0x2f343aff, | 48 | .border = 0x2F343AFF, |
49 | .background = 0x900000ff, | 49 | .background = 0x900000FF, |
50 | .text = 0xffffffff | 50 | .text = 0xFFFFFFFF |
51 | }, | 51 | }, |
52 | .binding_mode = { | 52 | .binding_mode = { |
53 | .border = 0x2f343aff, | 53 | .border = 0x2F343AFF, |
54 | .background = 0x900000ff, | 54 | .background = 0x900000FF, |
55 | .text = 0xffffffff | 55 | .text = 0xFFFFFFFF |
56 | }, | 56 | }, |
57 | }; | 57 | }; |
58 | 58 | ||