1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 focus_cycle_popup.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana 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.
20 #include "focus_cycle_popup.h"
28 #include "render/render.h"
33 /* Size of the hilite box around a window's icon */
34 #define HILITE_SIZE 40
35 /* Width of the outer ring around the hilite box */
36 #define HILITE_WIDTH 2
37 /* Space between the outer ring around the hilite box and the icon inside it */
38 #define HILITE_MARGIN 1
39 /* Total distance from the edge of the hilite box to the icon inside it */
40 #define HILITE_OFFSET (HILITE_WIDTH + HILITE_MARGIN)
41 /* Size of the icons, which can appear inside or outside of a hilite box */
42 #define ICON_SIZE (HILITE_SIZE - 2*HILITE_OFFSET)
43 /* Margin area around the outside of the dialog */
44 #define OUTSIDE_BORDER 3
45 /* Margin area around the text */
47 /* Scroll the list-mode list when the cursor gets within this many rows of the
49 #define SCROLL_MARGIN 4
51 typedef struct _ObFocusCyclePopup ObFocusCyclePopup
;
52 typedef struct _ObFocusCyclePopupTarget ObFocusCyclePopupTarget
;
54 struct _ObFocusCyclePopupTarget
59 /* This is used when the popup is in list mode */
63 struct _ObFocusCyclePopup
68 /* This is used when the popup is in icon mode */
69 Window icon_mode_text
;
72 Window list_mode_down
;
77 const ObFocusCyclePopupTarget
*last_target
;
81 /* How are the list is scrolled, in scroll mode */
86 RrAppearance
*a_hilite_text
;
88 RrAppearance
*a_arrow
;
91 ObFocusCyclePopupMode mode
;
94 /*! This popup shows all possible windows */
95 static ObFocusCyclePopup popup
;
96 /*! This popup shows a single window */
97 static ObIconPopup
*single_popup
;
99 static gchar
*popup_get_name (ObClient
*c
);
100 static void popup_setup (ObFocusCyclePopup
*p
,
101 gboolean create_targets
,
102 gboolean iconic_windows
,
103 gboolean all_desktops
,
104 gboolean dock_windows
,
105 gboolean desktop_windows
);
106 static void popup_render (ObFocusCyclePopup
*p
,
109 static Window
create_window(Window parent
, guint bwidth
, gulong mask
,
110 XSetWindowAttributes
*attr
)
112 return XCreateWindow(obt_display
, parent
, 0, 0, 1, 1, bwidth
,
113 RrDepth(ob_rr_inst
), InputOutput
,
114 RrVisual(ob_rr_inst
), mask
, attr
);
117 void focus_cycle_popup_startup(gboolean reconfig
)
119 XSetWindowAttributes attrib
;
122 single_popup
= icon_popup_new();
124 popup
.obwin
.type
= OB_WINDOW_CLASS_INTERNAL
;
125 popup
.a_bg
= RrAppearanceCopy(ob_rr_theme
->osd_hilite_bg
);
126 popup
.a_hilite_text
= RrAppearanceCopy(ob_rr_theme
->osd_hilite_label
);
127 popup
.a_text
= RrAppearanceCopy(ob_rr_theme
->a_unfocused_label
);
128 popup
.a_icon
= RrAppearanceCopy(ob_rr_theme
->a_clear
);
129 popup
.a_arrow
= RrAppearanceCopy(ob_rr_theme
->a_clear_tex
);
131 popup
.a_hilite_text
->surface
.parent
= popup
.a_bg
;
132 popup
.a_text
->surface
.parent
= popup
.a_bg
;
133 popup
.a_icon
->surface
.parent
= popup
.a_bg
;
135 popup
.a_text
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
136 popup
.a_hilite_text
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
138 /* 2 textures. texture[0] is the icon. texture[1] is the hilight, and
139 may or may not be used */
140 RrAppearanceAddTextures(popup
.a_icon
, 2);
142 popup
.a_icon
->texture
[0].type
= RR_TEXTURE_RGBA
;
144 popup
.a_arrow
->texture
[0].type
= RR_TEXTURE_MASK
;
145 popup
.a_arrow
->texture
[0].data
.mask
.color
=
146 ob_rr_theme
->osd_color
;
148 attrib
.override_redirect
= True
;
149 attrib
.border_pixel
=RrColorPixel(ob_rr_theme
->osd_border_color
);
150 popup
.bg
= create_window(obt_root(ob_screen
), ob_rr_theme
->obwidth
,
151 CWOverrideRedirect
| CWBorderPixel
, &attrib
);
153 /* create the text window used for the icon-mode popup */
154 popup
.icon_mode_text
= create_window(popup
.bg
, 0, 0, NULL
);
156 /* create the windows for the up and down arrows */
157 popup
.list_mode_up
= create_window(popup
.bg
, 0, 0, NULL
);
158 popup
.list_mode_down
= create_window(popup
.bg
, 0, 0, NULL
);
160 popup
.targets
= NULL
;
162 popup
.last_target
= NULL
;
164 /* set up the hilite texture for the icon */
165 popup
.a_icon
->texture
[1].data
.rgba
.width
= HILITE_SIZE
;
166 popup
.a_icon
->texture
[1].data
.rgba
.height
= HILITE_SIZE
;
167 popup
.a_icon
->texture
[1].data
.rgba
.alpha
= 0xff;
168 p
= g_new(RrPixel32
, HILITE_SIZE
* HILITE_SIZE
);
169 popup
.a_icon
->texture
[1].data
.rgba
.data
= p
;
171 /* create the hilite under the target icon */
176 color
= ((ob_rr_theme
->osd_color
->r
& 0xff) << RrDefaultRedOffset
) +
177 ((ob_rr_theme
->osd_color
->g
& 0xff) << RrDefaultGreenOffset
) +
178 ((ob_rr_theme
->osd_color
->b
& 0xff) << RrDefaultBlueOffset
);
181 for (x
= 0; x
< HILITE_SIZE
; x
++)
182 for (y
= 0; y
< HILITE_SIZE
; y
++) {
185 if (x
< HILITE_WIDTH
||
186 x
>= HILITE_SIZE
- HILITE_WIDTH
||
188 y
>= HILITE_SIZE
- HILITE_WIDTH
)
190 /* the border of the target */
193 /* the background of the target */
197 p
[o
++] = color
+ (a
<< RrDefaultAlphaOffset
);
201 stacking_add(INTERNAL_AS_WINDOW(&popup
));
202 window_add(&popup
.bg
, INTERNAL_AS_WINDOW(&popup
));
205 void focus_cycle_popup_shutdown(gboolean reconfig
)
207 icon_popup_free(single_popup
);
209 window_remove(popup
.bg
);
210 stacking_remove(INTERNAL_AS_WINDOW(&popup
));
212 while(popup
.targets
) {
213 ObFocusCyclePopupTarget
*t
= popup
.targets
->data
;
216 XDestroyWindow(obt_display
, t
->iconwin
);
217 XDestroyWindow(obt_display
, t
->textwin
);
219 popup
.targets
= g_list_delete_link(popup
.targets
, popup
.targets
);
222 g_free(popup
.a_icon
->texture
[1].data
.rgba
.data
);
223 popup
.a_icon
->texture
[1].data
.rgba
.data
= NULL
;
225 XDestroyWindow(obt_display
, popup
.list_mode_up
);
226 XDestroyWindow(obt_display
, popup
.list_mode_down
);
227 XDestroyWindow(obt_display
, popup
.icon_mode_text
);
228 XDestroyWindow(obt_display
, popup
.bg
);
230 RrAppearanceFree(popup
.a_arrow
);
231 RrAppearanceFree(popup
.a_icon
);
232 RrAppearanceFree(popup
.a_hilite_text
);
233 RrAppearanceFree(popup
.a_text
);
234 RrAppearanceFree(popup
.a_bg
);
237 static void popup_setup(ObFocusCyclePopup
*p
, gboolean create_targets
,
238 gboolean iconic_windows
, gboolean all_desktops
,
239 gboolean dock_windows
, gboolean desktop_windows
)
244 g_assert(p
->targets
== NULL
);
245 g_assert(p
->n_targets
== 0);
247 /* make its width to be the width of all the possible titles */
249 /* build a list of all the valid focus targets and measure their strings,
253 for (it
= g_list_last(focus_order
); it
; it
= g_list_previous(it
)) {
254 ObClient
*ft
= it
->data
;
256 if (focus_valid_target(ft
, TRUE
,
262 gchar
*text
= popup_get_name(ft
);
265 p
->a_text
->texture
[0].data
.text
.string
= text
;
266 maxwidth
= MAX(maxwidth
, RrMinWidth(p
->a_text
));
268 if (!create_targets
) {
271 ObFocusCyclePopupTarget
*t
= g_new(ObFocusCyclePopupTarget
, 1);
275 t
->iconwin
= create_window(p
->bg
, 0, 0, NULL
);
276 t
->textwin
= create_window(p
->bg
, 0, 0, NULL
);
278 p
->targets
= g_list_prepend(p
->targets
, t
);
285 p
->maxtextw
= maxwidth
;
288 static gchar
*popup_get_name(ObClient
*c
)
292 const gchar
*desk
= NULL
;
295 /* find our highest direct parent */
296 p
= client_search_top_direct_parent(c
);
298 if (c
->desktop
!= DESKTOP_ALL
&& c
->desktop
!= screen_desktop
)
299 desk
= screen_desktop_names
[c
->desktop
];
301 title
= c
->iconic
? c
->icon_title
: c
->title
;
303 /* use the transient's parent's title/icon if we don't have one */
304 if (p
!= c
&& title
[0] == '\0')
305 title
= p
->iconic
? p
->icon_title
: p
->title
;
308 ret
= g_strdup_printf("%s [%s]", title
, desk
);
310 ret
= g_strdup(title
);
315 static void popup_render(ObFocusCyclePopup
*p
, const ObClient
*c
)
320 Rect
*screen_area
= NULL
;
321 gint rgbax
, rgbay
, rgbaw
, rgbah
;
324 const ObFocusCyclePopupTarget
*newtarget
;
331 /* vars for icon mode */
332 gint icon_mode_textx
;
333 gint icon_mode_texty
;
336 /* vars for list mode */
337 gint list_mode_icon_column_w
= HILITE_SIZE
+ OUTSIDE_BORDER
;
338 gint up_arrow_x
, down_arrow_x
;
339 gint up_arrow_y
, down_arrow_y
;
341 g_assert(p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_ICONS
||
342 p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_LIST
);
344 screen_area
= screen_physical_area_active();
346 /* get the outside margins */
347 RrMargins(p
->a_bg
, &ml
, &mt
, &mr
, &mb
);
349 /* get our outside borders */
350 l
= ml
+ OUTSIDE_BORDER
;
351 r
= mr
+ OUTSIDE_BORDER
;
352 t
= mt
+ OUTSIDE_BORDER
;
353 b
= mb
+ OUTSIDE_BORDER
;
355 /* get the width from the text and keep it within limits */
356 w
= l
+ r
+ p
->maxtextw
;
357 if (p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_LIST
)
358 /* when in list mode, there are icons down the side */
359 w
+= list_mode_icon_column_w
;
360 w
= MIN(w
, MAX(screen_area
->width
/3, POPUP_WIDTH
)); /* max width */
361 w
= MAX(w
, POPUP_WIDTH
); /* min width */
363 /* get the text height */
364 texth
= RrMinHeight(p
->a_hilite_text
);
365 if (p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_LIST
)
366 texth
= MAX(MAX(texth
, RrMinHeight(p
->a_text
)), ICON_SIZE
);
368 texth
+= TEXT_BORDER
* 2;
370 if (p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_ICONS
) {
371 /* how many icons will fit in that row? make the width fit that */
373 icons_per_row
= (w
+ HILITE_SIZE
- 1) / HILITE_SIZE
;
374 w
= icons_per_row
* HILITE_SIZE
+ l
+ r
;
376 /* how many rows do we need? */
377 icon_rows
= (p
->n_targets
-1) / icons_per_row
+ 1;
379 /* in list mode, there is one column of icons.. */
381 /* maximum is 80% of the screen height */
382 icon_rows
= MIN(p
->n_targets
,
383 (4*screen_area
->height
/5) /* 80% of the screen */
385 MAX(HILITE_SIZE
, texth
)); /* height of each row */
386 /* but make sure there is always one */
387 icon_rows
= MAX(icon_rows
, 1);
390 /* get the text width */
392 if (p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_LIST
)
393 /* leave space on the side for the icons */
394 textw
-= list_mode_icon_column_w
;
396 /* find the height of the dialog */
397 h
= t
+ b
+ (icon_rows
* MAX(HILITE_SIZE
, texth
));
398 if (p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_ICONS
)
399 /* in icon mode the text sits below the icons, so make some space */
400 h
+= OUTSIDE_BORDER
+ texth
;
402 h
+= ob_rr_theme
->up_arrow_mask
->height
+ OUTSIDE_BORDER
403 + ob_rr_theme
->down_arrow_mask
->height
+ OUTSIDE_BORDER
;
406 /* center the icons if there is less than one row */
408 icons_center_x
= (w
- p
->n_targets
* HILITE_SIZE
) / 2;
412 if (p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_ICONS
) {
413 /* get the position of the text */
415 icon_mode_texty
= h
- texth
- b
;
418 /* find the position for the popup (include the outer borders) */
419 x
= screen_area
->x
+ (screen_area
->width
-
420 (w
+ ob_rr_theme
->obwidth
* 2)) / 2;
421 y
= screen_area
->y
+ (screen_area
->height
-
422 (h
+ ob_rr_theme
->obwidth
* 2)) / 2;
424 /* get the dimensions of the target hilite texture */
431 /* position the background but don't draw it */
432 XMoveResizeWindow(obt_display
, p
->bg
, x
, y
, w
, h
);
434 if (p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_ICONS
) {
435 /* position the text */
436 XMoveResizeWindow(obt_display
, p
->icon_mode_text
,
437 icon_mode_textx
, icon_mode_texty
, textw
, texth
);
438 XMapWindow(obt_display
, popup
.icon_mode_text
);
440 XUnmapWindow(obt_display
, popup
.icon_mode_text
);
442 up_arrow_x
= (w
- ob_rr_theme
->up_arrow_mask
->width
) / 2;
445 down_arrow_x
= (w
- ob_rr_theme
->down_arrow_mask
->width
) / 2;
446 down_arrow_y
= h
- b
- ob_rr_theme
->down_arrow_mask
->height
;
448 /* position the arrows */
449 XMoveResizeWindow(obt_display
, p
->list_mode_up
,
450 up_arrow_x
, up_arrow_y
,
451 ob_rr_theme
->up_arrow_mask
->width
,
452 ob_rr_theme
->up_arrow_mask
->height
);
453 XMoveResizeWindow(obt_display
, p
->list_mode_down
,
454 down_arrow_x
, down_arrow_y
,
455 ob_rr_theme
->down_arrow_mask
->width
,
456 ob_rr_theme
->down_arrow_mask
->height
);
460 /* reset the scrolling when the dialog is first shown */
464 /* find the focused target */
466 for (i
= 0, it
= p
->targets
; it
; ++i
, it
= g_list_next(it
)) {
467 const ObFocusCyclePopupTarget
*target
= it
->data
;
468 if (target
->client
== c
) {
469 /* save the target */
476 /* scroll the list if needed */
477 last_scroll
= p
->scroll
;
478 if (p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_LIST
) {
479 const gint top
= p
->scroll
+ SCROLL_MARGIN
;
480 const gint bottom
= p
->scroll
+ icon_rows
- SCROLL_MARGIN
;
481 const gint min_scroll
= 0;
482 const gint max_scroll
= p
->n_targets
- icon_rows
;
484 if (top
- selected_pos
>= 0) {
485 p
->scroll
-= top
- selected_pos
+ 1;
486 p
->scroll
= MAX(p
->scroll
, min_scroll
);
487 } else if (selected_pos
- bottom
>= 0) {
488 p
->scroll
+= selected_pos
- bottom
+ 1;
489 p
->scroll
= MIN(p
->scroll
, max_scroll
);
493 g_assert(newtarget
!= NULL
);
495 /* * * draw everything * * */
497 /* draw the background */
499 RrPaint(p
->a_bg
, p
->bg
, w
, h
);
501 /* draw the scroll arrows */
502 if (!p
->mapped
&& p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_LIST
) {
503 p
->a_arrow
->texture
[0].data
.mask
.mask
=
504 ob_rr_theme
->up_arrow_mask
;
505 p
->a_arrow
->surface
.parent
= p
->a_bg
;
506 p
->a_arrow
->surface
.parentx
= up_arrow_x
;
507 p
->a_arrow
->surface
.parenty
= up_arrow_y
;
508 RrPaint(p
->a_arrow
, p
->list_mode_up
,
509 ob_rr_theme
->up_arrow_mask
->width
,
510 ob_rr_theme
->up_arrow_mask
->height
);
512 p
->a_arrow
->texture
[0].data
.mask
.mask
=
513 ob_rr_theme
->down_arrow_mask
;
514 p
->a_arrow
->surface
.parent
= p
->a_bg
;
515 p
->a_arrow
->surface
.parentx
= down_arrow_x
;
516 p
->a_arrow
->surface
.parenty
= down_arrow_y
;
517 RrPaint(p
->a_arrow
, p
->list_mode_down
,
518 ob_rr_theme
->down_arrow_mask
->width
,
519 ob_rr_theme
->down_arrow_mask
->height
);
522 /* show the scroll arrows when appropriate */
523 if (p
->scroll
&& p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_LIST
)
524 XMapWindow(obt_display
, p
->list_mode_up
);
526 XUnmapWindow(obt_display
, p
->list_mode_up
);
528 if (p
->scroll
< p
->n_targets
- icon_rows
&&
529 p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_LIST
)
530 XMapWindow(obt_display
, p
->list_mode_down
);
532 XUnmapWindow(obt_display
, p
->list_mode_down
);
534 /* draw the icons and text */
535 for (i
= 0, it
= p
->targets
; it
; ++i
, it
= g_list_next(it
)) {
536 const ObFocusCyclePopupTarget
*target
= it
->data
;
538 /* have to redraw the targetted icon and last targetted icon
539 * to update the hilite */
540 if (!p
->mapped
|| newtarget
== target
|| p
->last_target
== target
||
541 last_scroll
!= p
->scroll
)
543 /* row and column start from 0 */
544 const gint row
= i
/ icons_per_row
- p
->scroll
;
545 const gint col
= i
% icons_per_row
;
546 const ObClientIcon
*icon
;
548 gint list_mode_textx
, list_mode_texty
;
551 /* find the coordinates for the icon */
552 iconx
= icons_center_x
+ l
+ (col
* HILITE_SIZE
);
553 icony
= t
+ ob_rr_theme
->up_arrow_mask
->height
+ OUTSIDE_BORDER
554 + (row
* MAX(texth
, HILITE_SIZE
))
555 + MAX(texth
- HILITE_SIZE
, 0) / 2;
557 /* find the dimensions of the text box */
558 list_mode_textx
= iconx
+ HILITE_SIZE
+ TEXT_BORDER
;
559 list_mode_texty
= icony
+ HILITE_OFFSET
;
561 /* position the icon */
562 XMoveResizeWindow(obt_display
, target
->iconwin
,
563 iconx
, icony
, HILITE_SIZE
, HILITE_SIZE
);
565 /* position the text */
566 if (p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_LIST
)
567 XMoveResizeWindow(obt_display
, target
->textwin
,
568 list_mode_textx
, list_mode_texty
,
571 /* show/hide the right windows */
572 if (row
>= 0 && row
< icon_rows
) {
573 XMapWindow(obt_display
, target
->iconwin
);
574 if (p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_LIST
)
575 XMapWindow(obt_display
, target
->textwin
);
577 XUnmapWindow(obt_display
, target
->textwin
);
579 XUnmapWindow(obt_display
, target
->textwin
);
580 if (p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_LIST
)
581 XUnmapWindow(obt_display
, target
->iconwin
);
583 XMapWindow(obt_display
, target
->iconwin
);
586 /* get the icon from the client */
587 icon
= client_icon(target
->client
, ICON_SIZE
, ICON_SIZE
);
588 p
->a_icon
->texture
[0].data
.rgba
.width
= icon
->width
;
589 p
->a_icon
->texture
[0].data
.rgba
.height
= icon
->height
;
590 p
->a_icon
->texture
[0].data
.rgba
.twidth
= ICON_SIZE
;
591 p
->a_icon
->texture
[0].data
.rgba
.theight
= ICON_SIZE
;
592 p
->a_icon
->texture
[0].data
.rgba
.tx
= HILITE_OFFSET
;
593 p
->a_icon
->texture
[0].data
.rgba
.ty
= HILITE_OFFSET
;
594 p
->a_icon
->texture
[0].data
.rgba
.alpha
=
595 target
->client
->iconic
? OB_ICONIC_ALPHA
: 0xff;
596 p
->a_icon
->texture
[0].data
.rgba
.data
= icon
->data
;
598 /* Draw the hilite? */
599 p
->a_icon
->texture
[1].type
= (target
== newtarget
) ?
600 RR_TEXTURE_RGBA
: RR_TEXTURE_NONE
;
603 p
->a_icon
->surface
.parentx
= iconx
;
604 p
->a_icon
->surface
.parenty
= icony
;
605 RrPaint(p
->a_icon
, target
->iconwin
, HILITE_SIZE
, HILITE_SIZE
);
608 if (p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_LIST
||
611 text
= (target
== newtarget
) ? p
->a_hilite_text
: p
->a_text
;
612 text
->texture
[0].data
.text
.string
= target
->text
;
613 text
->surface
.parentx
=
614 p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_ICONS
?
615 icon_mode_textx
: list_mode_textx
;
616 text
->surface
.parenty
=
617 p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_ICONS
?
618 icon_mode_texty
: list_mode_texty
;
620 (p
->mode
== OB_FOCUS_CYCLE_POPUP_MODE_ICONS
?
621 p
->icon_mode_text
: target
->textwin
),
627 p
->last_target
= newtarget
;
634 void focus_cycle_popup_show(ObClient
*c
, gboolean iconic_windows
,
635 gboolean all_desktops
, gboolean dock_windows
,
636 gboolean desktop_windows
,
637 ObFocusCyclePopupMode mode
)
641 if (mode
== OB_FOCUS_CYCLE_POPUP_MODE_NONE
) {
642 focus_cycle_popup_hide();
646 /* do this stuff only when the dialog is first showing */
648 popup_setup(&popup
, TRUE
, iconic_windows
, all_desktops
,
649 dock_windows
, desktop_windows
);
650 /* this is fixed once the dialog is shown */
653 g_assert(popup
.targets
!= NULL
);
655 popup_render(&popup
, c
);
658 /* show the dialog */
659 XMapWindow(obt_display
, popup
.bg
);
662 screen_hide_desktop_popup();
666 void focus_cycle_popup_hide(void)
670 ignore_start
= event_start_ignore_all_enters();
672 XUnmapWindow(obt_display
, popup
.bg
);
675 event_end_ignore_all_enters(ignore_start
);
677 popup
.mapped
= FALSE
;
679 while(popup
.targets
) {
680 ObFocusCyclePopupTarget
*t
= popup
.targets
->data
;
683 XDestroyWindow(obt_display
, t
->iconwin
);
684 XDestroyWindow(obt_display
, t
->textwin
);
687 popup
.targets
= g_list_delete_link(popup
.targets
, popup
.targets
);
690 popup
.last_target
= NULL
;
693 void focus_cycle_popup_single_show(struct _ObClient
*c
,
694 gboolean iconic_windows
,
695 gboolean all_desktops
,
696 gboolean dock_windows
,
697 gboolean desktop_windows
)
703 /* do this stuff only when the dialog is first showing */
707 popup_setup(&popup
, FALSE
, iconic_windows
, all_desktops
,
708 dock_windows
, desktop_windows
);
709 g_assert(popup
.targets
== NULL
);
711 /* position the popup */
712 a
= screen_physical_area_active();
713 icon_popup_position(single_popup
, CenterGravity
,
714 a
->x
+ a
->width
/ 2, a
->y
+ a
->height
/ 2);
715 icon_popup_height(single_popup
, POPUP_HEIGHT
);
716 icon_popup_min_width(single_popup
, POPUP_WIDTH
);
717 icon_popup_max_width(single_popup
, MAX(a
->width
/3, POPUP_WIDTH
));
718 icon_popup_text_width(single_popup
, popup
.maxtextw
);
722 text
= popup_get_name(c
);
723 icon_popup_show(single_popup
, text
, client_icon(c
, HILITE_SIZE
,
726 screen_hide_desktop_popup();
729 void focus_cycle_popup_single_hide(void)
731 icon_popup_hide(single_popup
);