summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-08-19 15:09:14 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-08-19 15:09:14 -0400
commit4ac920827d93a994b9132652b1c7ae54dc73c71c (patch)
tree9484f1f76b2d24076f9ce2bbb1c2435569568569
parentMerge pull request #88 from aouelete/master (diff)
parentstyle (diff)
downloadsway-4ac920827d93a994b9132652b1c7ae54dc73c71c.tar.gz
sway-4ac920827d93a994b9132652b1c7ae54dc73c71c.tar.zst
sway-4ac920827d93a994b9132652b1c7ae54dc73c71c.zip
Merge pull request #89 from taiyu-len/master
reset floating view on floating_mod repress
-rw-r--r--sway/handlers.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index 71691d7d..f7d5386a 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -91,6 +91,31 @@ swayc_t *container_under_pointer(void) {
91 return lookup; 91 return lookup;
92} 92}
93 93
94static struct wlc_geometry saved_floating;
95
96static void start_floating(swayc_t *view) {
97 if (view->is_floating) {
98 saved_floating.origin.x = view->x;
99 saved_floating.origin.y = view->y;
100 saved_floating.size.w = view->width;
101 saved_floating.size.h = view->height;
102 }
103}
104
105static void reset_floating(swayc_t *view) {
106 if (view->is_floating) {
107 view->x = saved_floating.origin.x;
108 view->y = saved_floating.origin.y;
109 view->width = saved_floating.size.w;
110 view->height = saved_floating.size.h;
111 arrange_windows(view->parent, -1, -1);
112 }
113 dragging = resizing = false;
114 lock_left = lock_right = lock_top = lock_bottom = false;
115}
116
117/* Handles */
118
94static bool handle_output_created(wlc_handle output) { 119static bool handle_output_created(wlc_handle output) {
95 swayc_t *op = new_output(output); 120 swayc_t *op = new_output(output);
96 121
@@ -233,7 +258,7 @@ static void handle_view_focus(wlc_handle view, bool focus) {
233 258
234static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geometry *geometry) { 259static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geometry *geometry) {
235 sway_log(L_DEBUG, "geometry request %d x %d : %d x %d", 260 sway_log(L_DEBUG, "geometry request %d x %d : %d x %d",
236 geometry->origin.x, geometry->origin.y, geometry->size.w,geometry->size.h); 261 geometry->origin.x, geometry->origin.y, geometry->size.w, geometry->size.h);
237 // If the view is floating, then apply the geometry. 262 // If the view is floating, then apply the geometry.
238 // Otherwise save the desired width/height for the view. 263 // Otherwise save the desired width/height for the view.
239 // This will not do anything for the time being as WLC improperly sends geometry requests 264 // This will not do anything for the time being as WLC improperly sends geometry requests
@@ -254,12 +279,12 @@ static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geo
254 279
255static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit state, bool toggle) { 280static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit state, bool toggle) {
256 swayc_t *c = NULL; 281 swayc_t *c = NULL;
257 switch(state) { 282 switch (state) {
258 case WLC_BIT_FULLSCREEN: 283 case WLC_BIT_FULLSCREEN:
259 // i3 just lets it become fullscreen 284 // i3 just lets it become fullscreen
260 wlc_view_set_state(view, state, toggle); 285 wlc_view_set_state(view, state, toggle);
261 c = get_swayc_for_handle(view, &root_container); 286 c = get_swayc_for_handle(view, &root_container);
262 sway_log(L_DEBUG, "setting view %ld %s, fullscreen %d",view,c->name,toggle); 287 sway_log(L_DEBUG, "setting view %ld %s, fullscreen %d", view, c->name, toggle);
263 if (c) { 288 if (c) {
264 arrange_windows(c->parent, -1, -1); 289 arrange_windows(c->parent, -1, -1);
265 // Set it as focused window for that workspace if its going fullscreen 290 // Set it as focused window for that workspace if its going fullscreen
@@ -291,6 +316,10 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
291 } 316 }
292 bool cmd_success = false; 317 bool cmd_success = false;
293 318
319 if ((modifiers->mods & config->floating_mod) && (dragging || resizing)) {
320 reset_floating(get_focused_view(&root_container));
321 }
322
294 struct sway_mode *mode = config->current_mode; 323 struct sway_mode *mode = config->current_mode;
295 // Lowercase if necessary 324 // Lowercase if necessary
296 sym = tolower(sym); 325 sym = tolower(sym);
@@ -500,6 +529,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
500 lock_top = !lock_bottom; 529 lock_top = !lock_bottom;
501 lock_right = origin->x < midway_x; 530 lock_right = origin->x < midway_x;
502 lock_left = !lock_right; 531 lock_left = !lock_right;
532 start_floating(pointer);
503 } 533 }
504 //Dont want pointer sent to window while dragging or resizing 534 //Dont want pointer sent to window while dragging or resizing
505 return (dragging || resizing); 535 return (dragging || resizing);