X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Ffocus_cycle_popup.c;h=d5b707ede87f56e95902ce94e5e6a2b55e1727d2;hb=ad3bf0cea4d471ccb821227f1df485a8c639fca0;hp=42c3fed6ae48bc7c07101f2bbb06226c3e889f8d;hpb=9b447a2d2837a6dab0380bc767644f8fe5083aa9;p=chaz%2Fopenbox diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 42c3fed6..d5b707ed 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -137,7 +137,6 @@ void focus_cycle_popup_startup(gboolean reconfig) /* create the text window used for the icon-mode popup */ popup.icon_mode_text = create_window(popup.bg, 0, 0, NULL); - XMapWindow(obt_display, popup.icon_mode_text); popup.targets = NULL; popup.n_targets = 0; @@ -256,7 +255,6 @@ static void popup_setup(ObFocusCyclePopup *p, gboolean create_targets, t->textwin = create_window(p->bg, 0, 0, NULL); XMapWindow(obt_display, t->iconwin); - XMapWindow(obt_display, t->textwin); p->targets = g_list_prepend(p->targets, t); ++n; @@ -340,6 +338,10 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c, w = MIN(w, MAX(screen_area->width/3, POPUP_WIDTH)); /* max width */ w = MAX(w, POPUP_WIDTH); /* min width */ + /* get the text height */ + texth = MAX(RrMinHeight(p->a_text), RrMinHeight(p->a_hilite_text)) + + TEXT_BORDER * 2; + if (mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) { /* how many icons will fit in that row? make the width fit that */ w -= l + r; @@ -353,15 +355,18 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c, else { /* in list mode, there is one column of icons.. */ icons_per_row = 1; - icon_rows = p->n_targets; + /* maximum is 80% of the screen height */ + icon_rows = MIN(p->n_targets, + (4*screen_area->height/5) /* 80% of the screen */ + / + MAX(HILITE_SIZE, texth)); /* height of each row */ } - /* get the text dimensions */ + /* get the text width */ textw = w - l - r; if (mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) /* leave space on the side for the icons */ textw -= list_mode_icon_column_w; - texth = RrMinHeight(p->a_text) + TEXT_BORDER * 2; /* find the height of the dialog */ #warning limit the height and scroll entries somehow @@ -398,10 +403,14 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c, /* position the background but don't draw it */ XMoveResizeWindow(obt_display, p->bg, x, y, w, h); - if (mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) + if (mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) { /* position the text */ XMoveResizeWindow(obt_display, p->icon_mode_text, icon_mode_textx, icon_mode_texty, textw, texth); + XMapWindow(obt_display, popup.icon_mode_text); + } + else + XUnmapWindow(obt_display, popup.icon_mode_text); } /* find the focused target */ @@ -451,10 +460,14 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c, iconx, icony, HILITE_SIZE, HILITE_SIZE); /* position the text */ - if (mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) + if (mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) { XMoveResizeWindow(obt_display, target->textwin, list_mode_textx, list_mode_texty, textw, texth); + XMapWindow(obt_display, target->textwin); + } + else + XUnmapWindow(obt_display, target->textwin); /* get the icon from the client */ icon = client_icon(target->client, ICON_SIZE, ICON_SIZE);