aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/server.h1
-rw-r--r--include/sway/tree/view.h15
-rw-r--r--sway/commands/fullscreen.c1
-rw-r--r--sway/desktop/output.c1
-rw-r--r--sway/desktop/wl_shell.c165
-rw-r--r--sway/meson.build1
-rw-r--r--sway/server.c10
-rw-r--r--sway/tree/container.c6
-rw-r--r--sway/tree/view.c2
9 files changed, 2 insertions, 200 deletions
diff --git a/include/sway/server.h b/include/sway/server.h
index d04ea896..c95ee0f3 100644
--- a/include/sway/server.h
+++ b/include/sway/server.h
@@ -58,6 +58,5 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data);
58void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data); 58void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
59void handle_xdg_shell_surface(struct wl_listener *listener, void *data); 59void handle_xdg_shell_surface(struct wl_listener *listener, void *data);
60void handle_xwayland_surface(struct wl_listener *listener, void *data); 60void handle_xwayland_surface(struct wl_listener *listener, void *data);
61void handle_wl_shell_surface(struct wl_listener *listener, void *data);
62 61
63#endif 62#endif
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 7c07842b..9af13004 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -10,7 +10,6 @@
10struct sway_container; 10struct sway_container;
11 11
12enum sway_view_type { 12enum sway_view_type {
13 SWAY_VIEW_WL_SHELL,
14 SWAY_VIEW_XDG_SHELL_V6, 13 SWAY_VIEW_XDG_SHELL_V6,
15 SWAY_VIEW_XDG_SHELL, 14 SWAY_VIEW_XDG_SHELL,
16 SWAY_VIEW_XWAYLAND, 15 SWAY_VIEW_XWAYLAND,
@@ -139,20 +138,6 @@ struct sway_xwayland_unmanaged {
139 struct wl_listener destroy; 138 struct wl_listener destroy;
140}; 139};
141 140
142struct sway_wl_shell_view {
143 struct sway_view view;
144
145 struct wl_listener commit;
146 struct wl_listener request_move;
147 struct wl_listener request_resize;
148 struct wl_listener request_maximize;
149 struct wl_listener request_fullscreen;
150 struct wl_listener set_state;
151 struct wl_listener destroy;
152
153 int pending_width, pending_height;
154};
155
156struct sway_view_child; 141struct sway_view_child;
157 142
158struct sway_view_child_impl { 143struct sway_view_child_impl {
diff --git a/sway/commands/fullscreen.c b/sway/commands/fullscreen.c
index 8692e92d..ec9ec276 100644
--- a/sway/commands/fullscreen.c
+++ b/sway/commands/fullscreen.c
@@ -1,4 +1,3 @@
1#include <wlr/types/wlr_wl_shell.h>
2#include "log.h" 1#include "log.h"
3#include "sway/commands.h" 2#include "sway/commands.h"
4#include "sway/config.h" 3#include "sway/config.h"
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 974cd56c..3f89f5cc 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -11,7 +11,6 @@
11#include <wlr/types/wlr_output_layout.h> 11#include <wlr/types/wlr_output_layout.h>
12#include <wlr/types/wlr_output.h> 12#include <wlr/types/wlr_output.h>
13#include <wlr/types/wlr_surface.h> 13#include <wlr/types/wlr_surface.h>
14#include <wlr/types/wlr_wl_shell.h>
15#include <wlr/util/region.h> 14#include <wlr/util/region.h>
16#include "log.h" 15#include "log.h"
17#include "sway/config.h" 16#include "sway/config.h"
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c
deleted file mode 100644
index cb3774f7..00000000
--- a/sway/desktop/wl_shell.c
+++ /dev/null
@@ -1,165 +0,0 @@
1#define _POSIX_C_SOURCE 199309L
2#include <stdbool.h>
3#include <stdlib.h>
4#include <wayland-server.h>
5#include <wlr/types/wlr_wl_shell.h>
6#include "sway/tree/container.h"
7#include "sway/tree/layout.h"
8#include "sway/server.h"
9#include "sway/tree/view.h"
10#include "sway/input/seat.h"
11#include "sway/input/input-manager.h"
12#include "log.h"
13
14static struct sway_wl_shell_view *wl_shell_view_from_view(
15 struct sway_view *view) {
16 if (!sway_assert(view->type == SWAY_VIEW_WL_SHELL,
17 "Expected wl_shell view")) {
18 return NULL;
19 }
20 return (struct sway_wl_shell_view *)view;
21}
22
23static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) {
24 if (wl_shell_view_from_view(view) == NULL) {
25 return NULL;
26 }
27 switch (prop) {
28 case VIEW_PROP_TITLE:
29 return view->wlr_wl_shell_surface->title;
30 case VIEW_PROP_CLASS:
31 return view->wlr_wl_shell_surface->class;
32 default:
33 return NULL;
34 }
35}
36
37static void configure(struct sway_view *view, double ox, double oy, int width,
38 int height) {
39 struct sway_wl_shell_view *wl_shell_view = wl_shell_view_from_view(view);
40 if (wl_shell_view == NULL) {
41 return;
42 }
43 wl_shell_view->pending_width = width;
44 wl_shell_view->pending_height = height;
45 wlr_wl_shell_surface_configure(view->wlr_wl_shell_surface, 0, width, height);
46}
47
48static void _close(struct sway_view *view) {
49 if (wl_shell_view_from_view(view) == NULL) {
50 return;
51 }
52
53 wl_client_destroy(view->wlr_wl_shell_surface->client);
54}
55
56static void destroy(struct sway_view *view) {
57 struct sway_wl_shell_view *wl_shell_view = wl_shell_view_from_view(view);
58 if (wl_shell_view == NULL) {
59 return;
60 }
61 wl_list_remove(&wl_shell_view->commit.link);
62 wl_list_remove(&wl_shell_view->destroy.link);
63 wl_list_remove(&wl_shell_view->request_fullscreen.link);
64 wl_list_remove(&wl_shell_view->set_state.link);
65 free(wl_shell_view);
66}
67
68static void set_fullscreen(struct sway_view *view, bool fullscreen) {
69 // TODO
70}
71
72static const struct sway_view_impl view_impl = {
73 .get_string_prop = get_string_prop,
74 .configure = configure,
75 .close = _close,
76 .destroy = destroy,
77 .set_fullscreen = set_fullscreen,
78};
79
80static void handle_commit(struct wl_listener *listener, void *data) {
81 struct sway_wl_shell_view *wl_shell_view =
82 wl_container_of(listener, wl_shell_view, commit);
83 struct sway_view *view = &wl_shell_view->view;
84 // NOTE: We intentionally discard the view's desired width here
85 // TODO: Let floating views do whatever
86 view_update_size(view, wl_shell_view->pending_width,
87 wl_shell_view->pending_height);
88 view_damage_from(view);
89}
90
91static void handle_destroy(struct wl_listener *listener, void *data) {
92 struct sway_wl_shell_view *wl_shell_view =
93 wl_container_of(listener, wl_shell_view, destroy);
94 view_destroy(&wl_shell_view->view);
95}
96
97static void handle_request_fullscreen(struct wl_listener *listener, void *data) {
98 struct sway_wl_shell_view *wl_shell_view =
99 wl_container_of(listener, wl_shell_view, request_fullscreen);
100 view_set_fullscreen(&wl_shell_view->view, true);
101}
102
103static void handle_set_state(struct wl_listener *listener, void *data) {
104 struct sway_wl_shell_view *wl_shell_view =
105 wl_container_of(listener, wl_shell_view, set_state);
106 struct sway_view *view = &wl_shell_view->view;
107 struct wlr_wl_shell_surface *surface = view->wlr_wl_shell_surface;
108 if (view->is_fullscreen &&
109 surface->state != WLR_WL_SHELL_SURFACE_STATE_FULLSCREEN) {
110 view_set_fullscreen(view, false);
111 }
112}
113
114void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
115 struct sway_server *server = wl_container_of(listener, server,
116 wl_shell_surface);
117 struct wlr_wl_shell_surface *shell_surface = data;
118
119 if (shell_surface->state == WLR_WL_SHELL_SURFACE_STATE_POPUP) {
120 // popups don't get views
121 wlr_log(L_DEBUG, "New wl_shell popup");
122 return;
123 }
124
125 // TODO: make transient windows floating
126
127 wlr_log(L_DEBUG, "New wl_shell toplevel title='%s' app_id='%s'",
128 shell_surface->title, shell_surface->class);
129 wlr_wl_shell_surface_ping(shell_surface);
130
131 struct sway_wl_shell_view *wl_shell_view =
132 calloc(1, sizeof(struct sway_wl_shell_view));
133 if (!sway_assert(wl_shell_view, "Failed to allocate view")) {
134 return;
135 }
136
137 view_init(&wl_shell_view->view, SWAY_VIEW_WL_SHELL, &view_impl);
138 wl_shell_view->view.wlr_wl_shell_surface = shell_surface;
139
140 // TODO:
141 // - Wire up listeners
142 // - Look up pid and open on appropriate workspace
143 // - Set new view to maximized so it behaves nicely
144 // - Criteria
145
146 wl_shell_view->commit.notify = handle_commit;
147 wl_signal_add(&shell_surface->surface->events.commit,
148 &wl_shell_view->commit);
149
150 wl_shell_view->destroy.notify = handle_destroy;
151 wl_signal_add(&shell_surface->events.destroy, &wl_shell_view->destroy);
152
153 wl_shell_view->request_fullscreen.notify = handle_request_fullscreen;
154 wl_signal_add(&shell_surface->events.request_fullscreen,
155 &wl_shell_view->request_fullscreen);
156
157 wl_shell_view->set_state.notify = handle_set_state;
158 wl_signal_add(&shell_surface->events.set_state, &wl_shell_view->set_state);
159
160 view_map(&wl_shell_view->view, shell_surface->surface);
161
162 if (shell_surface->state == WLR_WL_SHELL_SURFACE_STATE_FULLSCREEN) {
163 view_set_fullscreen(&wl_shell_view->view, true);
164 }
165}
diff --git a/sway/meson.build b/sway/meson.build
index 570d4783..67c2a422 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -12,7 +12,6 @@ sway_sources = files(
12 'desktop/desktop.c', 12 'desktop/desktop.c',
13 'desktop/layer_shell.c', 13 'desktop/layer_shell.c',
14 'desktop/output.c', 14 'desktop/output.c',
15 'desktop/wl_shell.c',
16 'desktop/xdg_shell_v6.c', 15 'desktop/xdg_shell_v6.c',
17 'desktop/xdg_shell.c', 16 'desktop/xdg_shell.c',
18 'desktop/xwayland.c', 17 'desktop/xwayland.c',
diff --git a/sway/server.c b/sway/server.c
index 6147a39d..050ddf56 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -8,15 +8,14 @@
8#include <wlr/render/wlr_renderer.h> 8#include <wlr/render/wlr_renderer.h>
9#include <wlr/types/wlr_compositor.h> 9#include <wlr/types/wlr_compositor.h>
10#include <wlr/types/wlr_gamma_control.h> 10#include <wlr/types/wlr_gamma_control.h>
11#include <wlr/types/wlr_linux_dmabuf.h> 11#include <wlr/types/wlr_idle.h>
12#include <wlr/types/wlr_layer_shell.h> 12#include <wlr/types/wlr_layer_shell.h>
13#include <wlr/types/wlr_linux_dmabuf.h>
13#include <wlr/types/wlr_primary_selection.h> 14#include <wlr/types/wlr_primary_selection.h>
14#include <wlr/types/wlr_screenshooter.h> 15#include <wlr/types/wlr_screenshooter.h>
15#include <wlr/types/wlr_server_decoration.h> 16#include <wlr/types/wlr_server_decoration.h>
16#include <wlr/types/wlr_xcursor_manager.h> 17#include <wlr/types/wlr_xcursor_manager.h>
17#include <wlr/types/wlr_xdg_output.h> 18#include <wlr/types/wlr_xdg_output.h>
18#include <wlr/types/wlr_wl_shell.h>
19#include <wlr/types/wlr_idle.h>
20#include <wlr/util/log.h> 19#include <wlr/util/log.h>
21// TODO WLR: make Xwayland optional 20// TODO WLR: make Xwayland optional
22#include <wlr/xwayland.h> 21#include <wlr/xwayland.h>
@@ -88,11 +87,6 @@ bool server_init(struct sway_server *server) {
88 &server->xdg_shell_surface); 87 &server->xdg_shell_surface);
89 server->xdg_shell_surface.notify = handle_xdg_shell_surface; 88 server->xdg_shell_surface.notify = handle_xdg_shell_surface;
90 89
91 server->wl_shell = wlr_wl_shell_create(server->wl_display);
92 wl_signal_add(&server->wl_shell->events.new_surface,
93 &server->wl_shell_surface);
94 server->wl_shell_surface.notify = handle_wl_shell_surface;
95
96 // TODO make xwayland optional 90 // TODO make xwayland optional
97 server->xwayland = 91 server->xwayland =
98 wlr_xwayland_create(server->wl_display, server->compositor, true); 92 wlr_xwayland_create(server->wl_display, server->compositor, true);
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 9f7294db..a17b20f7 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -6,7 +6,6 @@
6#include <strings.h> 6#include <strings.h>
7#include <wayland-server.h> 7#include <wayland-server.h>
8#include <wlr/types/wlr_output_layout.h> 8#include <wlr/types/wlr_output_layout.h>
9#include <wlr/types/wlr_wl_shell.h>
10#include <wlr/types/wlr_xdg_shell_v6.h> 9#include <wlr/types/wlr_xdg_shell_v6.h>
11#include <wlr/types/wlr_xdg_shell.h> 10#include <wlr/types/wlr_xdg_shell.h>
12#include "cairo.h" 11#include "cairo.h"
@@ -446,11 +445,6 @@ struct sway_container *container_at(struct sway_container *parent,
446 _surface = wlr_surface_surface_at(sview->surface, 445 _surface = wlr_surface_surface_at(sview->surface,
447 view_sx, view_sy, &_sx, &_sy); 446 view_sx, view_sy, &_sx, &_sy);
448 break; 447 break;
449 case SWAY_VIEW_WL_SHELL:
450 _surface = wlr_wl_shell_surface_surface_at(
451 sview->wlr_wl_shell_surface,
452 view_sx, view_sy, &_sx, &_sy);
453 break;
454 case SWAY_VIEW_XDG_SHELL_V6: 448 case SWAY_VIEW_XDG_SHELL_V6:
455 // the top left corner of the sway container is the 449 // the top left corner of the sway container is the
456 // coordinate of the top left corner of the window geometry 450 // coordinate of the top left corner of the window geometry
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 41dee1c4..e0e3c110 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -97,8 +97,6 @@ uint32_t view_get_window_type(struct sway_view *view) {
97 97
98const char *view_get_type(struct sway_view *view) { 98const char *view_get_type(struct sway_view *view) {
99 switch(view->type) { 99 switch(view->type) {
100 case SWAY_VIEW_WL_SHELL:
101 return "wl_shell";
102 case SWAY_VIEW_XDG_SHELL_V6: 100 case SWAY_VIEW_XDG_SHELL_V6:
103 return "xdg_shell_v6"; 101 return "xdg_shell_v6";
104 case SWAY_VIEW_XDG_SHELL: 102 case SWAY_VIEW_XDG_SHELL: