From 23cbab843592f35fba74034539f3213ae5d1b7c9 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sun, 2 Sep 2007 04:46:03 +0200 Subject: Beginnings of alt-tab dialog that lists all titles to the right of icons --- openbox/focus_cycle_popup.c | 90 +++++++++++++++------------------------------ 1 file changed, 29 insertions(+), 61 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 096f5c63..b98ebc17 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -43,7 +43,8 @@ struct _ObFocusCyclePopupTarget { ObClient *client; gchar *text; - Window win; + Window iconwin; + Window textwin; }; struct _ObFocusCyclePopup @@ -51,8 +52,6 @@ struct _ObFocusCyclePopup ObWindow obwin; Window bg; - Window text; - GList *targets; gint n_targets; @@ -116,16 +115,12 @@ void focus_cycle_popup_startup(gboolean reconfig) popup.bg = create_window(obt_root(ob_screen), ob_rr_theme->obwidth, CWOverrideRedirect | CWBorderPixel, &attrib); - popup.text = create_window(popup.bg, 0, 0, NULL); - popup.targets = NULL; popup.n_targets = 0; popup.last_target = NULL; popup.hilite_rgba = NULL; - XMapWindow(obt_display, popup.text); - stacking_add(INTERNAL_AS_WINDOW(&popup)); window_add(&popup.bg, INTERNAL_AS_WINDOW(&popup)); } @@ -141,7 +136,8 @@ void focus_cycle_popup_shutdown(gboolean reconfig) ObFocusCyclePopupTarget *t = popup.targets->data; g_free(t->text); - XDestroyWindow(obt_display, t->win); + XDestroyWindow(obt_display, t->iconwin); + XDestroyWindow(obt_display, t->textwin); popup.targets = g_list_delete_link(popup.targets, popup.targets); } @@ -149,7 +145,6 @@ void focus_cycle_popup_shutdown(gboolean reconfig) g_free(popup.hilite_rgba); popup.hilite_rgba = NULL; - XDestroyWindow(obt_display, popup.text); XDestroyWindow(obt_display, popup.bg); RrAppearanceFree(popup.a_icon); @@ -195,9 +190,11 @@ static void popup_setup(ObFocusCyclePopup *p, gboolean create_targets, t->client = ft; t->text = text; - t->win = create_window(p->bg, 0, 0, NULL); + t->iconwin = create_window(p->bg, 0, 0, NULL); + t->textwin = create_window(p->bg, 0, 0, NULL); - XMapWindow(obt_display, t->win); + XMapWindow(obt_display, t->iconwin); + XMapWindow(obt_display, t->textwin); p->targets = g_list_prepend(p->targets, t); ++n; @@ -242,11 +239,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) gint l, t, r, b; gint x, y, w, h; Rect *screen_area = NULL; - gint icons_per_row; - gint icon_rows; - gint textx, texty, textw, texth; gint rgbax, rgbay, rgbaw, rgbah; - gint icons_center_x; gint innerw, innerh; gint i; GList *it; @@ -273,24 +266,8 @@ 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 */ - /* how many icons will fit in that row? make the width fit that */ - w -= l + r; - icons_per_row = (w + ICON_SIZE - 1) / ICON_SIZE; - w = icons_per_row * ICON_SIZE + l + r; - - /* how many rows do we need? */ - icon_rows = (p->n_targets-1) / icons_per_row + 1; - - /* get the text dimensions */ - textw = w - l - r; - texth = RrMinHeight(p->a_text) + TEXT_BORDER * 2; - /* find the height of the dialog */ - h = t + b + (icon_rows * ICON_SIZE) + (OUTSIDE_BORDER + texth); - - /* get the position of the text */ - textx = l; - texty = h - texth - b; + h = t + b + (p->n_targets * ICON_SIZE) + OUTSIDE_BORDER; /* find the position for the popup (include the outer borders) */ x = screen_area->x + (screen_area->width - @@ -304,12 +281,6 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) rgbaw = w - ml - mr; rgbah = h - mt - mb; - /* center the icons if there is less than one row */ - if (icon_rows == 1) - icons_center_x = (w - p->n_targets * ICON_SIZE) / 2; - else - icons_center_x = 0; - if (!p->mapped) { /* position the background but don't draw it*/ XMoveResizeWindow(obt_display, p->bg, x, y, w, h); @@ -320,24 +291,17 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) p->a_bg->texture[0].data.rgba.alpha = 0xff; p->hilite_rgba = g_new(RrPixel32, rgbaw * rgbah); p->a_bg->texture[0].data.rgba.data = p->hilite_rgba; - - /* position the text, but don't draw it */ - XMoveResizeWindow(obt_display, p->text, textx, texty, textw, texth); - p->a_text->surface.parentx = textx; - p->a_text->surface.parenty = texty; } /* find the focused target */ for (i = 0, it = p->targets; it; ++i, it = g_list_next(it)) { const ObFocusCyclePopupTarget *target = it->data; - const gint row = i / icons_per_row; /* starting from 0 */ - const gint col = i % icons_per_row; /* starting from 0 */ if (target->client == c) { /* save the target */ newtarget = target; - newtargetx = icons_center_x + l + (col * ICON_SIZE); - newtargety = t + (row * ICON_SIZE); + newtargetx = l; + newtargety = t + i * ICON_SIZE; if (!p->mapped) break; /* if we're not dimensioning, then we're done */ @@ -391,7 +355,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* draw the background */ RrPaint(p->a_bg, p->bg, w, h); - /* draw the icons */ + /* draw the icons and text */ for (i = 0, it = p->targets; it; ++i, it = g_list_next(it)) { const ObFocusCyclePopupTarget *target = it->data; @@ -399,20 +363,23 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) they can pick up the hilite changes in the backgroud */ if (!p->mapped || newtarget == target || p->last_target == target) { const ObClientIcon *icon; - const gint row = i / icons_per_row; /* starting from 0 */ - const gint col = i % icons_per_row; /* starting from 0 */ gint innerx, innery; /* find the dimensions of the icon inside it */ - innerx = icons_center_x + l + (col * ICON_SIZE); + innerx = l; innerx += ICON_HILITE_WIDTH + ICON_HILITE_MARGIN; - innery = t + (row * ICON_SIZE); + innery = t + i * ICON_SIZE; innery += ICON_HILITE_WIDTH + ICON_HILITE_MARGIN; /* move the icon */ - XMoveResizeWindow(obt_display, target->win, + XMoveResizeWindow(obt_display, target->iconwin, innerx, innery, innerw, innerh); + /* move the text */ + XMoveResizeWindow(obt_display, target->textwin, + innerx + ICON_SIZE, innery, + w - innerx - ICON_SIZE - OUTSIDE_BORDER, innerh); + /* get the icon from the client */ icon = client_icon(target->client, innerw, innerh); p->a_icon->texture[0].data.rgba.width = icon->width; @@ -424,16 +391,16 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* draw the icon */ p->a_icon->surface.parentx = innerx; p->a_icon->surface.parenty = innery; - RrPaint(p->a_icon, target->win, innerw, innerh); + RrPaint(p->a_icon, target->iconwin, innerw, innerh); + + /* draw the text */ + p->a_text->texture[0].data.text.string = target->text; + p->a_text->surface.parentx = innerx + ICON_SIZE; + p->a_text->surface.parenty = innery; + RrPaint(p->a_text, target->textwin, w - innerx - ICON_SIZE - OUTSIDE_BORDER, innerh); } } - /* draw the text */ - p->a_text->texture[0].data.text.string = newtarget->text; - p->a_text->surface.parentx = textx; - p->a_text->surface.parenty = texty; - RrPaint(p->a_text, p->text, textw, texth); - p->last_target = newtarget; g_free(screen_area); @@ -479,7 +446,8 @@ void focus_cycle_popup_hide(void) ObFocusCyclePopupTarget *t = popup.targets->data; g_free(t->text); - XDestroyWindow(obt_display, t->win); + XDestroyWindow(obt_display, t->iconwin); + XDestroyWindow(obt_display, t->textwin); g_free(t); popup.targets = g_list_delete_link(popup.targets, popup.targets); -- cgit v1.2.3 From d35dd5ce74bb1e6aadf8047be5b80324b0db37ed Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sun, 2 Sep 2007 14:52:39 +0200 Subject: Draw the hilite texture with the icon appearance instead of the background. This means we don't have to redraw the whole background every time. However, the hilite is now a bit too small (or the icon is a bit too big). --- openbox/focus_cycle_popup.c | 56 ++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index b98ebc17..f39483a2 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -100,15 +100,14 @@ void focus_cycle_popup_startup(gboolean reconfig) popup.obwin.type = OB_WINDOW_CLASS_INTERNAL; popup.a_bg = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg); popup.a_text = RrAppearanceCopy(ob_rr_theme->osd_hilite_label); - popup.a_icon = RrAppearanceCopy(ob_rr_theme->a_clear_tex); + popup.a_icon = RrAppearanceCopy(ob_rr_theme->a_clear); popup.a_text->surface.parent = popup.a_bg; popup.a_icon->surface.parent = popup.a_bg; - popup.a_icon->texture[0].type = RR_TEXTURE_RGBA; + RrAppearanceAddTextures(popup.a_icon, 2); - RrAppearanceAddTextures(popup.a_bg, 1); - popup.a_bg->texture[0].type = RR_TEXTURE_RGBA; + popup.a_icon->texture[1].type = RR_TEXTURE_RGBA; attrib.override_redirect = True; attrib.border_pixel=RrColorPixel(ob_rr_theme->osd_border_color); @@ -267,6 +266,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) w = MAX(w, POPUP_WIDTH); /* min width */ /* find the height of the dialog */ +#warning limit the height and scroll entries somehow h = t + b + (p->n_targets * ICON_SIZE) + OUTSIDE_BORDER; /* find the position for the popup (include the outer borders) */ @@ -285,12 +285,12 @@ 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); - /* set up the hilite texture for the background */ - p->a_bg->texture[0].data.rgba.width = rgbaw; - p->a_bg->texture[0].data.rgba.height = rgbah; - p->a_bg->texture[0].data.rgba.alpha = 0xff; - p->hilite_rgba = g_new(RrPixel32, rgbaw * rgbah); - p->a_bg->texture[0].data.rgba.data = p->hilite_rgba; + /* set up the hilite texture for the icon */ + p->a_icon->texture[0].data.rgba.width = ICON_SIZE; + p->a_icon->texture[0].data.rgba.height = ICON_SIZE; + p->a_icon->texture[0].data.rgba.alpha = 0xff; + p->hilite_rgba = g_new(RrPixel32, ICON_SIZE * ICON_SIZE); + p->a_icon->texture[0].data.rgba.data = p->hilite_rgba; } /* find the focused target */ @@ -320,22 +320,14 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) ((ob_rr_theme->osd_color->b & 0xff) << RrDefaultBlueOffset); o = 0; - for (i = 0; i < rgbah; ++i) - for (j = 0; j < rgbaw; ++j) { + for (x = 0; x < ICON_SIZE; x++) + for (y = 0; y < ICON_SIZE; y++) { guchar a; - const gint x = j + rgbax - newtargetx; - const gint y = i + rgbay - newtargety; - if (x < 0 || x >= ICON_SIZE || - y < 0 || y >= ICON_SIZE) - { - /* outside the target */ - a = 0x00; - } - else if (x < ICON_HILITE_WIDTH || - x >= ICON_SIZE - ICON_HILITE_WIDTH || - y < ICON_HILITE_WIDTH || - y >= ICON_SIZE - ICON_HILITE_WIDTH) + if (x < ICON_HILITE_WIDTH || + x >= ICON_SIZE - ICON_HILITE_WIDTH || + y < ICON_HILITE_WIDTH || + y >= ICON_SIZE - ICON_HILITE_WIDTH) { /* the border of the target */ a = 0x88; @@ -353,7 +345,8 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* * * draw everything * * */ /* draw the background */ - RrPaint(p->a_bg, p->bg, w, h); + if (!p->mapped) + RrPaint(p->a_bg, p->bg, w, h); /* draw the icons and text */ for (i = 0, it = p->targets; it; ++i, it = g_list_next(it)) { @@ -382,11 +375,16 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* get the icon from the client */ icon = client_icon(target->client, innerw, innerh); - p->a_icon->texture[0].data.rgba.width = icon->width; - p->a_icon->texture[0].data.rgba.height = icon->height; - p->a_icon->texture[0].data.rgba.alpha = + p->a_icon->texture[1].data.rgba.width = icon->width; + p->a_icon->texture[1].data.rgba.height = icon->height; + p->a_icon->texture[1].data.rgba.alpha = target->client->iconic ? OB_ICONIC_ALPHA : 0xff; - p->a_icon->texture[0].data.rgba.data = icon->data; + p->a_icon->texture[1].data.rgba.data = icon->data; + + /* Draw the hilite? */ +#warning do i have to add more obrender interface thingers to get it to draw the icon inside the hilight? sigh + p->a_icon->texture[0].type = (target == newtarget) ? + RR_TEXTURE_RGBA : RR_TEXTURE_NONE; /* draw the icon */ p->a_icon->surface.parentx = innerx; -- cgit v1.2.3 From 23f3d6e34fcb4714c58e55b2528f897e2f0effe4 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sun, 2 Sep 2007 22:29:34 +0200 Subject: Move hilite texture rendering to init time, and draw it after the icon. --- openbox/focus_cycle_popup.c | 94 ++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 49 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index f39483a2..2c3d4c39 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -107,7 +107,7 @@ void focus_cycle_popup_startup(gboolean reconfig) RrAppearanceAddTextures(popup.a_icon, 2); - popup.a_icon->texture[1].type = RR_TEXTURE_RGBA; + popup.a_icon->texture[0].type = RR_TEXTURE_RGBA; attrib.override_redirect = True; attrib.border_pixel=RrColorPixel(ob_rr_theme->osd_border_color); @@ -118,7 +118,45 @@ void focus_cycle_popup_startup(gboolean reconfig) popup.n_targets = 0; popup.last_target = NULL; - popup.hilite_rgba = NULL; + /* set up the hilite texture for the icon */ + popup.a_icon->texture[1].data.rgba.width = ICON_SIZE; + popup.a_icon->texture[1].data.rgba.height = ICON_SIZE; + popup.a_icon->texture[1].data.rgba.alpha = 0xff; + popup.hilite_rgba = g_new(RrPixel32, ICON_SIZE * ICON_SIZE); + popup.a_icon->texture[1].data.rgba.data = popup.hilite_rgba; + + /* create the hilite under the target icon */ + { + RrPixel32 color; + gint x, y, o; + + color = ((ob_rr_theme->osd_color->r & 0xff) << RrDefaultRedOffset) + + ((ob_rr_theme->osd_color->g & 0xff) << RrDefaultGreenOffset) + + ((ob_rr_theme->osd_color->b & 0xff) << RrDefaultBlueOffset); + + o = 0; + for (x = 0; x < ICON_SIZE; x++) + for (y = 0; y < ICON_SIZE; y++) { + guchar a; + + if (x < ICON_HILITE_WIDTH || + x >= ICON_SIZE - ICON_HILITE_WIDTH || + y < ICON_HILITE_WIDTH || + y >= ICON_SIZE - ICON_HILITE_WIDTH) + { + /* the border of the target */ + a = 0x88; + } + else { + /* the background of the target */ + a = 0x22; + } + + popup.hilite_rgba[o++] = + color + (a << RrDefaultAlphaOffset); + } + } + stacking_add(INTERNAL_AS_WINDOW(&popup)); window_add(&popup.bg, INTERNAL_AS_WINDOW(&popup)); @@ -284,13 +322,6 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) if (!p->mapped) { /* position the background but don't draw it*/ XMoveResizeWindow(obt_display, p->bg, x, y, w, h); - - /* set up the hilite texture for the icon */ - p->a_icon->texture[0].data.rgba.width = ICON_SIZE; - p->a_icon->texture[0].data.rgba.height = ICON_SIZE; - p->a_icon->texture[0].data.rgba.alpha = 0xff; - p->hilite_rgba = g_new(RrPixel32, ICON_SIZE * ICON_SIZE); - p->a_icon->texture[0].data.rgba.data = p->hilite_rgba; } /* find the focused target */ @@ -310,38 +341,6 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) g_assert(newtarget != NULL); - /* create the hilite under the target icon */ - { - RrPixel32 color; - gint i, j, o; - - color = ((ob_rr_theme->osd_color->r & 0xff) << RrDefaultRedOffset) + - ((ob_rr_theme->osd_color->g & 0xff) << RrDefaultGreenOffset) + - ((ob_rr_theme->osd_color->b & 0xff) << RrDefaultBlueOffset); - - o = 0; - for (x = 0; x < ICON_SIZE; x++) - for (y = 0; y < ICON_SIZE; y++) { - guchar a; - - if (x < ICON_HILITE_WIDTH || - x >= ICON_SIZE - ICON_HILITE_WIDTH || - y < ICON_HILITE_WIDTH || - y >= ICON_SIZE - ICON_HILITE_WIDTH) - { - /* the border of the target */ - a = 0x88; - } - else { - /* the background of the target */ - a = 0x22; - } - - p->hilite_rgba[o++] = - color + (a << RrDefaultAlphaOffset); - } - } - /* * * draw everything * * */ /* draw the background */ @@ -375,15 +374,15 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* get the icon from the client */ icon = client_icon(target->client, innerw, innerh); - p->a_icon->texture[1].data.rgba.width = icon->width; - p->a_icon->texture[1].data.rgba.height = icon->height; - p->a_icon->texture[1].data.rgba.alpha = + p->a_icon->texture[0].data.rgba.width = icon->width; + p->a_icon->texture[0].data.rgba.height = icon->height; + p->a_icon->texture[0].data.rgba.alpha = target->client->iconic ? OB_ICONIC_ALPHA : 0xff; - p->a_icon->texture[1].data.rgba.data = icon->data; + p->a_icon->texture[0].data.rgba.data = icon->data; /* Draw the hilite? */ #warning do i have to add more obrender interface thingers to get it to draw the icon inside the hilight? sigh - p->a_icon->texture[0].type = (target == newtarget) ? + p->a_icon->texture[1].type = (target == newtarget) ? RR_TEXTURE_RGBA : RR_TEXTURE_NONE; /* draw the icon */ @@ -452,9 +451,6 @@ void focus_cycle_popup_hide(void) } popup.n_targets = 0; popup.last_target = NULL; - - g_free(popup.hilite_rgba); - popup.hilite_rgba = NULL; } void focus_cycle_popup_single_show(struct _ObClient *c, -- cgit v1.2.3 From da5f4e08f5e77fe6fe54d65b668aa129150b281b Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sun, 2 Sep 2007 22:43:28 +0200 Subject: Don't need to hang on to the hilite_rgba pointer any more. --- openbox/focus_cycle_popup.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 2c3d4c39..028b5d9b 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -63,8 +63,6 @@ struct _ObFocusCyclePopup RrAppearance *a_text; RrAppearance *a_icon; - RrPixel32 *hilite_rgba; - gboolean mapped; }; @@ -94,6 +92,7 @@ static Window create_window(Window parent, guint bwidth, gulong mask, void focus_cycle_popup_startup(gboolean reconfig) { XSetWindowAttributes attrib; + RrPixel32 *p; single_popup = icon_popup_new(); @@ -122,8 +121,8 @@ void focus_cycle_popup_startup(gboolean reconfig) popup.a_icon->texture[1].data.rgba.width = ICON_SIZE; popup.a_icon->texture[1].data.rgba.height = ICON_SIZE; popup.a_icon->texture[1].data.rgba.alpha = 0xff; - popup.hilite_rgba = g_new(RrPixel32, ICON_SIZE * ICON_SIZE); - popup.a_icon->texture[1].data.rgba.data = popup.hilite_rgba; + p = g_new(RrPixel32, ICON_SIZE * ICON_SIZE); + popup.a_icon->texture[1].data.rgba.data = p; /* create the hilite under the target icon */ { @@ -152,12 +151,10 @@ void focus_cycle_popup_startup(gboolean reconfig) a = 0x22; } - popup.hilite_rgba[o++] = - color + (a << RrDefaultAlphaOffset); + p[o++] = color + (a << RrDefaultAlphaOffset); } } - stacking_add(INTERNAL_AS_WINDOW(&popup)); window_add(&popup.bg, INTERNAL_AS_WINDOW(&popup)); } @@ -179,9 +176,6 @@ void focus_cycle_popup_shutdown(gboolean reconfig) popup.targets = g_list_delete_link(popup.targets, popup.targets); } - g_free(popup.hilite_rgba); - popup.hilite_rgba = NULL; - XDestroyWindow(obt_display, popup.bg); RrAppearanceFree(popup.a_icon); -- cgit v1.2.3 From 3592046b2b26e05ee94c0dd0fed5b7fd5475c198 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Mon, 3 Sep 2007 00:16:26 +0200 Subject: Make the icon and hilite the proper sizes. Had to add some obrender thingers and fiddle around a bit. Also fixed up some confusing logic. --- openbox/focus_cycle_popup.c | 77 ++++++++++++++++++++++++--------------------- render/render.c | 18 ++++++++--- render/render.h | 5 +++ 3 files changed, 61 insertions(+), 39 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 028b5d9b..532de4ba 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -30,9 +30,11 @@ #include #include -#define ICON_SIZE 40 -#define ICON_HILITE_WIDTH 2 -#define ICON_HILITE_MARGIN 1 +#define HILITE_SIZE 40 +#define HILITE_WIDTH 2 +#define HILITE_MARGIN 1 +#define HILITE_OFFSET (HILITE_WIDTH + HILITE_MARGIN) +#define ICON_SIZE (HILITE_SIZE - 2*HILITE_OFFSET) #define OUTSIDE_BORDER 3 #define TEXT_BORDER 2 @@ -118,10 +120,10 @@ void focus_cycle_popup_startup(gboolean reconfig) popup.last_target = NULL; /* set up the hilite texture for the icon */ - popup.a_icon->texture[1].data.rgba.width = ICON_SIZE; - popup.a_icon->texture[1].data.rgba.height = ICON_SIZE; + popup.a_icon->texture[1].data.rgba.width = HILITE_SIZE; + popup.a_icon->texture[1].data.rgba.height = HILITE_SIZE; popup.a_icon->texture[1].data.rgba.alpha = 0xff; - p = g_new(RrPixel32, ICON_SIZE * ICON_SIZE); + p = g_new(RrPixel32, HILITE_SIZE * HILITE_SIZE); popup.a_icon->texture[1].data.rgba.data = p; /* create the hilite under the target icon */ @@ -134,14 +136,14 @@ void focus_cycle_popup_startup(gboolean reconfig) ((ob_rr_theme->osd_color->b & 0xff) << RrDefaultBlueOffset); o = 0; - for (x = 0; x < ICON_SIZE; x++) - for (y = 0; y < ICON_SIZE; y++) { + for (x = 0; x < HILITE_SIZE; x++) + for (y = 0; y < HILITE_SIZE; y++) { guchar a; - if (x < ICON_HILITE_WIDTH || - x >= ICON_SIZE - ICON_HILITE_WIDTH || - y < ICON_HILITE_WIDTH || - y >= ICON_SIZE - ICON_HILITE_WIDTH) + if (x < HILITE_WIDTH || + x >= HILITE_SIZE - HILITE_WIDTH || + y < HILITE_WIDTH || + y >= HILITE_SIZE - HILITE_WIDTH) { /* the border of the target */ a = 0x88; @@ -271,7 +273,6 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) gint x, y, w, h; Rect *screen_area = NULL; gint rgbax, rgbay, rgbaw, rgbah; - gint innerw, innerh; gint i; GList *it; const ObFocusCyclePopupTarget *newtarget; @@ -288,10 +289,6 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) t = mt + OUTSIDE_BORDER; b = mb + OUTSIDE_BORDER; - /* get the icon pictures' sizes */ - innerw = ICON_SIZE - (ICON_HILITE_WIDTH + ICON_HILITE_MARGIN) * 2; - innerh = ICON_SIZE - (ICON_HILITE_WIDTH + ICON_HILITE_MARGIN) * 2; - /* get the width from the text and keep it within limits */ w = l + r + p->maxtextw; w = MIN(w, MAX(screen_area->width/3, POPUP_WIDTH)); /* max width */ @@ -299,7 +296,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* find the height of the dialog */ #warning limit the height and scroll entries somehow - h = t + b + (p->n_targets * ICON_SIZE) + OUTSIDE_BORDER; + h = t + b + (p->n_targets * HILITE_SIZE); /* find the position for the popup (include the outer borders) */ x = screen_area->x + (screen_area->width - @@ -326,7 +323,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* save the target */ newtarget = target; newtargetx = l; - newtargety = t + i * ICON_SIZE; + newtargety = t + i * HILITE_SIZE; if (!p->mapped) break; /* if we're not dimensioning, then we're done */ @@ -345,50 +342,59 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) for (i = 0, it = p->targets; it; ++i, it = g_list_next(it)) { const ObFocusCyclePopupTarget *target = it->data; - /* have to redraw the targetted icon and last targetted icon, - they can pick up the hilite changes in the backgroud */ + /* have to redraw the targetted icon and last targetted icon + * to update the hilite */ if (!p->mapped || newtarget == target || p->last_target == target) { const ObClientIcon *icon; - gint innerx, innery; + gint innerx, innery, textx, texty; + gint textw /* texth = ICON_SIZE */; /* find the dimensions of the icon inside it */ innerx = l; - innerx += ICON_HILITE_WIDTH + ICON_HILITE_MARGIN; - innery = t + i * ICON_SIZE; - innery += ICON_HILITE_WIDTH + ICON_HILITE_MARGIN; + innery = t + i * HILITE_SIZE; + + /* find the dimensions of the text box */ + textx = innerx + HILITE_SIZE + TEXT_BORDER; + texty = innery + HILITE_OFFSET; + textw = w + /* left edge */ - innerx - HILITE_SIZE - TEXT_BORDER + /* right edge */ - OUTSIDE_BORDER - TEXT_BORDER; /* move the icon */ XMoveResizeWindow(obt_display, target->iconwin, - innerx, innery, innerw, innerh); + innerx, innery, HILITE_SIZE, HILITE_SIZE); /* move the text */ XMoveResizeWindow(obt_display, target->textwin, - innerx + ICON_SIZE, innery, - w - innerx - ICON_SIZE - OUTSIDE_BORDER, innerh); + textx, texty, + textw, ICON_SIZE); /* get the icon from the client */ - icon = client_icon(target->client, innerw, innerh); + icon = client_icon(target->client, ICON_SIZE, ICON_SIZE); p->a_icon->texture[0].data.rgba.width = icon->width; p->a_icon->texture[0].data.rgba.height = icon->height; + p->a_icon->texture[0].data.rgba.twidth = ICON_SIZE; + p->a_icon->texture[0].data.rgba.theight = ICON_SIZE; + p->a_icon->texture[0].data.rgba.tx = HILITE_OFFSET; + p->a_icon->texture[0].data.rgba.ty = HILITE_OFFSET; p->a_icon->texture[0].data.rgba.alpha = target->client->iconic ? OB_ICONIC_ALPHA : 0xff; p->a_icon->texture[0].data.rgba.data = icon->data; /* Draw the hilite? */ -#warning do i have to add more obrender interface thingers to get it to draw the icon inside the hilight? sigh p->a_icon->texture[1].type = (target == newtarget) ? RR_TEXTURE_RGBA : RR_TEXTURE_NONE; /* draw the icon */ p->a_icon->surface.parentx = innerx; p->a_icon->surface.parenty = innery; - RrPaint(p->a_icon, target->iconwin, innerw, innerh); + RrPaint(p->a_icon, target->iconwin, HILITE_SIZE, HILITE_SIZE); /* draw the text */ p->a_text->texture[0].data.text.string = target->text; - p->a_text->surface.parentx = innerx + ICON_SIZE; - p->a_text->surface.parenty = innery; - RrPaint(p->a_text, target->textwin, w - innerx - ICON_SIZE - OUTSIDE_BORDER, innerh); + p->a_text->surface.parentx = textx; + p->a_text->surface.parenty = texty; + RrPaint(p->a_text, target->textwin, textw, ICON_SIZE); } } @@ -477,7 +483,8 @@ void focus_cycle_popup_single_show(struct _ObClient *c, } text = popup_get_name(c); - icon_popup_show(single_popup, text, client_icon(c, ICON_SIZE, ICON_SIZE)); + icon_popup_show(single_popup, text, client_icon(c, HILITE_SIZE, + HILITE_SIZE)); g_free(text); screen_hide_desktop_popup(); } diff --git a/render/render.c b/render/render.c index 4119dc7f..7791429a 100644 --- a/render/render.c +++ b/render/render.c @@ -132,10 +132,20 @@ Pixmap RrPaintPixmap(RrAppearance *a, gint w, gint h) break; case RR_TEXTURE_RGBA: g_assert(!transferred); - RrImageDraw(a->surface.pixel_data, - &a->texture[i].data.rgba, - a->w, a->h, - &tarea); + { + RrRect narea = tarea; + RrTextureRGBA *rgb = &a->texture[i].data.rgba; + if (rgb->twidth) + narea.width = MIN(tarea.width, rgb->twidth); + if (rgb->theight) + narea.height = MIN(tarea.height, rgb->theight); + narea.x += rgb->tx; + narea.y += rgb->ty; + RrImageDraw(a->surface.pixel_data, + &a->texture[i].data.rgba, + a->w, a->h, + &narea); + } force_transfer = 1; break; } diff --git a/render/render.h b/render/render.h index 1f87c6e0..7b81e2ff 100644 --- a/render/render.h +++ b/render/render.h @@ -165,6 +165,11 @@ struct _RrTextureRGBA { gint cwidth; gint cheight; RrPixel32 *cache; +/* size and position to draw at */ + gint tx; + gint ty; + gint twidth; + gint theight; }; struct _RrTextureLineArt { -- cgit v1.2.3 From 2924adb9b1addab67983a5276ec6932b7b7933d6 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Mon, 3 Sep 2007 00:42:14 +0200 Subject: Use a_unfocused_label for all but the hilited items. Should introduce some sort of theme element for this I suppose, but dana is not here. --- openbox/focus_cycle_popup.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 532de4ba..d303d2e2 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -63,6 +63,7 @@ struct _ObFocusCyclePopup RrAppearance *a_bg; RrAppearance *a_text; + RrAppearance *a_hilite_text; RrAppearance *a_icon; gboolean mapped; @@ -100,9 +101,11 @@ void focus_cycle_popup_startup(gboolean reconfig) popup.obwin.type = OB_WINDOW_CLASS_INTERNAL; popup.a_bg = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg); - popup.a_text = RrAppearanceCopy(ob_rr_theme->osd_hilite_label); + popup.a_hilite_text = RrAppearanceCopy(ob_rr_theme->osd_hilite_label); + popup.a_text = RrAppearanceCopy(ob_rr_theme->a_unfocused_label); popup.a_icon = RrAppearanceCopy(ob_rr_theme->a_clear); + popup.a_hilite_text->surface.parent = popup.a_bg; popup.a_text->surface.parent = popup.a_bg; popup.a_icon->surface.parent = popup.a_bg; @@ -181,6 +184,7 @@ void focus_cycle_popup_shutdown(gboolean reconfig) XDestroyWindow(obt_display, popup.bg); RrAppearanceFree(popup.a_icon); + RrAppearanceFree(popup.a_hilite_text); RrAppearanceFree(popup.a_text); RrAppearanceFree(popup.a_bg); } @@ -348,6 +352,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) const ObClientIcon *icon; gint innerx, innery, textx, texty; gint textw /* texth = ICON_SIZE */; + RrAppearance *text; /* find the dimensions of the icon inside it */ innerx = l; @@ -391,10 +396,11 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) RrPaint(p->a_icon, target->iconwin, HILITE_SIZE, HILITE_SIZE); /* draw the text */ - p->a_text->texture[0].data.text.string = target->text; - p->a_text->surface.parentx = textx; - p->a_text->surface.parenty = texty; - RrPaint(p->a_text, target->textwin, textw, ICON_SIZE); + text = (target == newtarget) ? p->a_hilite_text : p->a_text; + text->texture[0].data.text.string = target->text; + text->surface.parentx = textx; + text->surface.parenty = texty; + RrPaint(text, target->textwin, textw, ICON_SIZE); } } -- cgit v1.2.3 From 76464a604ee2999b00b806be25722f7fcac1cd9c Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 3 Feb 2008 00:07:21 -0500 Subject: combine the old focus cycle popup code with mika's new list-mode popup, and make an action option for it (the old option) --- openbox/actions/cyclewindows.c | 16 ++-- openbox/focus_cycle.c | 17 ++-- openbox/focus_cycle.h | 3 +- openbox/focus_cycle_popup.c | 173 ++++++++++++++++++++++++++++++++--------- openbox/focus_cycle_popup.h | 9 ++- 5 files changed, 165 insertions(+), 53 deletions(-) diff --git a/openbox/actions/cyclewindows.c b/openbox/actions/cyclewindows.c index 36dd66ee..b013b66b 100644 --- a/openbox/actions/cyclewindows.c +++ b/openbox/actions/cyclewindows.c @@ -8,13 +8,13 @@ typedef struct { gboolean linear; - gboolean dialog; gboolean dock_windows; gboolean desktop_windows; gboolean all_desktops; gboolean forward; gboolean bar; gboolean raise; + ObFocusCyclePopupMode dialog_mode; GSList *actions; } Options; @@ -47,13 +47,17 @@ static gpointer setup_func(xmlNodePtr node) Options *o; o = g_new0(Options, 1); - o->dialog = TRUE; o->bar = TRUE; + o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_ICONS; if ((n = obt_parse_find_node(node, "linear"))) o->linear = obt_parse_node_bool(n); - if ((n = obt_parse_find_node(node, "dialog"))) - o->dialog = obt_parse_node_bool(n); + if ((n = obt_parse_find_node(node, "dialog"))) { + if (obt_parse_node_contains(n, "none")) + o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_NONE; + else if (obt_parse_node_contains(n, "list")) + o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_LIST; + } if ((n = obt_parse_find_node(node, "bar"))) o->bar = obt_parse_node_bool(n); if ((n = obt_parse_find_node(node, "raise"))) @@ -125,7 +129,7 @@ static gboolean run_func(ObActionsData *data, gpointer options) o->linear, TRUE, o->bar, - o->dialog, + o->dialog_mode, FALSE, FALSE); cycling = TRUE; @@ -185,7 +189,7 @@ static void end_cycle(gboolean cancel, guint state, Options *o) o->linear, TRUE, o->bar, - o->dialog, + o->dialog_mode, TRUE, cancel); cycling = FALSE; diff --git a/openbox/focus_cycle.c b/openbox/focus_cycle.c index 2348f8d0..dbf79c9a 100644 --- a/openbox/focus_cycle.c +++ b/openbox/focus_cycle.c @@ -19,7 +19,6 @@ #include "focus_cycle.h" #include "focus_cycle_indicator.h" -#include "focus_cycle_popup.h" #include "client.h" #include "frame.h" #include "focus.h" @@ -70,7 +69,7 @@ void focus_cycle_stop(ObClient *ifclient) ObClient* focus_cycle(gboolean forward, gboolean all_desktops, gboolean dock_windows, gboolean desktop_windows, gboolean linear, gboolean interactive, - gboolean showbar, gboolean dialog, + gboolean showbar, ObFocusCyclePopupMode mode, gboolean done, gboolean cancel) { static ObClient *t = NULL; @@ -131,13 +130,13 @@ ObClient* focus_cycle(gboolean forward, gboolean all_desktops, focus_cycle_target = ft; focus_cycle_draw_indicator(showbar ? ft : NULL); } - if (dialog) - /* same arguments as focus_target_valid */ - focus_cycle_popup_show(ft, - focus_cycle_iconic_windows, - focus_cycle_all_desktops, - focus_cycle_dock_windows, - focus_cycle_desktop_windows); + /* same arguments as focus_target_valid */ + focus_cycle_popup_show(ft, + focus_cycle_iconic_windows, + focus_cycle_all_desktops, + focus_cycle_dock_windows, + focus_cycle_desktop_windows, + mode); return focus_cycle_target; } else if (ft != focus_cycle_target) { focus_cycle_target = ft; diff --git a/openbox/focus_cycle.h b/openbox/focus_cycle.h index 6e1c2c9d..c31abc81 100644 --- a/openbox/focus_cycle.h +++ b/openbox/focus_cycle.h @@ -21,6 +21,7 @@ #define __focus_cycle_h #include "misc.h" +#include "focus_cycle_popup.h" #include #include @@ -37,7 +38,7 @@ void focus_cycle_shutdown(gboolean reconfig); struct _ObClient* focus_cycle(gboolean forward, gboolean all_desktops, gboolean dock_windows, gboolean desktop_windows, gboolean linear, gboolean interactive, - gboolean showbar, gboolean dialog, + gboolean showbar, ObFocusCyclePopupMode mode, gboolean done, gboolean cancel); struct _ObClient* focus_directional_cycle(ObDirection dir, gboolean dock_windows, diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index d303d2e2..9f3fa3e8 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -30,12 +30,19 @@ #include #include +/* Size of the hilite box around a window's icon */ #define HILITE_SIZE 40 +/* Width of the outer ring around the hilite box */ #define HILITE_WIDTH 2 +/* Space between the outer ring around the hilite box and the icon inside it */ #define HILITE_MARGIN 1 +/* Total distance from the edge of the hilite box to the icon inside it */ #define HILITE_OFFSET (HILITE_WIDTH + HILITE_MARGIN) +/* Size of the icons, which can appear inside or outside of a hilite box */ #define ICON_SIZE (HILITE_SIZE - 2*HILITE_OFFSET) +/* Margin area around the outside of the dialog */ #define OUTSIDE_BORDER 3 +/* Margin area around the text */ #define TEXT_BORDER 2 typedef struct _ObFocusCyclePopup ObFocusCyclePopup; @@ -46,6 +53,7 @@ struct _ObFocusCyclePopupTarget ObClient *client; gchar *text; Window iconwin; + /* This is used when the popup is in list mode */ Window textwin; }; @@ -54,6 +62,9 @@ struct _ObFocusCyclePopup ObWindow obwin; Window bg; + /* This is used when the popup is in icon mode */ + Window icon_mode_text; + GList *targets; gint n_targets; @@ -82,7 +93,8 @@ static void popup_setup (ObFocusCyclePopup *p, gboolean dock_windows, gboolean desktop_windows); static void popup_render (ObFocusCyclePopup *p, - const ObClient *c); + const ObClient *c, + ObFocusCyclePopupMode mode); static Window create_window(Window parent, guint bwidth, gulong mask, XSetWindowAttributes *attr) @@ -109,6 +121,11 @@ void focus_cycle_popup_startup(gboolean reconfig) popup.a_text->surface.parent = popup.a_bg; popup.a_icon->surface.parent = popup.a_bg; + popup.a_text->texture[0].data.text.justify = RR_JUSTIFY_LEFT; + popup.a_hilite_text->texture[0].data.text.justify = RR_JUSTIFY_LEFT; + + /* 2 textures. texture[0] is the icon. texture[1] is the hilight, and + may or may not be used */ RrAppearanceAddTextures(popup.a_icon, 2); popup.a_icon->texture[0].type = RR_TEXTURE_RGBA; @@ -118,6 +135,10 @@ void focus_cycle_popup_startup(gboolean reconfig) popup.bg = create_window(obt_root(ob_screen), ob_rr_theme->obwidth, CWOverrideRedirect | CWBorderPixel, &attrib); + /* 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; popup.last_target = NULL; @@ -181,6 +202,10 @@ void focus_cycle_popup_shutdown(gboolean reconfig) popup.targets = g_list_delete_link(popup.targets, popup.targets); } + g_free(popup.a_icon->texture[1].data.rgba.data); + popup.a_icon->texture[1].data.rgba.data = NULL; + + XDestroyWindow(obt_display, popup.icon_mode_text); XDestroyWindow(obt_display, popup.bg); RrAppearanceFree(popup.a_icon); @@ -270,7 +295,8 @@ static gchar *popup_get_name(ObClient *c) return ret; } -static void popup_render(ObFocusCyclePopup *p, const ObClient *c) +static void popup_render(ObFocusCyclePopup *p, const ObClient *c, + ObFocusCyclePopupMode mode) { gint ml, mt, mr, mb; gint l, t, r, b; @@ -280,7 +306,20 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) gint i; GList *it; const ObFocusCyclePopupTarget *newtarget; - gint newtargetx, newtargety; + gint icons_per_row; + gint icon_rows; + gint textw, texth; + + /* vars for icon mode */ + gint icon_mode_textx; + gint icon_mode_texty; + gint icons_center_x; + + /* vars for list mode */ + gint list_mode_icon_column_w = HILITE_SIZE + OUTSIDE_BORDER; + + g_assert(mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS || + mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST); screen_area = screen_physical_area_active(); @@ -295,12 +334,53 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* get the width from the text and keep it within limits */ w = l + r + p->maxtextw; + if (mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) + /* when in list mode, there are icons down the side */ + w += list_mode_icon_column_w; w = MIN(w, MAX(screen_area->width/3, POPUP_WIDTH)); /* max width */ w = MAX(w, POPUP_WIDTH); /* min width */ + if (mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) { + /* how many icons will fit in that row? make the width fit that */ + w -= l + r; + icons_per_row = (w + ICON_SIZE - 1) / ICON_SIZE; + w = icons_per_row * ICON_SIZE + l + r; + + /* how many rows do we need? */ + icon_rows = (p->n_targets-1) / icons_per_row + 1; + + } + else { + /* in list mode, there is one column of icons.. */ + icons_per_row = 1; + icon_rows = p->n_targets; + } + + /* get the text dimensions */ + 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 - h = t + b + (p->n_targets * HILITE_SIZE); + h = t + b + (icon_rows * MAX(HILITE_SIZE, texth)); + if (mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) + /* in icon mode the text sits below the icons, so make some space */ + h += OUTSIDE_BORDER + texth; + + /* center the icons if there is less than one row */ + if (icon_rows == 1) + icons_center_x = (w - p->n_targets * ICON_SIZE) / 2; + else + icons_center_x = 0; + + if (mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) { + /* get the position of the text */ + icon_mode_textx = l; + icon_mode_texty = h - texth - b; + } /* find the position for the popup (include the outer borders) */ x = screen_area->x + (screen_area->width - @@ -315,22 +395,23 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) rgbah = h - mt - mb; if (!p->mapped) { - /* position the background but don't draw it*/ + /* 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) + /* position the text */ + XMoveResizeWindow(obt_display, p->icon_mode_text, + icon_mode_textx, icon_mode_texty, textw, texth); } /* find the focused target */ + newtarget = NULL; for (i = 0, it = p->targets; it; ++i, it = g_list_next(it)) { const ObFocusCyclePopupTarget *target = it->data; - if (target->client == c) { /* save the target */ newtarget = target; - newtargetx = l; - newtargety = t + i * HILITE_SIZE; - - if (!p->mapped) - break; /* if we're not dimensioning, then we're done */ + break; } } @@ -349,30 +430,34 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* have to redraw the targetted icon and last targetted icon * to update the hilite */ if (!p->mapped || newtarget == target || p->last_target == target) { + const gint row = i / icons_per_row; /* starting from 0 */ + const gint col = i % icons_per_row; /* starting from 0 */ const ObClientIcon *icon; - gint innerx, innery, textx, texty; - gint textw /* texth = ICON_SIZE */; + gint iconx, icony; + gint list_mode_textx, list_mode_texty; RrAppearance *text; - /* find the dimensions of the icon inside it */ - innerx = l; - innery = t + i * HILITE_SIZE; + /* find the coordinates for the icon */ + iconx = icons_center_x + l + (col * HILITE_SIZE); + icony = t + (row * MAX(texth, HILITE_SIZE)) + + MAX(texth - HILITE_SIZE, 0) / 2; /* find the dimensions of the text box */ - textx = innerx + HILITE_SIZE + TEXT_BORDER; - texty = innery + HILITE_OFFSET; - textw = w - /* left edge */ - innerx - HILITE_SIZE - TEXT_BORDER - /* right edge */ - OUTSIDE_BORDER - TEXT_BORDER; + list_mode_textx = iconx + HILITE_SIZE + TEXT_BORDER; + list_mode_texty = icony + HILITE_OFFSET; +// textw = w +// /* left edge */ - innerx - HILITE_SIZE - TEXT_BORDER +// /* right edge */ - OUTSIDE_BORDER - TEXT_BORDER; - /* move the icon */ + /* position the icon */ XMoveResizeWindow(obt_display, target->iconwin, - innerx, innery, HILITE_SIZE, HILITE_SIZE); + iconx, icony, HILITE_SIZE, HILITE_SIZE); - /* move the text */ - XMoveResizeWindow(obt_display, target->textwin, - textx, texty, - textw, ICON_SIZE); + /* position the text */ + if (mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) + XMoveResizeWindow(obt_display, target->textwin, + list_mode_textx, list_mode_texty, + textw, texth); /* get the icon from the client */ icon = client_icon(target->client, ICON_SIZE, ICON_SIZE); @@ -391,16 +476,26 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) RR_TEXTURE_RGBA : RR_TEXTURE_NONE; /* draw the icon */ - p->a_icon->surface.parentx = innerx; - p->a_icon->surface.parenty = innery; + p->a_icon->surface.parentx = iconx; + p->a_icon->surface.parenty = icony; RrPaint(p->a_icon, target->iconwin, HILITE_SIZE, HILITE_SIZE); /* draw the text */ - text = (target == newtarget) ? p->a_hilite_text : p->a_text; - text->texture[0].data.text.string = target->text; - text->surface.parentx = textx; - text->surface.parenty = texty; - RrPaint(text, target->textwin, textw, ICON_SIZE); + if (mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST || target == newtarget) + { + text = (target == newtarget) ? p->a_hilite_text : p->a_text; + text->texture[0].data.text.string = target->text; + text->surface.parentx = + mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? + icon_mode_textx : list_mode_textx; + text->surface.parenty = + mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? + icon_mode_texty : list_mode_texty; + RrPaint(text, + (mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? + p->icon_mode_text : target->textwin), + textw, texth); + } } } @@ -411,17 +506,23 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) void focus_cycle_popup_show(ObClient *c, gboolean iconic_windows, gboolean all_desktops, gboolean dock_windows, - gboolean desktop_windows) + gboolean desktop_windows, + ObFocusCyclePopupMode mode) { g_assert(c != NULL); + if (mode == OB_FOCUS_CYCLE_POPUP_MODE_NONE) { + focus_cycle_popup_hide(); + return; + } + /* do this stuff only when the dialog is first showing */ if (!popup.mapped) popup_setup(&popup, TRUE, iconic_windows, all_desktops, dock_windows, desktop_windows); g_assert(popup.targets != NULL); - popup_render(&popup, c); + popup_render(&popup, c, mode); if (!popup.mapped) { /* show the dialog */ diff --git a/openbox/focus_cycle_popup.h b/openbox/focus_cycle_popup.h index ded39e20..b940583b 100644 --- a/openbox/focus_cycle_popup.h +++ b/openbox/focus_cycle_popup.h @@ -24,12 +24,19 @@ struct _ObClient; #include +typedef enum { + OB_FOCUS_CYCLE_POPUP_MODE_NONE, + OB_FOCUS_CYCLE_POPUP_MODE_ICONS, + OB_FOCUS_CYCLE_POPUP_MODE_LIST +} ObFocusCyclePopupMode; + void focus_cycle_popup_startup(gboolean reconfig); void focus_cycle_popup_shutdown(gboolean reconfig); void focus_cycle_popup_show(struct _ObClient *c, gboolean iconic_windows, gboolean all_desktops, gboolean dock_windows, - gboolean desktop_windows); + gboolean desktop_windows, + ObFocusCyclePopupMode mode); void focus_cycle_popup_hide(); void focus_cycle_popup_single_show(struct _ObClient *c, -- cgit v1.2.3 From 88d0c56be0eab0860987c7026a07a4b9c6e8f386 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 3 Feb 2008 00:16:09 -0500 Subject: fix some uses of ICON_SIZE where it should be HILITE_SIZE now, from the old icon-mode focus cycle popup --- openbox/focus_cycle_popup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 9f3fa3e8..19d3d0b8 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -343,8 +343,8 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c, if (mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) { /* how many icons will fit in that row? make the width fit that */ w -= l + r; - icons_per_row = (w + ICON_SIZE - 1) / ICON_SIZE; - w = icons_per_row * ICON_SIZE + l + r; + icons_per_row = (w + HILITE_SIZE - 1) / HILITE_SIZE; + w = icons_per_row * HILITE_SIZE + l + r; /* how many rows do we need? */ icon_rows = (p->n_targets-1) / icons_per_row + 1; @@ -372,7 +372,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c, /* center the icons if there is less than one row */ if (icon_rows == 1) - icons_center_x = (w - p->n_targets * ICON_SIZE) / 2; + icons_center_x = (w - p->n_targets * HILITE_SIZE) / 2; else icons_center_x = 0; -- cgit v1.2.3 From 9b447a2d2837a6dab0380bc767644f8fe5083aa9 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 3 Feb 2008 00:24:14 -0500 Subject: remove commented code --- openbox/focus_cycle_popup.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 19d3d0b8..42c3fed6 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -445,9 +445,6 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c, /* find the dimensions of the text box */ list_mode_textx = iconx + HILITE_SIZE + TEXT_BORDER; list_mode_texty = icony + HILITE_OFFSET; -// textw = w -// /* left edge */ - innerx - HILITE_SIZE - TEXT_BORDER -// /* right edge */ - OUTSIDE_BORDER - TEXT_BORDER; /* position the icon */ XMoveResizeWindow(obt_display, target->iconwin, -- cgit v1.2.3 From 04e1084d588a7c2aedcaef53d927c33afec17437 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 3 Feb 2008 00:39:19 -0500 Subject: map the appropriate text-containing windows, and unmap the ones that are not being used based on the focus popup cycle mode --- openbox/focus_cycle_popup.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 42c3fed6..42fe29c9 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; @@ -398,10 +396,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 +453,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); -- cgit v1.2.3 From ad3bf0cea4d471ccb821227f1df485a8c639fca0 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 3 Feb 2008 00:44:10 -0500 Subject: limit the alttab list to 80% of the screen height --- openbox/focus_cycle_popup.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 42fe29c9..d5b707ed 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -338,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; @@ -351,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 -- cgit v1.2.3 From 892107d3ba483fe9356d66c5b62496d7fa332020 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 3 Feb 2008 00:51:55 -0500 Subject: center the text vertically in list alttab box mode --- openbox/focus_cycle_popup.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index d5b707ed..c862933c 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -339,8 +339,11 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c, 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; + texth = RrMinHeight(p->a_hilite_text); + if (mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) + texth = MAX(MAX(texth, RrMinHeight(p->a_text)), ICON_SIZE); + else + texth += TEXT_BORDER * 2; if (mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) { /* how many icons will fit in that row? make the width fit that */ -- cgit v1.2.3 From 25d54d2ddab10e233a3300e2ebba13fa5f3f401f Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 3 Feb 2008 01:00:42 -0500 Subject: fix the alttab popup mode when it shows on screen, so it won't change mid-cycling --- openbox/focus_cycle_popup.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index c862933c..c69c1d27 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -78,6 +78,7 @@ struct _ObFocusCyclePopup RrAppearance *a_icon; gboolean mapped; + ObFocusCyclePopupMode mode; }; /*! This popup shows all possible windows */ @@ -93,8 +94,7 @@ static void popup_setup (ObFocusCyclePopup *p, gboolean dock_windows, gboolean desktop_windows); static void popup_render (ObFocusCyclePopup *p, - const ObClient *c, - ObFocusCyclePopupMode mode); + const ObClient *c); static Window create_window(Window parent, guint bwidth, gulong mask, XSetWindowAttributes *attr) @@ -293,8 +293,7 @@ static gchar *popup_get_name(ObClient *c) return ret; } -static void popup_render(ObFocusCyclePopup *p, const ObClient *c, - ObFocusCyclePopupMode mode) +static void popup_render(ObFocusCyclePopup *p, const ObClient *c) { gint ml, mt, mr, mb; gint l, t, r, b; @@ -316,8 +315,8 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c, /* vars for list mode */ gint list_mode_icon_column_w = HILITE_SIZE + OUTSIDE_BORDER; - g_assert(mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS || - mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST); + g_assert(p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS || + p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST); screen_area = screen_physical_area_active(); @@ -332,7 +331,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c, /* get the width from the text and keep it within limits */ w = l + r + p->maxtextw; - if (mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) + if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) /* when in list mode, there are icons down the side */ w += list_mode_icon_column_w; w = MIN(w, MAX(screen_area->width/3, POPUP_WIDTH)); /* max width */ @@ -340,12 +339,12 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c, /* get the text height */ texth = RrMinHeight(p->a_hilite_text); - if (mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) + if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) texth = MAX(MAX(texth, RrMinHeight(p->a_text)), ICON_SIZE); else texth += TEXT_BORDER * 2; - if (mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) { + if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) { /* how many icons will fit in that row? make the width fit that */ w -= l + r; icons_per_row = (w + HILITE_SIZE - 1) / HILITE_SIZE; @@ -367,14 +366,14 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c, /* get the text width */ textw = w - l - r; - if (mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) + if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) /* leave space on the side for the icons */ textw -= list_mode_icon_column_w; /* find the height of the dialog */ #warning limit the height and scroll entries somehow h = t + b + (icon_rows * MAX(HILITE_SIZE, texth)); - if (mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) + if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) /* in icon mode the text sits below the icons, so make some space */ h += OUTSIDE_BORDER + texth; @@ -384,7 +383,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c, else icons_center_x = 0; - if (mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) { + if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) { /* get the position of the text */ icon_mode_textx = l; icon_mode_texty = h - texth - b; @@ -406,7 +405,7 @@ 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 (p->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); @@ -463,7 +462,7 @@ 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 (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) { XMoveResizeWindow(obt_display, target->textwin, list_mode_textx, list_mode_texty, textw, texth); @@ -494,18 +493,19 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c, RrPaint(p->a_icon, target->iconwin, HILITE_SIZE, HILITE_SIZE); /* draw the text */ - if (mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST || target == newtarget) + if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST || + target == newtarget) { text = (target == newtarget) ? p->a_hilite_text : p->a_text; text->texture[0].data.text.string = target->text; text->surface.parentx = - mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? + p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? icon_mode_textx : list_mode_textx; text->surface.parenty = - mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? + p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? icon_mode_texty : list_mode_texty; RrPaint(text, - (mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? + (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? p->icon_mode_text : target->textwin), textw, texth); } @@ -530,12 +530,15 @@ void focus_cycle_popup_show(ObClient *c, gboolean iconic_windows, } /* do this stuff only when the dialog is first showing */ - if (!popup.mapped) - popup_setup(&popup, TRUE, iconic_windows, all_desktops, + if (!popup.mapped) { + popup_setup(&popup, TRUE, iconic_windows, all_desktops, dock_windows, desktop_windows); + /* this is fixed once the dialog is shown */ + popup.mode = mode; + } g_assert(popup.targets != NULL); - popup_render(&popup, c, mode); + popup_render(&popup, c); if (!popup.mapped) { /* show the dialog */ -- cgit v1.2.3 From b097f84dfdf4e2548dba96aa63325cb05b5244a1 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 4 Feb 2008 23:25:26 -0500 Subject: scroll the alttab box in list mode --- openbox/focus_cycle_popup.c | 144 ++++++++++++++++++++++++++++++-------------- 1 file changed, 99 insertions(+), 45 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index c69c1d27..c5807c3a 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -44,6 +44,9 @@ #define OUTSIDE_BORDER 3 /* Margin area around the text */ #define TEXT_BORDER 2 +/* Scroll the list-mode list when the cursor gets within this many rows of the + top or bottom */ +#define SCROLL_MARGIN 4 typedef struct _ObFocusCyclePopup ObFocusCyclePopup; typedef struct _ObFocusCyclePopupTarget ObFocusCyclePopupTarget; @@ -72,6 +75,9 @@ struct _ObFocusCyclePopup gint maxtextw; + /* How are the list is scrolled, in scroll mode */ + gint scroll; + RrAppearance *a_bg; RrAppearance *a_text; RrAppearance *a_hilite_text; @@ -254,8 +260,6 @@ static void popup_setup(ObFocusCyclePopup *p, gboolean create_targets, t->iconwin = create_window(p->bg, 0, 0, NULL); t->textwin = create_window(p->bg, 0, 0, NULL); - XMapWindow(obt_display, t->iconwin); - p->targets = g_list_prepend(p->targets, t); ++n; } @@ -306,6 +310,8 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) gint icons_per_row; gint icon_rows; gint textw, texth; + gint selected_pos; + gint last_scroll; /* vars for icon mode */ gint icon_mode_textx; @@ -371,7 +377,6 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) textw -= list_mode_icon_column_w; /* find the height of the dialog */ -#warning limit the height and scroll entries somehow h = t + b + (icon_rows * MAX(HILITE_SIZE, texth)); if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) /* in icon mode the text sits below the icons, so make some space */ @@ -413,6 +418,9 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) } else XUnmapWindow(obt_display, popup.icon_mode_text); + + /* reset the scrolling when the dialog is first shown */ + p->scroll = 0; } /* find the focused target */ @@ -425,6 +433,25 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) break; } } + selected_pos = i; + + /* scroll the list if needed */ + last_scroll = p->scroll; + if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) { + const gint top = p->scroll + SCROLL_MARGIN; + const gint bottom = p->scroll + icon_rows - SCROLL_MARGIN; + const gint min_scroll = 0; + const gint max_scroll = p->n_targets - icon_rows; + + if (top - selected_pos >= 0) { + p->scroll -= top - selected_pos + 1; + p->scroll = MAX(p->scroll, min_scroll); + } + else if (selected_pos - bottom >= 0) { + p->scroll += selected_pos - bottom + 1; + p->scroll = MIN(p->scroll, max_scroll); + } + } g_assert(newtarget != NULL); @@ -440,9 +467,12 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* have to redraw the targetted icon and last targetted icon * to update the hilite */ - if (!p->mapped || newtarget == target || p->last_target == target) { - const gint row = i / icons_per_row; /* starting from 0 */ - const gint col = i % icons_per_row; /* starting from 0 */ + if (!p->mapped || newtarget == target || p->last_target == target || + last_scroll != p->scroll) + { + /* row and column start from 0 */ + const gint row = i / icons_per_row - p->scroll; + const gint col = i % icons_per_row; const ObClientIcon *icon; gint iconx, icony; gint list_mode_textx, list_mode_texty; @@ -462,52 +492,74 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) iconx, icony, HILITE_SIZE, HILITE_SIZE); /* position the text */ - if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) { + if (p->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); + + /* show/hide the right windows */ + if (row >= 0 && row < icon_rows) { + XMapWindow(obt_display, target->iconwin); + if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) + XMapWindow(obt_display, target->textwin); + else + XUnmapWindow(obt_display, target->textwin); } - else + else { XUnmapWindow(obt_display, target->textwin); + if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) + XUnmapWindow(obt_display, target->iconwin); + else + XMapWindow(obt_display, target->iconwin); + } - /* get the icon from the client */ - icon = client_icon(target->client, ICON_SIZE, ICON_SIZE); - p->a_icon->texture[0].data.rgba.width = icon->width; - p->a_icon->texture[0].data.rgba.height = icon->height; - p->a_icon->texture[0].data.rgba.twidth = ICON_SIZE; - p->a_icon->texture[0].data.rgba.theight = ICON_SIZE; - p->a_icon->texture[0].data.rgba.tx = HILITE_OFFSET; - p->a_icon->texture[0].data.rgba.ty = HILITE_OFFSET; - p->a_icon->texture[0].data.rgba.alpha = - target->client->iconic ? OB_ICONIC_ALPHA : 0xff; - p->a_icon->texture[0].data.rgba.data = icon->data; - - /* Draw the hilite? */ - p->a_icon->texture[1].type = (target == newtarget) ? - RR_TEXTURE_RGBA : RR_TEXTURE_NONE; - - /* draw the icon */ - p->a_icon->surface.parentx = iconx; - p->a_icon->surface.parenty = icony; - RrPaint(p->a_icon, target->iconwin, HILITE_SIZE, HILITE_SIZE); - - /* draw the text */ - if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST || - target == newtarget) + /* only draw if we have to */ + if (!p->mapped || + newtarget == target || p->last_target == target || + /* wasn't visible before... */ + ((row + p->scroll < last_scroll || + row + p->scroll >= last_scroll + icon_rows) && + /* ...and is visible now */ + (row >= 0 && row < icon_rows))) { - text = (target == newtarget) ? p->a_hilite_text : p->a_text; - text->texture[0].data.text.string = target->text; - text->surface.parentx = - p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? - icon_mode_textx : list_mode_textx; - text->surface.parenty = - p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? - icon_mode_texty : list_mode_texty; - RrPaint(text, - (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? - p->icon_mode_text : target->textwin), - textw, texth); + /* get the icon from the client */ + icon = client_icon(target->client, ICON_SIZE, ICON_SIZE); + p->a_icon->texture[0].data.rgba.width = icon->width; + p->a_icon->texture[0].data.rgba.height = icon->height; + p->a_icon->texture[0].data.rgba.twidth = ICON_SIZE; + p->a_icon->texture[0].data.rgba.theight = ICON_SIZE; + p->a_icon->texture[0].data.rgba.tx = HILITE_OFFSET; + p->a_icon->texture[0].data.rgba.ty = HILITE_OFFSET; + p->a_icon->texture[0].data.rgba.alpha = + target->client->iconic ? OB_ICONIC_ALPHA : 0xff; + p->a_icon->texture[0].data.rgba.data = icon->data; + + /* Draw the hilite? */ + p->a_icon->texture[1].type = (target == newtarget) ? + RR_TEXTURE_RGBA : RR_TEXTURE_NONE; + + /* draw the icon */ + p->a_icon->surface.parentx = iconx; + p->a_icon->surface.parenty = icony; + RrPaint(p->a_icon, target->iconwin, HILITE_SIZE, HILITE_SIZE); + + /* draw the text */ + if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST || + target == newtarget) + { + text = (target == newtarget) ? p->a_hilite_text : p->a_text; + text->texture[0].data.text.string = target->text; + text->surface.parentx = + p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? + icon_mode_textx : list_mode_textx; + text->surface.parenty = + p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? + icon_mode_texty : list_mode_texty; + RrPaint(text, + (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? + p->icon_mode_text : target->textwin), + textw, texth); + } } } } @@ -515,6 +567,8 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) p->last_target = newtarget; g_free(screen_area); + + XFlush(obt_display); } void focus_cycle_popup_show(ObClient *c, gboolean iconic_windows, -- cgit v1.2.3 From 0369732c35b42b272eb66da4a54b37f253037049 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 5 Feb 2008 00:11:38 -0500 Subject: when scrolling, all the items need to be redrawn to make parentrelative work --- openbox/focus_cycle_popup.c | 82 ++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 46 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index c5807c3a..e418d96f 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -513,53 +513,43 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) XMapWindow(obt_display, target->iconwin); } - /* only draw if we have to */ - if (!p->mapped || - newtarget == target || p->last_target == target || - /* wasn't visible before... */ - ((row + p->scroll < last_scroll || - row + p->scroll >= last_scroll + icon_rows) && - /* ...and is visible now */ - (row >= 0 && row < icon_rows))) + /* get the icon from the client */ + icon = client_icon(target->client, ICON_SIZE, ICON_SIZE); + p->a_icon->texture[0].data.rgba.width = icon->width; + p->a_icon->texture[0].data.rgba.height = icon->height; + p->a_icon->texture[0].data.rgba.twidth = ICON_SIZE; + p->a_icon->texture[0].data.rgba.theight = ICON_SIZE; + p->a_icon->texture[0].data.rgba.tx = HILITE_OFFSET; + p->a_icon->texture[0].data.rgba.ty = HILITE_OFFSET; + p->a_icon->texture[0].data.rgba.alpha = + target->client->iconic ? OB_ICONIC_ALPHA : 0xff; + p->a_icon->texture[0].data.rgba.data = icon->data; + + /* Draw the hilite? */ + p->a_icon->texture[1].type = (target == newtarget) ? + RR_TEXTURE_RGBA : RR_TEXTURE_NONE; + + /* draw the icon */ + p->a_icon->surface.parentx = iconx; + p->a_icon->surface.parenty = icony; + RrPaint(p->a_icon, target->iconwin, HILITE_SIZE, HILITE_SIZE); + + /* draw the text */ + if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST || + target == newtarget) { - /* get the icon from the client */ - icon = client_icon(target->client, ICON_SIZE, ICON_SIZE); - p->a_icon->texture[0].data.rgba.width = icon->width; - p->a_icon->texture[0].data.rgba.height = icon->height; - p->a_icon->texture[0].data.rgba.twidth = ICON_SIZE; - p->a_icon->texture[0].data.rgba.theight = ICON_SIZE; - p->a_icon->texture[0].data.rgba.tx = HILITE_OFFSET; - p->a_icon->texture[0].data.rgba.ty = HILITE_OFFSET; - p->a_icon->texture[0].data.rgba.alpha = - target->client->iconic ? OB_ICONIC_ALPHA : 0xff; - p->a_icon->texture[0].data.rgba.data = icon->data; - - /* Draw the hilite? */ - p->a_icon->texture[1].type = (target == newtarget) ? - RR_TEXTURE_RGBA : RR_TEXTURE_NONE; - - /* draw the icon */ - p->a_icon->surface.parentx = iconx; - p->a_icon->surface.parenty = icony; - RrPaint(p->a_icon, target->iconwin, HILITE_SIZE, HILITE_SIZE); - - /* draw the text */ - if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST || - target == newtarget) - { - text = (target == newtarget) ? p->a_hilite_text : p->a_text; - text->texture[0].data.text.string = target->text; - text->surface.parentx = - p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? - icon_mode_textx : list_mode_textx; - text->surface.parenty = - p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? - icon_mode_texty : list_mode_texty; - RrPaint(text, - (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? - p->icon_mode_text : target->textwin), - textw, texth); - } + text = (target == newtarget) ? p->a_hilite_text : p->a_text; + text->texture[0].data.text.string = target->text; + text->surface.parentx = + p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? + icon_mode_textx : list_mode_textx; + text->surface.parenty = + p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? + icon_mode_texty : list_mode_texty; + RrPaint(text, + (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS ? + p->icon_mode_text : target->textwin), + textw, texth); } } } -- cgit v1.2.3 From 92bbd733fa1a8fbc5eebf207932bf26be0251894 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 5 Feb 2008 00:16:48 -0500 Subject: make sure the alttab list-mode has at least 1 row --- openbox/focus_cycle_popup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index e418d96f..1d37ae9c 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -368,6 +368,8 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) (4*screen_area->height/5) /* 80% of the screen */ / MAX(HILITE_SIZE, texth)); /* height of each row */ + /* but make sure there is always one */ + icon_rows = MAX(icon_rows, 1); } /* get the text width */ -- cgit v1.2.3 From bc13099405a7aecc0eb8b6688b2b3a384f4dfcac Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 6 Feb 2008 01:32:12 -0500 Subject: show a small arrow on the top/bottom of the alttab list box when there are more windows that are not visible in that direction --- openbox/focus_cycle_popup.c | 78 +++++++++++++++++++++++++++++++++++++++++++-- render/theme.c | 12 +++++++ render/theme.h | 3 ++ 3 files changed, 91 insertions(+), 2 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 1d37ae9c..24cbfb50 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -68,6 +68,9 @@ struct _ObFocusCyclePopup /* This is used when the popup is in icon mode */ Window icon_mode_text; + Window list_mode_up; + Window list_mode_down; + GList *targets; gint n_targets; @@ -82,6 +85,7 @@ struct _ObFocusCyclePopup RrAppearance *a_text; RrAppearance *a_hilite_text; RrAppearance *a_icon; + RrAppearance *a_arrow; gboolean mapped; ObFocusCyclePopupMode mode; @@ -122,6 +126,7 @@ void focus_cycle_popup_startup(gboolean reconfig) popup.a_hilite_text = RrAppearanceCopy(ob_rr_theme->osd_hilite_label); popup.a_text = RrAppearanceCopy(ob_rr_theme->a_unfocused_label); popup.a_icon = RrAppearanceCopy(ob_rr_theme->a_clear); + popup.a_arrow = RrAppearanceCopy(ob_rr_theme->a_clear_tex); popup.a_hilite_text->surface.parent = popup.a_bg; popup.a_text->surface.parent = popup.a_bg; @@ -136,6 +141,10 @@ void focus_cycle_popup_startup(gboolean reconfig) popup.a_icon->texture[0].type = RR_TEXTURE_RGBA; + popup.a_arrow->texture[0].type = RR_TEXTURE_MASK; + popup.a_arrow->texture[0].data.mask.color = + ob_rr_theme->osd_color; + attrib.override_redirect = True; attrib.border_pixel=RrColorPixel(ob_rr_theme->osd_border_color); popup.bg = create_window(obt_root(ob_screen), ob_rr_theme->obwidth, @@ -144,6 +153,10 @@ 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); + /* create the windows for the up and down arrows */ + popup.list_mode_up = create_window(popup.bg, 0, 0, NULL); + popup.list_mode_down = create_window(popup.bg, 0, 0, NULL); + popup.targets = NULL; popup.n_targets = 0; popup.last_target = NULL; @@ -210,9 +223,12 @@ void focus_cycle_popup_shutdown(gboolean reconfig) g_free(popup.a_icon->texture[1].data.rgba.data); popup.a_icon->texture[1].data.rgba.data = NULL; + XDestroyWindow(obt_display, popup.list_mode_up); + XDestroyWindow(obt_display, popup.list_mode_down); XDestroyWindow(obt_display, popup.icon_mode_text); XDestroyWindow(obt_display, popup.bg); + RrAppearanceFree(popup.a_arrow); RrAppearanceFree(popup.a_icon); RrAppearanceFree(popup.a_hilite_text); RrAppearanceFree(popup.a_text); @@ -320,6 +336,8 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* vars for list mode */ gint list_mode_icon_column_w = HILITE_SIZE + OUTSIDE_BORDER; + gint up_arrow_x, down_arrow_x; + gint up_arrow_y, down_arrow_y; g_assert(p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS || p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST); @@ -383,6 +401,10 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) /* in icon mode the text sits below the icons, so make some space */ h += OUTSIDE_BORDER + texth; + else + h += ob_rr_theme->up_arrow_mask->height + OUTSIDE_BORDER + + ob_rr_theme->down_arrow_mask->height + OUTSIDE_BORDER; + /* center the icons if there is less than one row */ if (icon_rows == 1) @@ -418,9 +440,27 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) icon_mode_textx, icon_mode_texty, textw, texth); XMapWindow(obt_display, popup.icon_mode_text); } - else + else { XUnmapWindow(obt_display, popup.icon_mode_text); + up_arrow_x = (w - ob_rr_theme->up_arrow_mask->width) / 2; + up_arrow_y = t; + + down_arrow_x = (w - ob_rr_theme->down_arrow_mask->width) / 2; + down_arrow_y = h - b - ob_rr_theme->down_arrow_mask->height; + + /* position the arrows */ + XMoveResizeWindow(obt_display, p->list_mode_up, + up_arrow_x, up_arrow_y, + ob_rr_theme->up_arrow_mask->width, + ob_rr_theme->up_arrow_mask->height); + XMoveResizeWindow(obt_display, p->list_mode_down, + down_arrow_x, down_arrow_y, + ob_rr_theme->down_arrow_mask->width, + ob_rr_theme->down_arrow_mask->height); + } + + /* reset the scrolling when the dialog is first shown */ p->scroll = 0; } @@ -463,6 +503,39 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) if (!p->mapped) RrPaint(p->a_bg, p->bg, w, h); + /* draw the scroll arrows */ + if (!p->mapped && p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) { + p->a_arrow->texture[0].data.mask.mask = + ob_rr_theme->up_arrow_mask; + p->a_arrow->surface.parent = p->a_bg; + p->a_arrow->surface.parentx = up_arrow_x; + p->a_arrow->surface.parenty = up_arrow_y; + RrPaint(p->a_arrow, p->list_mode_up, + ob_rr_theme->up_arrow_mask->width, + ob_rr_theme->up_arrow_mask->height); + + p->a_arrow->texture[0].data.mask.mask = + ob_rr_theme->down_arrow_mask; + p->a_arrow->surface.parent = p->a_bg; + p->a_arrow->surface.parentx = down_arrow_x; + p->a_arrow->surface.parenty = down_arrow_y; + RrPaint(p->a_arrow, p->list_mode_down, + ob_rr_theme->down_arrow_mask->width, + ob_rr_theme->down_arrow_mask->height); + } + + /* show the scroll arrows when appropriate */ + if (p->scroll && p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) + XMapWindow(obt_display, p->list_mode_up); + else + XUnmapWindow(obt_display, p->list_mode_up); + + if (p->scroll < p->n_targets - icon_rows && + p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) + XMapWindow(obt_display, p->list_mode_down); + else + XUnmapWindow(obt_display, p->list_mode_down); + /* draw the icons and text */ for (i = 0, it = p->targets; it; ++i, it = g_list_next(it)) { const ObFocusCyclePopupTarget *target = it->data; @@ -482,7 +555,8 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* find the coordinates for the icon */ iconx = icons_center_x + l + (col * HILITE_SIZE); - icony = t + (row * MAX(texth, HILITE_SIZE)) + icony = t + ob_rr_theme->up_arrow_mask->height + OUTSIDE_BORDER + + (row * MAX(texth, HILITE_SIZE)) + MAX(texth - HILITE_SIZE, 0) / 2; /* find the dimensions of the text box */ diff --git a/render/theme.c b/render/theme.c index d644a92f..6d87cafb 100644 --- a/render/theme.c +++ b/render/theme.c @@ -538,6 +538,16 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name, theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data); } + /* up and down arrows */ + { + guchar data[] = { 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00 }; + theme->down_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data); + } + { + guchar data[] = { 0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00 }; + theme->up_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data); + } + /* setup the default window icon */ theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH, OB_DEFAULT_ICON_HEIGHT, @@ -1450,6 +1460,8 @@ void RrThemeFree(RrTheme *theme) RrPixmapMaskFree(theme->close_hover_mask); RrPixmapMaskFree(theme->close_pressed_mask); RrPixmapMaskFree(theme->menu_bullet_mask); + RrPixmapMaskFree(theme->down_arrow_mask); + RrPixmapMaskFree(theme->up_arrow_mask); RrFontClose(theme->win_font_focused); RrFontClose(theme->win_font_unfocused); diff --git a/render/theme.h b/render/theme.h index 2c35284f..9f51fabd 100644 --- a/render/theme.h +++ b/render/theme.h @@ -144,6 +144,9 @@ struct _RrTheme { RrPixmapMask *menu_toggle_mask; /* menu boolean */ #endif + RrPixmapMask *down_arrow_mask; + RrPixmapMask *up_arrow_mask; + /* global appearances */ RrAppearance *a_disabled_focused_max; RrAppearance *a_disabled_unfocused_max; -- cgit v1.2.3 From 930d7a33ad5da28884d8824cccb18a9de0eb2db3 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Wed, 6 Feb 2008 07:45:07 +0100 Subject: style --- openbox/focus_cycle_popup.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 24cbfb50..77a6d215 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -189,8 +189,7 @@ void focus_cycle_popup_startup(gboolean reconfig) { /* the border of the target */ a = 0x88; - } - else { + } else { /* the background of the target */ a = 0x22; } @@ -266,9 +265,9 @@ static void popup_setup(ObFocusCyclePopup *p, gboolean create_targets, p->a_text->texture[0].data.text.string = text; maxwidth = MAX(maxwidth, RrMinWidth(p->a_text)); - if (!create_targets) + if (!create_targets) { g_free(text); - else { + } else { ObFocusCyclePopupTarget *t = g_new(ObFocusCyclePopupTarget, 1); t->client = ft; @@ -376,9 +375,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* how many rows do we need? */ icon_rows = (p->n_targets-1) / icons_per_row + 1; - - } - else { + } else { /* in list mode, there is one column of icons.. */ icons_per_row = 1; /* maximum is 80% of the screen height */ @@ -439,8 +436,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) XMoveResizeWindow(obt_display, p->icon_mode_text, icon_mode_textx, icon_mode_texty, textw, texth); XMapWindow(obt_display, popup.icon_mode_text); - } - else { + } else { XUnmapWindow(obt_display, popup.icon_mode_text); up_arrow_x = (w - ob_rr_theme->up_arrow_mask->width) / 2; @@ -488,8 +484,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) if (top - selected_pos >= 0) { p->scroll -= top - selected_pos + 1; p->scroll = MAX(p->scroll, min_scroll); - } - else if (selected_pos - bottom >= 0) { + } else if (selected_pos - bottom >= 0) { p->scroll += selected_pos - bottom + 1; p->scroll = MIN(p->scroll, max_scroll); } @@ -580,8 +575,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) XMapWindow(obt_display, target->textwin); else XUnmapWindow(obt_display, target->textwin); - } - else { + } else { XUnmapWindow(obt_display, target->textwin); if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) XUnmapWindow(obt_display, target->iconwin); -- cgit v1.2.3 From a066e6193950ca2d0eb53ae127cb42f453c01dbf Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Wed, 6 Feb 2008 08:05:34 +0100 Subject: Don't show extra space for arrows when not needed. --- openbox/focus_cycle_popup.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 77a6d215..2a0b24dc 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -337,6 +337,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) gint list_mode_icon_column_w = HILITE_SIZE + OUTSIDE_BORDER; gint up_arrow_x, down_arrow_x; gint up_arrow_y, down_arrow_y; + gboolean showing_arrows = FALSE; g_assert(p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS || p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST); @@ -393,16 +394,34 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* leave space on the side for the icons */ textw -= list_mode_icon_column_w; + if (!p->mapped) + /* reset the scrolling when the dialog is first shown */ + p->scroll = 0; + + /* show the scroll arrows when appropriate */ + if (p->scroll && p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) { + XMapWindow(obt_display, p->list_mode_up); + showing_arrows = TRUE; + } else + XUnmapWindow(obt_display, p->list_mode_up); + + if (p->scroll < p->n_targets - icon_rows && + p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) + { + XMapWindow(obt_display, p->list_mode_down); + showing_arrows = TRUE; + } else + XUnmapWindow(obt_display, p->list_mode_down); + /* find the height of the dialog */ h = t + b + (icon_rows * MAX(HILITE_SIZE, texth)); if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) /* in icon mode the text sits below the icons, so make some space */ h += OUTSIDE_BORDER + texth; - else + else if (showing_arrows) h += ob_rr_theme->up_arrow_mask->height + OUTSIDE_BORDER + ob_rr_theme->down_arrow_mask->height + OUTSIDE_BORDER; - /* center the icons if there is less than one row */ if (icon_rows == 1) icons_center_x = (w - p->n_targets * HILITE_SIZE) / 2; @@ -455,10 +474,6 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) ob_rr_theme->down_arrow_mask->width, ob_rr_theme->down_arrow_mask->height); } - - - /* reset the scrolling when the dialog is first shown */ - p->scroll = 0; } /* find the focused target */ @@ -519,18 +534,6 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) ob_rr_theme->down_arrow_mask->height); } - /* show the scroll arrows when appropriate */ - if (p->scroll && p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) - XMapWindow(obt_display, p->list_mode_up); - else - XUnmapWindow(obt_display, p->list_mode_up); - - if (p->scroll < p->n_targets - icon_rows && - p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) - XMapWindow(obt_display, p->list_mode_down); - else - XUnmapWindow(obt_display, p->list_mode_down); - /* draw the icons and text */ for (i = 0, it = p->targets; it; ++i, it = g_list_next(it)) { const ObFocusCyclePopupTarget *target = it->data; @@ -550,7 +553,9 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* find the coordinates for the icon */ iconx = icons_center_x + l + (col * HILITE_SIZE); - icony = t + ob_rr_theme->up_arrow_mask->height + OUTSIDE_BORDER + icony = t + (showing_arrows ? ob_rr_theme->up_arrow_mask->height + + OUTSIDE_BORDER + : 0) + (row * MAX(texth, HILITE_SIZE)) + MAX(texth - HILITE_SIZE, 0) / 2; -- cgit v1.2.3 From e9eac7ce50a214e3cc14e737d0e109612eb32080 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 6 Feb 2008 09:31:03 -0500 Subject: make the listmode alttab the default --- openbox/actions/cyclewindows.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openbox/actions/cyclewindows.c b/openbox/actions/cyclewindows.c index b013b66b..44d87cf6 100644 --- a/openbox/actions/cyclewindows.c +++ b/openbox/actions/cyclewindows.c @@ -48,15 +48,15 @@ static gpointer setup_func(xmlNodePtr node) o = g_new0(Options, 1); o->bar = TRUE; - o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_ICONS; + o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_LIST; if ((n = obt_parse_find_node(node, "linear"))) o->linear = obt_parse_node_bool(n); if ((n = obt_parse_find_node(node, "dialog"))) { if (obt_parse_node_contains(n, "none")) o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_NONE; - else if (obt_parse_node_contains(n, "list")) - o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_LIST; + else if (obt_parse_node_contains(n, "icons")) + o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_ICONS; } if ((n = obt_parse_find_node(node, "bar"))) o->bar = obt_parse_node_bool(n); -- cgit v1.2.3 From d81339c9cf6592fc86dc05428ee6e70ac573afe5 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 6 Feb 2008 09:35:28 -0500 Subject: show the arrows in the alttab list box at the right times (they were one step behind) --- openbox/focus_cycle_popup.c | 75 +++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 2a0b24dc..5925feb3 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -398,6 +398,42 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* reset the scrolling when the dialog is first shown */ p->scroll = 0; + /* find the height of the dialog */ + h = t + b + (icon_rows * MAX(HILITE_SIZE, texth)); + if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) + /* in icon mode the text sits below the icons, so make some space */ + h += OUTSIDE_BORDER + texth; + + /* find the focused target */ + newtarget = NULL; + for (i = 0, it = p->targets; it; ++i, it = g_list_next(it)) { + const ObFocusCyclePopupTarget *target = it->data; + if (target->client == c) { + /* save the target */ + newtarget = target; + break; + } + } + selected_pos = i; + g_assert(newtarget != NULL); + + /* scroll the list if needed */ + last_scroll = p->scroll; + if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) { + const gint top = p->scroll + SCROLL_MARGIN; + const gint bottom = p->scroll + icon_rows - SCROLL_MARGIN; + const gint min_scroll = 0; + const gint max_scroll = p->n_targets - icon_rows; + + if (top - selected_pos >= 0) { + p->scroll -= top - selected_pos + 1; + p->scroll = MAX(p->scroll, min_scroll); + } else if (selected_pos - bottom >= 0) { + p->scroll += selected_pos - bottom + 1; + p->scroll = MIN(p->scroll, max_scroll); + } + } + /* show the scroll arrows when appropriate */ if (p->scroll && p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) { XMapWindow(obt_display, p->list_mode_up); @@ -413,12 +449,8 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) } else XUnmapWindow(obt_display, p->list_mode_down); - /* find the height of the dialog */ - h = t + b + (icon_rows * MAX(HILITE_SIZE, texth)); - if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS) - /* in icon mode the text sits below the icons, so make some space */ - h += OUTSIDE_BORDER + texth; - else if (showing_arrows) + /* make space for the arrows */ + if (showing_arrows) h += ob_rr_theme->up_arrow_mask->height + OUTSIDE_BORDER + ob_rr_theme->down_arrow_mask->height + OUTSIDE_BORDER; @@ -476,37 +508,6 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) } } - /* find the focused target */ - newtarget = NULL; - for (i = 0, it = p->targets; it; ++i, it = g_list_next(it)) { - const ObFocusCyclePopupTarget *target = it->data; - if (target->client == c) { - /* save the target */ - newtarget = target; - break; - } - } - selected_pos = i; - - /* scroll the list if needed */ - last_scroll = p->scroll; - if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_LIST) { - const gint top = p->scroll + SCROLL_MARGIN; - const gint bottom = p->scroll + icon_rows - SCROLL_MARGIN; - const gint min_scroll = 0; - const gint max_scroll = p->n_targets - icon_rows; - - if (top - selected_pos >= 0) { - p->scroll -= top - selected_pos + 1; - p->scroll = MAX(p->scroll, min_scroll); - } else if (selected_pos - bottom >= 0) { - p->scroll += selected_pos - bottom + 1; - p->scroll = MIN(p->scroll, max_scroll); - } - } - - g_assert(newtarget != NULL); - /* * * draw everything * * */ /* draw the background */ -- cgit v1.2.3 From de85e4f1d96c911c7c9dc7c2a9b514b13b028aec Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 7 Feb 2008 09:10:01 -0500 Subject: put stuff in the right place in alttab list mode when there is only 1 window in it --- openbox/focus_cycle_popup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 5925feb3..ceab3ca1 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -455,7 +455,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) + ob_rr_theme->down_arrow_mask->height + OUTSIDE_BORDER; /* center the icons if there is less than one row */ - if (icon_rows == 1) + if (p->mode == OB_FOCUS_CYCLE_POPUP_MODE_ICONS && icon_rows == 1) icons_center_x = (w - p->n_targets * HILITE_SIZE) / 2; else icons_center_x = 0; -- cgit v1.2.3