1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 focus.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003 Ben Jansens
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 See the COPYING file for a copy of the GNU General Public License.
24 #include "framerender.h"
34 #include "render/render.h"
40 ObClient
*focus_client
, *focus_hilite
;
41 GList
**focus_order
; /* these lists are created when screen_startup
42 sets the number of desktops */
43 ObClient
*focus_cycle_target
;
49 InternalWindow bottom
;
52 RrAppearance
*a_focus_indicator
;
55 static ObIconPopup
*focus_cycle_popup
;
57 static void focus_cycle_destructor(ObClient
*client
, gpointer data
)
59 /* end cycling if the target disappears. CurrentTime is fine, time won't
62 if (focus_cycle_target
== client
)
63 focus_cycle(TRUE
, TRUE
, TRUE
, TRUE
, TRUE
, TRUE
, CurrentTime
);
66 static Window
createWindow(Window parent
, gulong mask
,
67 XSetWindowAttributes
*attrib
)
69 return XCreateWindow(ob_display
, parent
, 0, 0, 1, 1, 0,
70 RrDepth(ob_rr_inst
), InputOutput
,
71 RrVisual(ob_rr_inst
), mask
, attrib
);
75 void focus_startup(gboolean reconfig
)
77 focus_cycle_popup
= icon_popup_new(TRUE
);
80 XSetWindowAttributes attr
;
82 client_add_destructor(focus_cycle_destructor
, NULL
);
84 /* start with nothing focused */
85 focus_set_client(NULL
);
87 focus_indicator
.top
.obwin
.type
= Window_Internal
;
88 focus_indicator
.left
.obwin
.type
= Window_Internal
;
89 focus_indicator
.right
.obwin
.type
= Window_Internal
;
90 focus_indicator
.bottom
.obwin
.type
= Window_Internal
;
92 attr
.override_redirect
= True
;
93 attr
.background_pixel
= BlackPixel(ob_display
, ob_screen
);
94 focus_indicator
.top
.win
=
95 createWindow(RootWindow(ob_display
, ob_screen
),
96 CWOverrideRedirect
| CWBackPixel
, &attr
);
97 focus_indicator
.left
.win
=
98 createWindow(RootWindow(ob_display
, ob_screen
),
99 CWOverrideRedirect
| CWBackPixel
, &attr
);
100 focus_indicator
.right
.win
=
101 createWindow(RootWindow(ob_display
, ob_screen
),
102 CWOverrideRedirect
| CWBackPixel
, &attr
);
103 focus_indicator
.bottom
.win
=
104 createWindow(RootWindow(ob_display
, ob_screen
),
105 CWOverrideRedirect
| CWBackPixel
, &attr
);
107 stacking_add(INTERNAL_AS_WINDOW(&focus_indicator
.top
));
108 stacking_add(INTERNAL_AS_WINDOW(&focus_indicator
.left
));
109 stacking_add(INTERNAL_AS_WINDOW(&focus_indicator
.right
));
110 stacking_add(INTERNAL_AS_WINDOW(&focus_indicator
.bottom
));
112 color_white
= RrColorNew(ob_rr_inst
, 0xff, 0xff, 0xff);
114 a_focus_indicator
= RrAppearanceNew(ob_rr_inst
, 4);
115 a_focus_indicator
->surface
.grad
= RR_SURFACE_SOLID
;
116 a_focus_indicator
->surface
.relief
= RR_RELIEF_FLAT
;
117 a_focus_indicator
->surface
.primary
= RrColorNew(ob_rr_inst
,
119 a_focus_indicator
->texture
[0].type
= RR_TEXTURE_LINE_ART
;
120 a_focus_indicator
->texture
[0].data
.lineart
.color
= color_white
;
121 a_focus_indicator
->texture
[1].type
= RR_TEXTURE_LINE_ART
;
122 a_focus_indicator
->texture
[1].data
.lineart
.color
= color_white
;
123 a_focus_indicator
->texture
[2].type
= RR_TEXTURE_LINE_ART
;
124 a_focus_indicator
->texture
[2].data
.lineart
.color
= color_white
;
125 a_focus_indicator
->texture
[3].type
= RR_TEXTURE_LINE_ART
;
126 a_focus_indicator
->texture
[3].data
.lineart
.color
= color_white
;
130 void focus_shutdown(gboolean reconfig
)
134 icon_popup_free(focus_cycle_popup
);
137 client_remove_destructor(focus_cycle_destructor
);
139 for (i
= 0; i
< screen_num_desktops
; ++i
)
140 g_list_free(focus_order
[i
]);
143 /* reset focus to root */
144 XSetInputFocus(ob_display
, PointerRoot
, RevertToNone
, CurrentTime
);
146 RrColorFree(color_white
);
148 RrAppearanceFree(a_focus_indicator
);
150 XDestroyWindow(ob_display
, focus_indicator
.top
.win
);
151 XDestroyWindow(ob_display
, focus_indicator
.left
.win
);
152 XDestroyWindow(ob_display
, focus_indicator
.right
.win
);
153 XDestroyWindow(ob_display
, focus_indicator
.bottom
.win
);
157 static void push_to_top(ObClient
*client
)
161 desktop
= client
->desktop
;
162 if (desktop
== DESKTOP_ALL
) desktop
= screen_desktop
;
163 focus_order
[desktop
] = g_list_remove(focus_order
[desktop
], client
);
164 focus_order
[desktop
] = g_list_prepend(focus_order
[desktop
], client
);
167 void focus_set_client(ObClient
*client
)
173 ob_debug("focus_set_client 0x%lx\n", client
? client
->window
: 0);
176 /* uninstall the old colormap, and install the new one */
177 screen_install_colormap(focus_client
, FALSE
);
178 screen_install_colormap(client
, TRUE
);
180 if (client
== NULL
) {
182 ob_debug("actively focusing NONWINDOW\n");
184 /* when nothing will be focused, send focus to the backup target */
185 XSetInputFocus(ob_display
, screen_support_win
, RevertToNone
,
187 XSync(ob_display
, FALSE
);
190 /* in the middle of cycling..? kill it. CurrentTime is fine, time won't
193 if (focus_cycle_target
)
194 focus_cycle(TRUE
, TRUE
, TRUE
, TRUE
, TRUE
, TRUE
, CurrentTime
);
197 focus_client
= client
;
199 /* move to the top of the list */
203 /* set the NET_ACTIVE_WINDOW hint, but preserve it on shutdown */
204 if (ob_state() != OB_STATE_EXITING
) {
205 active
= client
? client
->window
: None
;
206 PROP_SET32(RootWindow(ob_display
, ob_screen
),
207 net_active_window
, window
, active
);
209 /* remove hiliting from the window when it gets focused */
211 client_hilite(client
, FALSE
);
215 /* finds the first transient that isn't 'skip' and ensure's that client_normal
217 static ObClient
*find_transient_recursive(ObClient
*c
, ObClient
*top
,
223 for (it
= c
->transients
; it
; it
= g_slist_next(it
)) {
224 if (it
->data
== top
) return NULL
;
225 ret
= find_transient_recursive(it
->data
, top
, skip
);
226 if (ret
&& ret
!= skip
&& client_normal(ret
)) return ret
;
227 if (it
->data
!= skip
&& client_normal(it
->data
)) return it
->data
;
232 static ObClient
* focus_fallback_transient(ObClient
*top
, ObClient
*old
)
234 ObClient
*target
= find_transient_recursive(top
, top
, old
);
236 /* make sure client_normal is true always */
237 if (!client_normal(top
))
239 target
= top
; /* no transient, keep the top */
241 if (client_can_focus(target
))
247 ObClient
* focus_fallback_target(ObFocusFallbackType type
, ObClient
*old
)
250 ObClient
*target
= NULL
;
252 if ((type
== OB_FOCUS_FALLBACK_UNFOCUSING
253 || type
== OB_FOCUS_FALLBACK_CLOSED
) && old
) {
254 if (old
->transient_for
) {
255 gboolean trans
= FALSE
;
257 if (!config_focus_follow
|| config_focus_last
)
260 if ((target
= client_under_pointer())) {
263 sit
= client_search_top_transients(target
);
264 for (; sit
; sit
= g_slist_next(sit
))
265 if (client_search_transient(sit
->data
, old
)) {
272 /* try for transient relations */
274 if (old
->transient_for
== OB_TRAN_GROUP
) {
275 for (it
= focus_order
[screen_desktop
]; it
;
276 it
= g_list_next(it
))
280 for (sit
= old
->group
->members
; sit
;
281 sit
= g_slist_next(sit
))
283 if (sit
->data
== it
->data
)
285 focus_fallback_transient(sit
->data
, old
)))
291 focus_fallback_transient(old
->transient_for
, old
)))
298 if (config_focus_follow
&&
299 (type
== OB_FOCUS_FALLBACK_UNFOCUSING
|| !config_focus_last
))
301 if ((target
= client_under_pointer()))
302 if (client_normal(target
) && client_can_focus(target
))
307 /* try for group relations */
311 for (it
= focus_order
[screen_desktop
]; it
; it
= g_list_next(it
))
312 for (sit
= old
->group
->members
; sit
; sit
= g_slist_next(sit
))
313 if (sit
->data
== it
->data
)
314 if (sit
->data
!= old
&& client_normal(sit
->data
))
315 if (client_can_focus(sit
->data
))
320 for (it
= focus_order
[screen_desktop
]; it
; it
= g_list_next(it
))
321 if (type
!= OB_FOCUS_FALLBACK_UNFOCUSING
|| it
->data
!= old
)
322 if (client_normal(it
->data
) && client_can_focus(it
->data
))
325 /* XXX fallback to the "desktop window" if one exists ?
326 could store it while going through all the windows in the loop right
333 void focus_fallback(ObFocusFallbackType type
)
336 ObClient
*old
= focus_client
;
338 /* unfocus any focused clients.. they can be focused by Pointer events
339 and such, and then when I try focus them, I won't get a FocusIn event
342 focus_set_client(NULL
);
344 if ((new = focus_fallback_target(type
, old
)))
348 static void popup_cycle(ObClient
*c
, gboolean show
)
351 icon_popup_hide(focus_cycle_popup
);
357 a
= screen_physical_area_monitor(0);
358 icon_popup_position(focus_cycle_popup
, CenterGravity
,
359 a
->x
+ a
->width
/ 2, a
->y
+ a
->height
/ 2);
360 /* icon_popup_size(focus_cycle_popup, a->height/2, a->height/16);
361 icon_popup_show(focus_cycle_popup, c->title,
362 client_icon(c, a->height/16, a->height/16));
364 /* XXX the size and the font extents need to be related on some level
366 icon_popup_size(focus_cycle_popup
, POPUP_WIDTH
, POPUP_HEIGHT
);
368 /* use the transient's parent's title/icon */
369 while (p
->transient_for
&& p
->transient_for
!= OB_TRAN_GROUP
)
370 p
= p
->transient_for
;
372 if (p
!= c
&& !strcmp("", (c
->iconic
? c
->icon_title
: c
->title
)))
373 title
= g_strdup(p
->iconic
? p
->icon_title
: p
->title
);
374 /*title = g_strconcat((c->iconic ? c->icon_title : c->title),
376 (p->iconic ? p->icon_title : p->title),
379 icon_popup_show(focus_cycle_popup
,
381 (c
->iconic
? c
->icon_title
: c
->title
)),
382 client_icon(p
, 48, 48));
387 void focus_cycle_draw_indicator()
389 if (!focus_cycle_target
) {
390 XUnmapWindow(ob_display
, focus_indicator
.top
.win
);
391 XUnmapWindow(ob_display
, focus_indicator
.left
.win
);
392 XUnmapWindow(ob_display
, focus_indicator
.right
.win
);
393 XUnmapWindow(ob_display
, focus_indicator
.bottom
.win
);
396 if (focus_cycle_target)
397 frame_adjust_focus(focus_cycle_target->frame, FALSE);
398 frame_adjust_focus(focus_cycle_target->frame, TRUE);
403 wt
= wl
= wr
= wb
= MAX(3,
404 MAX(1, MAX(ob_rr_theme
->paddingx
,
405 ob_rr_theme
->paddingy
)) * 2 +
406 ob_rr_theme
->fbwidth
* 2);
408 x
= focus_cycle_target
->frame
->area
.x
;
409 y
= focus_cycle_target
->frame
->area
.y
;
410 w
= focus_cycle_target
->frame
->area
.width
;
413 XMoveResizeWindow(ob_display
, focus_indicator
.top
.win
,
415 a_focus_indicator
->texture
[0].data
.lineart
.x1
= 0;
416 a_focus_indicator
->texture
[0].data
.lineart
.y1
= h
-1;
417 a_focus_indicator
->texture
[0].data
.lineart
.x2
= 0;
418 a_focus_indicator
->texture
[0].data
.lineart
.y2
= 0;
419 a_focus_indicator
->texture
[1].data
.lineart
.x1
= 0;
420 a_focus_indicator
->texture
[1].data
.lineart
.y1
= 0;
421 a_focus_indicator
->texture
[1].data
.lineart
.x2
= w
-1;
422 a_focus_indicator
->texture
[1].data
.lineart
.y2
= 0;
423 a_focus_indicator
->texture
[2].data
.lineart
.x1
= w
-1;
424 a_focus_indicator
->texture
[2].data
.lineart
.y1
= 0;
425 a_focus_indicator
->texture
[2].data
.lineart
.x2
= w
-1;
426 a_focus_indicator
->texture
[2].data
.lineart
.y2
= h
-1;
427 a_focus_indicator
->texture
[3].data
.lineart
.x1
= (wl
-1);
428 a_focus_indicator
->texture
[3].data
.lineart
.y1
= h
-1;
429 a_focus_indicator
->texture
[3].data
.lineart
.x2
= w
- wr
;
430 a_focus_indicator
->texture
[3].data
.lineart
.y2
= h
-1;
431 RrPaint(a_focus_indicator
, focus_indicator
.top
.win
,
434 x
= focus_cycle_target
->frame
->area
.x
;
435 y
= focus_cycle_target
->frame
->area
.y
;
437 h
= focus_cycle_target
->frame
->area
.height
;
439 XMoveResizeWindow(ob_display
, focus_indicator
.left
.win
,
441 a_focus_indicator
->texture
[0].data
.lineart
.x1
= w
-1;
442 a_focus_indicator
->texture
[0].data
.lineart
.y1
= 0;
443 a_focus_indicator
->texture
[0].data
.lineart
.x2
= 0;
444 a_focus_indicator
->texture
[0].data
.lineart
.y2
= 0;
445 a_focus_indicator
->texture
[1].data
.lineart
.x1
= 0;
446 a_focus_indicator
->texture
[1].data
.lineart
.y1
= 0;
447 a_focus_indicator
->texture
[1].data
.lineart
.x2
= 0;
448 a_focus_indicator
->texture
[1].data
.lineart
.y2
= h
-1;
449 a_focus_indicator
->texture
[2].data
.lineart
.x1
= 0;
450 a_focus_indicator
->texture
[2].data
.lineart
.y1
= h
-1;
451 a_focus_indicator
->texture
[2].data
.lineart
.x2
= w
-1;
452 a_focus_indicator
->texture
[2].data
.lineart
.y2
= h
-1;
453 a_focus_indicator
->texture
[3].data
.lineart
.x1
= w
-1;
454 a_focus_indicator
->texture
[3].data
.lineart
.y1
= wt
-1;
455 a_focus_indicator
->texture
[3].data
.lineart
.x2
= w
-1;
456 a_focus_indicator
->texture
[3].data
.lineart
.y2
= h
- wb
;
457 RrPaint(a_focus_indicator
, focus_indicator
.left
.win
,
460 x
= focus_cycle_target
->frame
->area
.x
+
461 focus_cycle_target
->frame
->area
.width
- wr
;
462 y
= focus_cycle_target
->frame
->area
.y
;
464 h
= focus_cycle_target
->frame
->area
.height
;
466 XMoveResizeWindow(ob_display
, focus_indicator
.right
.win
,
468 a_focus_indicator
->texture
[0].data
.lineart
.x1
= 0;
469 a_focus_indicator
->texture
[0].data
.lineart
.y1
= 0;
470 a_focus_indicator
->texture
[0].data
.lineart
.x2
= w
-1;
471 a_focus_indicator
->texture
[0].data
.lineart
.y2
= 0;
472 a_focus_indicator
->texture
[1].data
.lineart
.x1
= w
-1;
473 a_focus_indicator
->texture
[1].data
.lineart
.y1
= 0;
474 a_focus_indicator
->texture
[1].data
.lineart
.x2
= w
-1;
475 a_focus_indicator
->texture
[1].data
.lineart
.y2
= h
-1;
476 a_focus_indicator
->texture
[2].data
.lineart
.x1
= w
-1;
477 a_focus_indicator
->texture
[2].data
.lineart
.y1
= h
-1;
478 a_focus_indicator
->texture
[2].data
.lineart
.x2
= 0;
479 a_focus_indicator
->texture
[2].data
.lineart
.y2
= h
-1;
480 a_focus_indicator
->texture
[3].data
.lineart
.x1
= 0;
481 a_focus_indicator
->texture
[3].data
.lineart
.y1
= wt
-1;
482 a_focus_indicator
->texture
[3].data
.lineart
.x2
= 0;
483 a_focus_indicator
->texture
[3].data
.lineart
.y2
= h
- wb
;
484 RrPaint(a_focus_indicator
, focus_indicator
.right
.win
,
487 x
= focus_cycle_target
->frame
->area
.x
;
488 y
= focus_cycle_target
->frame
->area
.y
+
489 focus_cycle_target
->frame
->area
.height
- wb
;
490 w
= focus_cycle_target
->frame
->area
.width
;
493 XMoveResizeWindow(ob_display
, focus_indicator
.bottom
.win
,
495 a_focus_indicator
->texture
[0].data
.lineart
.x1
= 0;
496 a_focus_indicator
->texture
[0].data
.lineart
.y1
= 0;
497 a_focus_indicator
->texture
[0].data
.lineart
.x2
= 0;
498 a_focus_indicator
->texture
[0].data
.lineart
.y2
= h
-1;
499 a_focus_indicator
->texture
[1].data
.lineart
.x1
= 0;
500 a_focus_indicator
->texture
[1].data
.lineart
.y1
= h
-1;
501 a_focus_indicator
->texture
[1].data
.lineart
.x2
= w
-1;
502 a_focus_indicator
->texture
[1].data
.lineart
.y2
= h
-1;
503 a_focus_indicator
->texture
[2].data
.lineart
.x1
= w
-1;
504 a_focus_indicator
->texture
[2].data
.lineart
.y1
= h
-1;
505 a_focus_indicator
->texture
[2].data
.lineart
.x2
= w
-1;
506 a_focus_indicator
->texture
[2].data
.lineart
.y2
= 0;
507 a_focus_indicator
->texture
[3].data
.lineart
.x1
= wl
-1;
508 a_focus_indicator
->texture
[3].data
.lineart
.y1
= 0;
509 a_focus_indicator
->texture
[3].data
.lineart
.x2
= w
- wr
;
510 a_focus_indicator
->texture
[3].data
.lineart
.y2
= 0;
511 RrPaint(a_focus_indicator
, focus_indicator
.bottom
.win
,
514 XMapWindow(ob_display
, focus_indicator
.top
.win
);
515 XMapWindow(ob_display
, focus_indicator
.left
.win
);
516 XMapWindow(ob_display
, focus_indicator
.right
.win
);
517 XMapWindow(ob_display
, focus_indicator
.bottom
.win
);
521 static gboolean
valid_focus_target(ObClient
*ft
)
523 /* we don't use client_can_focus here, because that doesn't let you
524 focus an iconic window, but we want to be able to, so we just check
525 if the focus flags on the window allow it, and its on the current
527 if ((ft
->type
== OB_CLIENT_TYPE_NORMAL
||
528 ft
->type
== OB_CLIENT_TYPE_DIALOG
||
529 (!client_has_group_siblings(ft
) &&
530 (ft
->type
== OB_CLIENT_TYPE_TOOLBAR
||
531 ft
->type
== OB_CLIENT_TYPE_MENU
||
532 ft
->type
== OB_CLIENT_TYPE_UTILITY
))) &&
533 ((ft
->can_focus
|| ft
->focus_notify
) &&
535 (ft
->desktop
== screen_desktop
|| ft
->desktop
== DESKTOP_ALL
)) &&
536 ft
== client_focus_target(ft
))
542 for (it = ft->transients; it; it = g_slist_next(it)) {
543 ObClient *c = it->data;
545 if (c->frame->visible)
555 void focus_cycle(gboolean forward
, gboolean linear
, gboolean interactive
,
556 gboolean dialog
, gboolean done
, gboolean cancel
, Time time
)
558 static ObClient
*first
= NULL
;
559 static ObClient
*t
= NULL
;
560 static GList
*order
= NULL
;
561 GList
*it
, *start
, *list
;
566 focus_cycle_target
= NULL
;
571 if (!focus_order
[screen_desktop
])
574 if (!first
) first
= focus_client
;
576 if (linear
) list
= client_list
;
577 else list
= focus_order
[screen_desktop
];
579 if (!focus_order
[screen_desktop
])
583 if (!focus_cycle_target
) focus_cycle_target
= focus_client
;
585 start
= it
= g_list_find(list
, focus_cycle_target
);
586 if (!start
) /* switched desktops or something? */
587 start
= it
= forward
? g_list_last(list
) : g_list_first(list
);
588 if (!start
) goto done_cycle
;
593 if (it
== NULL
) it
= g_list_first(list
);
596 if (it
== NULL
) it
= g_list_last(list
);
599 if (valid_focus_target(ft
)) {
601 if (ft
!= focus_cycle_target
) { /* prevents flicker */
602 focus_cycle_target
= ft
;
603 focus_cycle_draw_indicator();
605 popup_cycle(ft
, dialog
);
607 } else if (ft
!= focus_cycle_target
) {
608 focus_cycle_target
= ft
;
613 } while (it
!= start
);
616 if (done
&& focus_cycle_target
)
617 client_activate(focus_cycle_target
, FALSE
, TRUE
, time
);
621 focus_cycle_target
= NULL
;
626 focus_cycle_draw_indicator();
627 popup_cycle(ft
, FALSE
);
633 void focus_directional_cycle(ObDirection dir
, gboolean interactive
,
634 gboolean dialog
, gboolean done
, gboolean cancel
,
637 static ObClient
*first
= NULL
;
644 focus_cycle_target
= NULL
;
649 if (!focus_order
[screen_desktop
])
652 if (!first
) first
= focus_client
;
653 if (!focus_cycle_target
) focus_cycle_target
= focus_client
;
655 if (focus_cycle_target
)
656 ft
= client_find_directional(focus_cycle_target
, dir
);
660 for (it
= focus_order
[screen_desktop
]; it
; it
= g_list_next(it
))
661 if (valid_focus_target(it
->data
))
666 if (ft
!= focus_cycle_target
) {/* prevents flicker */
667 focus_cycle_target
= ft
;
668 focus_cycle_draw_indicator();
671 if (focus_cycle_target
) {
672 popup_cycle(focus_cycle_target
, dialog
);
679 if (done
&& focus_cycle_target
)
680 client_activate(focus_cycle_target
, FALSE
, TRUE
, time
);
683 focus_cycle_target
= NULL
;
685 focus_cycle_draw_indicator();
686 popup_cycle(ft
, FALSE
);
691 void focus_order_add_new(ObClient
*c
)
696 focus_order_to_top(c
);
699 if (d
== DESKTOP_ALL
) {
700 for (i
= 0; i
< screen_num_desktops
; ++i
) {
701 g_assert(!g_list_find(focus_order
[i
], c
));
702 if (focus_order
[i
] && ((ObClient
*)focus_order
[i
]->data
)->iconic
)
703 focus_order
[i
] = g_list_insert(focus_order
[i
], c
, 0);
705 focus_order
[i
] = g_list_insert(focus_order
[i
], c
, 1);
708 g_assert(!g_list_find(focus_order
[d
], c
));
709 if (focus_order
[d
] && ((ObClient
*)focus_order
[d
]->data
)->iconic
)
710 focus_order
[d
] = g_list_insert(focus_order
[d
], c
, 0);
712 focus_order
[d
] = g_list_insert(focus_order
[d
], c
, 1);
717 void focus_order_remove(ObClient
*c
)
722 if (d
== DESKTOP_ALL
) {
723 for (i
= 0; i
< screen_num_desktops
; ++i
)
724 focus_order
[i
] = g_list_remove(focus_order
[i
], c
);
726 focus_order
[d
] = g_list_remove(focus_order
[d
], c
);
729 static void to_top(ObClient
*c
, guint d
)
731 focus_order
[d
] = g_list_remove(focus_order
[d
], c
);
733 focus_order
[d
] = g_list_prepend(focus_order
[d
], c
);
737 /* insert before first iconic window */
738 for (it
= focus_order
[d
];
739 it
&& !((ObClient
*)it
->data
)->iconic
; it
= g_list_next(it
));
740 focus_order
[d
] = g_list_insert_before(focus_order
[d
], it
, c
);
744 void focus_order_to_top(ObClient
*c
)
749 if (d
== DESKTOP_ALL
) {
750 for (i
= 0; i
< screen_num_desktops
; ++i
)
756 static void to_bottom(ObClient
*c
, guint d
)
758 focus_order
[d
] = g_list_remove(focus_order
[d
], c
);
760 focus_order
[d
] = g_list_append(focus_order
[d
], c
);
764 /* insert before first iconic window */
765 for (it
= focus_order
[d
];
766 it
&& !((ObClient
*)it
->data
)->iconic
; it
= g_list_next(it
));
767 focus_order
[d
] = g_list_insert_before(focus_order
[d
], it
, c
);
771 void focus_order_to_bottom(ObClient
*c
)
776 if (d
== DESKTOP_ALL
) {
777 for (i
= 0; i
< screen_num_desktops
; ++i
)