2 #define I3__FILE__ "floating.c"
4 * vim:ts=4:sw=4:expandtab
6 * i3 - an improved dynamic tiling window manager
7 * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
9 * floating.c: Floating windows.
14 extern xcb_connection_t *conn;
17 * Calculates sum of heights and sum of widths of all currently active outputs
20 static Rect total_outputs_dimensions(void) {
22 /* Use Rect to encapsulate dimensions, ignoring x/y */
23 Rect outputs_dimensions = {0, 0, 0, 0};
24 TAILQ_FOREACH(output, &outputs, outputs) {
25 outputs_dimensions.height += output->rect.height;
26 outputs_dimensions.width += output->rect.width;
28 return outputs_dimensions;
32 * Called when a floating window is created or resized.
33 * This function resizes the window if its size is higher or lower than the
34 * configured maximum/minimum size, respectively.
37 void floating_check_size(Con *floating_con) {
38 /* Define reasonable minimal and maximal sizes for floating windows */
39 const int floating_sane_min_height = 50;
40 const int floating_sane_min_width = 75;
41 Rect floating_sane_max_dimensions;
43 /* Unless user requests otherwise (-1), ensure width/height do not exceed
44 * configured maxima or, if unconfigured, limit to combined width of all
46 if (config.floating_minimum_height != -1) {
47 if (config.floating_minimum_height == 0)
48 floating_con->rect.height = max(floating_con->rect.height, floating_sane_min_height);
50 floating_con->rect.height = max(floating_con->rect.height, config.floating_minimum_height);
52 if (config.floating_minimum_width != -1) {
53 if (config.floating_minimum_width == 0)
54 floating_con->rect.width = max(floating_con->rect.width, floating_sane_min_width);
56 floating_con->rect.width = max(floating_con->rect.width, config.floating_minimum_width);
59 /* Unless user requests otherwise (-1), raise the width/height to
60 * reasonable minimum dimensions */
61 floating_sane_max_dimensions = total_outputs_dimensions();
62 if (config.floating_maximum_height != -1) {
63 if (config.floating_maximum_height == 0)
64 floating_con->rect.height = min(floating_con->rect.height, floating_sane_max_dimensions.height);
66 floating_con->rect.height = min(floating_con->rect.height, config.floating_maximum_height);
68 if (config.floating_maximum_width != -1) {
69 if (config.floating_maximum_width == 0)
70 floating_con->rect.width = min(floating_con->rect.width, floating_sane_max_dimensions.width);
72 floating_con->rect.width = min(floating_con->rect.width, config.floating_maximum_width);
76 void floating_enable(Con *con, bool automatic) {
77 bool set_focus = (con == focused);
79 if (con->parent && con->parent->type == CT_DOCKAREA) {
80 LOG("Container is a dock window, not enabling floating mode.\n");
84 if (con_is_floating(con)) {
85 LOG("Container is already in floating mode, not doing anything.\n");
89 /* 1: If the container is a workspace container, we need to create a new
90 * split-container with the same layout and make that one floating. We
91 * cannot touch the workspace container itself because floating containers
92 * are children of the workspace. */
93 if (con->type == CT_WORKSPACE) {
94 LOG("This is a workspace, creating new container around content\n");
95 if (con_num_children(con) == 0) {
96 LOG("Workspace is empty, aborting\n");
99 /* TODO: refactor this with src/con.c:con_set_layout */
100 Con *new = con_new(NULL, NULL);
102 new->layout = con->layout;
104 /* since the new container will be set into floating mode directly
105 * afterwards, we need to copy the workspace rect. */
106 memcpy(&(new->rect), &(con->rect), sizeof(Rect));
108 Con *old_focused = TAILQ_FIRST(&(con->focus_head));
109 if (old_focused == TAILQ_END(&(con->focus_head)))
112 /* 4: move the existing cons of this workspace below the new con */
113 DLOG("Moving cons\n");
115 while (!TAILQ_EMPTY(&(con->nodes_head))) {
116 child = TAILQ_FIRST(&(con->nodes_head));
118 con_attach(child, new, true);
121 /* 4: attach the new split container to the workspace */
122 DLOG("Attaching new split to ws\n");
123 con_attach(new, con, false);
126 con_focus(old_focused);
132 /* 1: detach the container from its parent */
133 /* TODO: refactor this with tree_close() */
134 TAILQ_REMOVE(&(con->parent->nodes_head), con, nodes);
135 TAILQ_REMOVE(&(con->parent->focus_head), con, focused);
137 con_fix_percent(con->parent);
139 /* 2: create a new container to render the decoration on, add
140 * it as a floating window to the workspace */
141 Con *nc = con_new(NULL, NULL);
142 /* we need to set the parent afterwards instead of passing it as an
143 * argument to con_new() because nc would be inserted into the tiling layer
145 Con *ws = con_get_workspace(con);
147 nc->type = CT_FLOATING_CON;
148 nc->layout = L_SPLITH;
149 /* We insert nc already, even though its rect is not yet calculated. This
150 * is necessary because otherwise the workspace might be empty (and get
151 * closed in tree_close()) even though it’s not. */
152 TAILQ_INSERT_TAIL(&(ws->floating_head), nc, floating_windows);
153 TAILQ_INSERT_TAIL(&(ws->focus_head), nc, focused);
155 /* check if the parent container is empty and close it if so */
156 if ((con->parent->type == CT_CON || con->parent->type == CT_FLOATING_CON) &&
157 con_num_children(con->parent) == 0) {
158 DLOG("Old container empty after setting this child to floating, closing\n");
159 tree_close(con->parent, DONT_KILL_WINDOW, false, false);
163 sasprintf(&name, "[i3 con] floatingcon around %p", con);
164 x_set_name(nc, name);
167 /* find the height for the decorations */
168 int deco_height = config.font.height + 5;
170 DLOG("Original rect: (%d, %d) with %d x %d\n", con->rect.x, con->rect.y, con->rect.width, con->rect.height);
171 DLOG("Geometry = (%d, %d) with %d x %d\n", con->geometry.x, con->geometry.y, con->geometry.width, con->geometry.height);
172 Rect zero = { 0, 0, 0, 0 };
173 nc->rect = con->geometry;
174 /* If the geometry was not set (split containers), we need to determine a
175 * sensible one by combining the geometry of all children */
176 if (memcmp(&(nc->rect), &zero, sizeof(Rect)) == 0) {
177 DLOG("Geometry not set, combining children\n");
179 TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
180 DLOG("child geometry: %d x %d\n", child->geometry.width, child->geometry.height);
181 nc->rect.width += child->geometry.width;
182 nc->rect.height = max(nc->rect.height, child->geometry.height);
186 floating_check_size(nc);
188 /* 3: attach the child to the new parent container. We need to do this
189 * because con_border_style_rect() needs to access con->parent. */
192 con->floating = FLOATING_USER_ON;
194 /* 4: set the border style as specified with new_float */
196 con->border_style = config.default_floating_border;
198 /* Add pixels for the decoration. */
199 Rect border_style_rect = con_border_style_rect(con);
201 nc->rect.height -= border_style_rect.height;
202 nc->rect.width -= border_style_rect.width;
204 /* Add some more pixels for the title bar */
205 if(con_border_style(con) == BS_NORMAL)
206 nc->rect.height += deco_height;
208 /* Honor the X11 border */
209 nc->rect.height += con->border_width * 2;
210 nc->rect.width += con->border_width * 2;
212 /* Some clients (like GIMP’s color picker window) get mapped
213 * to (0, 0), so we push them to a reasonable position
214 * (centered over their leader) */
215 if (nc->rect.x == 0 && nc->rect.y == 0) {
217 if (con->window && con->window->leader != XCB_NONE &&
218 (leader = con_by_window_id(con->window->leader)) != NULL) {
219 DLOG("Centering above leader\n");
220 nc->rect.x = leader->rect.x + (leader->rect.width / 2) - (nc->rect.width / 2);
221 nc->rect.y = leader->rect.y + (leader->rect.height / 2) - (nc->rect.height / 2);
223 /* center the window on workspace as fallback */
224 nc->rect.x = ws->rect.x + (ws->rect.width / 2) - (nc->rect.width / 2);
225 nc->rect.y = ws->rect.y + (ws->rect.height / 2) - (nc->rect.height / 2);
229 /* Sanity check: Are the coordinates on the appropriate output? If not, we
230 * need to change them */
231 Output *current_output = get_output_containing(nc->rect.x +
232 (nc->rect.width / 2), nc->rect.y + (nc->rect.height / 2));
234 Con *correct_output = con_get_output(ws);
235 if (!current_output || current_output->con != correct_output) {
236 DLOG("This floating window is on the wrong output, fixing coordinates (currently (%d, %d))\n",
237 nc->rect.x, nc->rect.y);
239 /* If moving from one output to another, keep the relative position
240 * consistent (e.g. a centered dialog will remain centered). */
242 floating_fix_coordinates(nc, ¤t_output->con->rect, &correct_output->rect);
244 nc->rect.x = correct_output->rect.x;
245 nc->rect.y = correct_output->rect.y;
249 DLOG("Floating rect: (%d, %d) with %d x %d\n", nc->rect.x, nc->rect.y, nc->rect.width, nc->rect.height);
251 /* 5: Subtract the deco_height in order to make the floating window appear
252 * at precisely the position it specified in its original geometry (which
253 * is what applications might remember). */
254 deco_height = (con->border_style == BS_NORMAL ? config.font.height + 5 : 0);
255 nc->rect.y -= deco_height;
257 DLOG("Corrected y = %d (deco_height = %d)\n", nc->rect.y, deco_height);
259 TAILQ_INSERT_TAIL(&(nc->nodes_head), con, nodes);
260 TAILQ_INSERT_TAIL(&(nc->focus_head), con, focused);
262 /* render the cons to get initial window_rect correct */
263 render_con(nc, false);
264 render_con(con, false);
269 /* Check if we need to re-assign it to a different workspace because of its
270 * coordinates and exit if that was done successfully. */
271 if (floating_maybe_reassign_ws(nc))
274 /* Sanitize coordinates: Check if they are on any output */
275 if (get_output_containing(nc->rect.x, nc->rect.y) != NULL)
278 ELOG("No output found at destination coordinates, centering floating window on current ws\n");
279 nc->rect.x = ws->rect.x + (ws->rect.width / 2) - (nc->rect.width / 2);
280 nc->rect.y = ws->rect.y + (ws->rect.height / 2) - (nc->rect.height / 2);
283 void floating_disable(Con *con, bool automatic) {
284 if (!con_is_floating(con)) {
285 LOG("Container isn't floating, not doing anything.\n");
289 Con *ws = con_get_workspace(con);
291 /* 1: detach from parent container */
292 TAILQ_REMOVE(&(con->parent->nodes_head), con, nodes);
293 TAILQ_REMOVE(&(con->parent->focus_head), con, focused);
295 /* 2: kill parent container */
296 TAILQ_REMOVE(&(con->parent->parent->floating_head), con->parent, floating_windows);
297 TAILQ_REMOVE(&(con->parent->parent->focus_head), con->parent, focused);
298 tree_close(con->parent, DONT_KILL_WINDOW, true, false);
300 /* 3: re-attach to the parent of the currently focused con on the workspace
301 * this floating con was on */
302 Con *focused = con_descend_tiling_focused(ws);
304 /* if there is no other container on this workspace, focused will be the
305 * workspace itself */
306 if (focused->type == CT_WORKSPACE)
307 con->parent = focused;
308 else con->parent = focused->parent;
310 /* con_fix_percent will adjust the percent value */
313 con->floating = FLOATING_USER_OFF;
315 con_attach(con, con->parent, false);
317 con_fix_percent(con->parent);
318 // TODO: don’t influence focus handling when Con was not focused before.
323 * Toggles floating mode for the given container.
325 * If the automatic flag is set to true, this was an automatic update by a change of the
326 * window class from the application which can be overwritten by the user.
329 void toggle_floating_mode(Con *con, bool automatic) {
330 /* see if the client is already floating */
331 if (con_is_floating(con)) {
332 LOG("already floating, re-setting to tiling\n");
334 floating_disable(con, automatic);
338 floating_enable(con, automatic);
342 * Raises the given container in the list of floating containers
345 void floating_raise_con(Con *con) {
346 DLOG("Raising floating con %p / %s\n", con, con->name);
347 TAILQ_REMOVE(&(con->parent->floating_head), con, floating_windows);
348 TAILQ_INSERT_TAIL(&(con->parent->floating_head), con, floating_windows);
352 * Checks if con’s coordinates are within its workspace and re-assigns it to
353 * the actual workspace if not.
356 bool floating_maybe_reassign_ws(Con *con) {
357 Output *output = get_output_containing(
358 con->rect.x + (con->rect.width / 2),
359 con->rect.y + (con->rect.height / 2));
362 ELOG("No output found at destination coordinates?\n");
366 if (con_get_output(con) == output->con) {
367 DLOG("still the same ws\n");
371 DLOG("Need to re-assign!\n");
373 Con *content = output_get_content(output->con);
374 Con *ws = TAILQ_FIRST(&(content->focus_head));
375 DLOG("Moving con %p / %s to workspace %p / %s\n", con, con->name, ws, ws->name);
376 con_move_to_workspace(con, ws, false, true);
377 con_focus(con_descend_focused(con));
381 DRAGGING_CB(drag_window_callback) {
382 const struct xcb_button_press_event_t *event = extra;
384 /* Reposition the client correctly while moving */
385 con->rect.x = old_rect->x + (new_x - event->root_x);
386 con->rect.y = old_rect->y + (new_y - event->root_y);
388 render_con(con, false);
392 /* Check if we cross workspace boundaries while moving */
393 if (!floating_maybe_reassign_ws(con))
399 * Called when the user clicked on the titlebar of a floating window.
400 * Calls the drag_pointer function with the drag_window callback
403 void floating_drag_window(Con *con, const xcb_button_press_event_t *event) {
404 DLOG("floating_drag_window\n");
406 /* Push changes before dragging, so that the window gets raised now and not
407 * after the user releases the mouse button */
410 /* Drag the window */
411 drag_pointer(con, event, XCB_NONE, BORDER_TOP /* irrelevant */, XCURSOR_CURSOR_MOVE, drag_window_callback, event);
416 * This is an ugly data structure which we need because there is no standard
417 * way of having nested functions (only available as a gcc extension at the
418 * moment, clang doesn’t support it) or blocks (only available as a clang
419 * extension and only on Mac OS X systems at the moment).
422 struct resize_window_callback_params {
423 const border_t corner;
424 const bool proportional;
425 const xcb_button_press_event_t *event;
428 DRAGGING_CB(resize_window_callback) {
429 const struct resize_window_callback_params *params = extra;
430 const xcb_button_press_event_t *event = params->event;
431 border_t corner = params->corner;
433 int32_t dest_x = con->rect.x;
434 int32_t dest_y = con->rect.y;
436 uint32_t dest_height;
438 double ratio = (double) old_rect->width / old_rect->height;
440 /* First guess: We resize by exactly the amount the mouse moved,
441 * taking into account in which corner the client was grabbed */
442 if (corner & BORDER_LEFT)
443 dest_width = old_rect->width - (new_x - event->root_x);
444 else dest_width = old_rect->width + (new_x - event->root_x);
446 if (corner & BORDER_TOP)
447 dest_height = old_rect->height - (new_y - event->root_y);
448 else dest_height = old_rect->height + (new_y - event->root_y);
450 /* Obey minimum window size */
451 Rect minimum = con_minimum_size(con);
452 dest_width = max(dest_width, minimum.width);
453 dest_height = max(dest_height, minimum.height);
455 /* User wants to keep proportions, so we may have to adjust our values */
456 if (params->proportional) {
457 dest_width = max(dest_width, (int) (dest_height * ratio));
458 dest_height = max(dest_height, (int) (dest_width / ratio));
461 /* If not the lower right corner is grabbed, we must also reposition
462 * the client by exactly the amount we resized it */
463 if (corner & BORDER_LEFT)
464 dest_x = old_rect->x + (old_rect->width - dest_width);
466 if (corner & BORDER_TOP)
467 dest_y = old_rect->y + (old_rect->height - dest_height);
469 con->rect = (Rect) { dest_x, dest_y, dest_width, dest_height };
471 /* TODO: don’t re-render the whole tree just because we change
472 * coordinates of a floating window */
474 x_push_changes(croot);
478 * Called when the user clicked on a floating window while holding the
479 * floating_modifier and the right mouse button.
480 * Calls the drag_pointer function with the resize_window callback
483 void floating_resize_window(Con *con, const bool proportional,
484 const xcb_button_press_event_t *event) {
485 DLOG("floating_resize_window\n");
487 /* corner saves the nearest corner to the original click. It contains
488 * a bitmask of the nearest borders (BORDER_LEFT, BORDER_RIGHT, …) */
491 if (event->event_x <= (con->rect.width / 2))
492 corner |= BORDER_LEFT;
493 else corner |= BORDER_RIGHT;
496 if (event->event_y <= (con->rect.height / 2)) {
497 corner |= BORDER_TOP;
498 cursor = (corner & BORDER_LEFT) ?
499 XCURSOR_CURSOR_TOP_LEFT_CORNER : XCURSOR_CURSOR_TOP_RIGHT_CORNER;
502 corner |= BORDER_BOTTOM;
503 cursor = (corner & BORDER_LEFT) ?
504 XCURSOR_CURSOR_BOTTOM_LEFT_CORNER : XCURSOR_CURSOR_BOTTOM_RIGHT_CORNER;
507 struct resize_window_callback_params params = { corner, proportional, event };
509 drag_pointer(con, event, XCB_NONE, BORDER_TOP /* irrelevant */, cursor, resize_window_callback, ¶ms);
513 * This function grabs your pointer and lets you drag stuff around (borders).
514 * Every time you move your mouse, an XCB_MOTION_NOTIFY event will be received
515 * and the given callback will be called with the parameters specified (client,
516 * border on which the click originally was), the original rect of the client,
517 * the event and the new coordinates (x, y).
520 void drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_window_t
521 confine_to, border_t border, int cursor, callback_t callback, const void *extra)
523 uint32_t new_x, new_y;
524 Rect old_rect = { 0, 0, 0, 0 };
526 memcpy(&old_rect, &(con->rect), sizeof(Rect));
528 Cursor xcursor = (cursor && xcursor_supported) ?
529 xcursor_get_cursor(cursor) : XCB_NONE;
531 /* Grab the pointer */
532 xcb_grab_pointer_cookie_t cookie;
533 xcb_grab_pointer_reply_t *reply;
534 cookie = xcb_grab_pointer(conn,
535 false, /* get all pointer events specified by the following mask */
536 root, /* grab the root window */
537 XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION, /* which events to let through */
538 XCB_GRAB_MODE_ASYNC, /* pointer events should continue as normal */
539 XCB_GRAB_MODE_ASYNC, /* keyboard mode */
540 confine_to, /* confine_to = in which window should the cursor stay */
541 xcursor, /* possibly display a special cursor */
544 if ((reply = xcb_grab_pointer_reply(conn, cookie, NULL)) == NULL) {
545 ELOG("Could not grab pointer\n");
551 /* Go into our own event loop */
554 xcb_generic_event_t *inside_event, *last_motion_notify = NULL;
555 bool loop_done = false;
556 /* I’ve always wanted to have my own eventhandler… */
557 while (!loop_done && (inside_event = xcb_wait_for_event(conn))) {
558 /* We now handle all events we can get using xcb_poll_for_event */
560 /* skip x11 errors */
561 if (inside_event->response_type == 0) {
565 /* Strip off the highest bit (set if the event is generated) */
566 int type = (inside_event->response_type & 0x7F);
569 case XCB_BUTTON_RELEASE:
573 case XCB_MOTION_NOTIFY:
574 /* motion_notify events are saved for later */
575 FREE(last_motion_notify);
576 last_motion_notify = inside_event;
579 case XCB_UNMAP_NOTIFY:
581 case XCB_KEY_RELEASE:
582 DLOG("Unmap-notify, aborting\n");
583 handle_event(type, inside_event);
588 DLOG("Passing to original handler\n");
589 /* Use original handler */
590 handle_event(type, inside_event);
593 if (last_motion_notify != inside_event)
595 } while ((inside_event = xcb_poll_for_event(conn)) != NULL);
597 if (last_motion_notify == NULL || loop_done)
600 new_x = ((xcb_motion_notify_event_t*)last_motion_notify)->root_x;
601 new_y = ((xcb_motion_notify_event_t*)last_motion_notify)->root_y;
603 callback(con, &old_rect, new_x, new_y, extra);
604 FREE(last_motion_notify);
607 xcb_ungrab_pointer(conn, XCB_CURRENT_TIME);
612 * Repositions the CT_FLOATING_CON to have the coordinates specified by
613 * newrect, but only if the coordinates are not out-of-bounds. Also reassigns
614 * the floating con to a different workspace if this move was across different
618 void floating_reposition(Con *con, Rect newrect) {
619 /* Sanity check: Are the new coordinates on any output? If not, we
620 * ignore that request. */
621 Output *output = get_output_containing(
622 newrect.x + (newrect.width / 2),
623 newrect.y + (newrect.height / 2));
626 ELOG("No output found at destination coordinates. Not repositioning.\n");
632 floating_maybe_reassign_ws(con);
637 * Fixes the coordinates of the floating window whenever the window gets
638 * reassigned to a different output (or when the output’s rect changes).
641 void floating_fix_coordinates(Con *con, Rect *old_rect, Rect *new_rect) {
642 DLOG("Fixing coordinates of floating window %p (rect (%d, %d), %d x %d)\n",
643 con, con->rect.x, con->rect.y, con->rect.width, con->rect.height);
644 DLOG("old_rect = (%d, %d), %d x %d\n",
645 old_rect->x, old_rect->y, old_rect->width, old_rect->height);
646 DLOG("new_rect = (%d, %d), %d x %d\n",
647 new_rect->x, new_rect->y, new_rect->width, new_rect->height);
648 /* First we get the x/y coordinates relative to the x/y coordinates
649 * of the output on which the window is on */
650 int32_t rel_x = con->rect.x - old_rect->x + (int32_t)(con->rect.width / 2);
651 int32_t rel_y = con->rect.y - old_rect->y + (int32_t)(con->rect.height / 2);
652 /* Then we calculate a fraction, for example 0.63 for a window
653 * which is at y = 1212 of a 1920 px high output */
654 DLOG("rel_x = %d, rel_y = %d, fraction_x = %f, fraction_y = %f, output->w = %d, output->h = %d\n",
655 rel_x, rel_y, (double)rel_x / old_rect->width, (double)rel_y / old_rect->height,
656 old_rect->width, old_rect->height);
657 /* Here we have to multiply at first. Or we will lose precision when not compiled with -msse2 */
658 con->rect.x = (int32_t)new_rect->x + (double)(rel_x * (int32_t)new_rect->width)
659 / (int32_t)old_rect->width - (int32_t)(con->rect.width / 2);
660 con->rect.y = (int32_t)new_rect->y + (double)(rel_y * (int32_t)new_rect->height)
661 / (int32_t)old_rect->height - (int32_t)(con->rect.height / 2);
662 DLOG("Resulting coordinates: x = %d, y = %d\n", con->rect.x, con->rect.y);
667 * Moves the client 10px to the specified direction.
670 void floating_move(xcb_connection_t *conn, Client *currently_focused, direction_t direction) {
671 DLOG("floating move\n");
673 Rect destination = currently_focused->rect;
674 Rect *screen = &(currently_focused->workspace->output->rect);
689 /* to make static analyzers happy */
694 /* Prevent windows from vanishing completely */
695 if ((int32_t)(destination.x + destination.width - 5) <= (int32_t)screen->x ||
696 (int32_t)(destination.x + 5) >= (int32_t)(screen->x + screen->width) ||
697 (int32_t)(destination.y + destination.height - 5) <= (int32_t)screen->y ||
698 (int32_t)(destination.y + 5) >= (int32_t)(screen->y + screen->height)) {
699 DLOG("boundary check failed, not moving\n");
703 currently_focused->rect = destination;
704 reposition_client(conn, currently_focused);
706 /* Because reposition_client does not send a faked configure event (only resize does),
707 * we need to initiate that on our own */
708 fake_absolute_configure_notify(conn, currently_focused);
709 /* fake_absolute_configure_notify flushes */
713 * Hides all floating clients (or show them if they are currently hidden) on
714 * the specified workspace.
717 void floating_toggle_hide(xcb_connection_t *conn, Workspace *workspace) {
720 workspace->floating_hidden = !workspace->floating_hidden;
721 DLOG("floating_hidden is now: %d\n", workspace->floating_hidden);
722 TAILQ_FOREACH(client, &(workspace->floating_clients), floating_clients) {
723 if (workspace->floating_hidden)
724 client_unmap(conn, client);
725 else client_map(conn, client);
728 /* If we just unmapped all floating windows we should ensure that the focus
729 * is set correctly, that ist, to the first non-floating client in stack */
730 if (workspace->floating_hidden)
731 SLIST_FOREACH(client, &(workspace->focus_stack), focus_clients) {
732 if (client_is_floating(client))
734 set_focus(conn, client, true);