diff options
Diffstat (limited to 'sway/handlers.c')
-rw-r--r-- | sway/handlers.c | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index 3e83b850..85df09f7 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include "handlers.h" | 10 | #include "handlers.h" |
11 | #include "stringop.h" | 11 | #include "stringop.h" |
12 | #include "workspace.h" | 12 | #include "workspace.h" |
13 | #include "container.h" | ||
13 | 14 | ||
14 | static struct wlc_origin mouse_origin; | 15 | static struct wlc_origin mouse_origin; |
15 | 16 | ||
@@ -88,17 +89,24 @@ static void handle_output_focused(wlc_handle output, bool focus) { | |||
88 | static bool handle_view_created(wlc_handle handle) { | 89 | static bool handle_view_created(wlc_handle handle) { |
89 | swayc_t *focused = get_focused_container(&root_container); | 90 | swayc_t *focused = get_focused_container(&root_container); |
90 | uint32_t type = wlc_view_get_type(handle); | 91 | uint32_t type = wlc_view_get_type(handle); |
91 | //If override_redirect/unmanaged/popup/modal/splach | 92 | // If override_redirect/unmanaged/popup/modal/splach |
92 | if (type) { | 93 | if (type) { |
93 | sway_log(L_DEBUG,"Unmanaged window of type %x left alone", type); | 94 | sway_log(L_DEBUG,"Unmanaged window of type %x left alone", type); |
94 | wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true); | 95 | wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true); |
95 | if (type & WLC_BIT_UNMANAGED) { | 96 | if (type & WLC_BIT_UNMANAGED) { |
96 | return true; | 97 | return true; |
97 | } | 98 | } |
98 | //for things like Dmenu | 99 | // For things like Dmenu |
99 | if (type & WLC_BIT_OVERRIDE_REDIRECT) { | 100 | if (type & WLC_BIT_OVERRIDE_REDIRECT) { |
100 | wlc_view_focus(handle); | 101 | wlc_view_focus(handle); |
101 | } | 102 | } |
103 | |||
104 | // Float popups | ||
105 | if (type & WLC_BIT_POPUP) { | ||
106 | swayc_t *view = new_floating_view(handle); | ||
107 | focus_view(view); | ||
108 | arrange_windows(active_workspace, -1, -1); | ||
109 | } | ||
102 | } else { | 110 | } else { |
103 | swayc_t *view = new_view(focused, handle); | 111 | swayc_t *view = new_view(focused, handle); |
104 | //Set maximize flag for windows. | 112 | //Set maximize flag for windows. |
@@ -118,6 +126,24 @@ static bool handle_view_created(wlc_handle handle) { | |||
118 | 126 | ||
119 | static void handle_view_destroyed(wlc_handle handle) { | 127 | static void handle_view_destroyed(wlc_handle handle) { |
120 | sway_log(L_DEBUG, "Destroying window %u", (unsigned int)handle); | 128 | sway_log(L_DEBUG, "Destroying window %u", (unsigned int)handle); |
129 | |||
130 | // Properly handle unmanaged views | ||
131 | uint32_t type = wlc_view_get_type(handle); | ||
132 | if (type) { | ||
133 | wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true); | ||
134 | sway_log(L_DEBUG,"Unmanaged window of type %x was destroyed", type); | ||
135 | if (type & WLC_BIT_UNMANAGED) { | ||
136 | focus_view(focus_pointer()); | ||
137 | arrange_windows(active_workspace, -1, -1); | ||
138 | return; | ||
139 | } | ||
140 | |||
141 | if (type & WLC_BIT_OVERRIDE_REDIRECT) { | ||
142 | focus_view(focus_pointer()); | ||
143 | arrange_windows(active_workspace, -1, -1); | ||
144 | return; | ||
145 | } | ||
146 | } | ||
121 | swayc_t *view = get_swayc_for_handle(handle, &root_container); | 147 | swayc_t *view = get_swayc_for_handle(handle, &root_container); |
122 | swayc_t *parent; | 148 | swayc_t *parent; |
123 | swayc_t *focused = get_focused_container(&root_container); | 149 | swayc_t *focused = get_focused_container(&root_container); |
@@ -135,8 +161,23 @@ static void handle_view_focus(wlc_handle view, bool focus) { | |||
135 | return; | 161 | return; |
136 | } | 162 | } |
137 | 163 | ||
138 | static void handle_view_geometry_request(wlc_handle view, const struct wlc_geometry* geometry) { | 164 | static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geometry* geometry) { |
139 | // deny that shit | 165 | // If the view is floating, then apply the geometry. |
166 | // Otherwise save the desired width/height for the view. | ||
167 | // This will not do anything for the time being as WLC improperly sends geometry requests | ||
168 | swayc_t *view = get_swayc_for_handle(handle, &root_container); | ||
169 | if (view) { | ||
170 | if (view->is_floating) { | ||
171 | view->width = geometry->size.w; | ||
172 | view->height = geometry->size.h; | ||
173 | view->x = geometry->origin.x; | ||
174 | view->y = geometry->origin.y; | ||
175 | arrange_windows(view->parent, -1, -1); | ||
176 | } else { | ||
177 | view->desired_width = geometry->size.w; | ||
178 | view->desired_height = geometry->size.h; | ||
179 | } | ||
180 | } | ||
140 | } | 181 | } |
141 | 182 | ||
142 | static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit state, bool toggle) { | 183 | static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit state, bool toggle) { |