aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-04-29 09:40:58 +0100
committerLibravatar emersion <contact@emersion.fr>2018-05-14 13:26:10 +0100
commit95a10dd4f35c6ffc14d23fa3a19a784e85a31724 (patch)
tree9793561e72a8d1b1f948080b5e36f98dbfa89619 /sway/desktop
parentMerge pull request #1968 from RyanDwyer/fix-criteria (diff)
downloadsway-95a10dd4f35c6ffc14d23fa3a19a784e85a31724.tar.gz
sway-95a10dd4f35c6ffc14d23fa3a19a784e85a31724.tar.zst
sway-95a10dd4f35c6ffc14d23fa3a19a784e85a31724.zip
Kill wl_shell
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/output.c1
-rw-r--r--sway/desktop/wl_shell.c165
2 files changed, 0 insertions, 166 deletions
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}