X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fpopup.c;h=4a0ae89075fa7c3a81330bb8a0bd6622c3dbe78b;hb=d3d4aa29871111737a4f6985da695c8688a05270;hp=8701e1d8211fdd57978ef58bfd9a4dfe87e96c10;hpb=9a7db27b467944c9ade8fd09a89200b2d2aa6e30;p=chaz%2Fopenbox diff --git a/openbox/popup.c b/openbox/popup.c index 8701e1d8..4a0ae890 100644 --- a/openbox/popup.c +++ b/openbox/popup.c @@ -1,3 +1,22 @@ +/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- + + popup.c for the Openbox window manager + Copyright (c) 2006 Mikael Magnusson + Copyright (c) 2003 Ben Jansens + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + See the COPYING file for a copy of the GNU General Public License. +*/ + #include "popup.h" #include "openbox.h" @@ -87,6 +106,12 @@ void popup_show(ObPopup *self, gchar *text) gint x, y, w, h; gint textw, texth; gint iconw; + Rect *area; /* won't go outside this */ + + area = screen_physical_area(); /* XXX this should work quite + good, someone with xinerama, + and different resolutions on + screens? */ RrMargins(self->a_bg, &l, &t, &r, &b); @@ -152,6 +177,9 @@ void popup_show(ObPopup *self, gchar *text) break; } + x=MAX(MIN(x, area->width-w),0); + y=MAX(MIN(y, area->height-h),0); + /* set the windows/appearances up */ XMoveResizeWindow(ob_display, self->bg, x, y, w, h); @@ -176,7 +204,7 @@ void popup_show(ObPopup *self, gchar *text) if (!self->mapped) { XMapWindow(ob_display, self->bg); - stacking_raise(INTERNAL_AS_WINDOW(self)); + stacking_raise(INTERNAL_AS_WINDOW(self), FALSE); self->mapped = TRUE; } } @@ -230,7 +258,7 @@ void icon_popup_free(ObIconPopup *self) } void icon_popup_show(ObIconPopup *self, - gchar *text, struct _ObClientIcon *icon) + gchar *text, const ObClientIcon *icon) { if (icon) { self->a_icon->texture[0].type = RR_TEXTURE_RGBA; @@ -248,7 +276,6 @@ static void pager_popup_draw_icon(gint px, gint py, gint w, gint h, { ObPagerPopup *self = data; gint x, y; - guint i; guint rown, n; guint horz_inc; guint vert_inc; @@ -263,11 +290,6 @@ static void pager_popup_draw_icon(gint px, gint py, gint w, gint h, / screen_desktop_layout.rows; /* make them squares */ eachw = eachh = MIN(eachw, eachh); - g_message("dif %d %d %d %d ", - (screen_desktop_layout.columns * (eachw + ob_rr_theme->bwidth) + - ob_rr_theme->bwidth), w, - (screen_desktop_layout.rows * (eachh + ob_rr_theme->bwidth) + - ob_rr_theme->bwidth), h); /* center */ px += (w - (screen_desktop_layout.columns * (eachw + ob_rr_theme->bwidth) + @@ -275,71 +297,69 @@ static void pager_popup_draw_icon(gint px, gint py, gint w, gint h, py += (h - (screen_desktop_layout.rows * (eachh + ob_rr_theme->bwidth) + ob_rr_theme->bwidth)) / 2; - g_message("%d %d %d %d", px, py, eachw, eachh); - if (eachw <= 0 || eachh <= 0) return; - switch (screen_desktop_layout.start_corner) { - case OB_CORNER_TOPLEFT: - n = 0; - switch (screen_desktop_layout.orientation) { - case OB_ORIENTATION_HORZ: + switch (screen_desktop_layout.orientation) { + case OB_ORIENTATION_HORZ: + switch (screen_desktop_layout.start_corner) { + case OB_CORNER_TOPLEFT: + n = 0; horz_inc = 1; vert_inc = screen_desktop_layout.columns; break; - case OB_ORIENTATION_VERT: - horz_inc = screen_desktop_layout.rows; - vert_inc = 1; - break; - } - break; - case OB_CORNER_TOPRIGHT: - n = screen_desktop_layout.columns; - switch (screen_desktop_layout.orientation) { - case OB_ORIENTATION_HORZ: + case OB_CORNER_TOPRIGHT: + n = screen_desktop_layout.columns - 1; horz_inc = -1; vert_inc = screen_desktop_layout.columns; break; - case OB_ORIENTATION_VERT: - horz_inc = -screen_desktop_layout.rows; - vert_inc = 1; + case OB_CORNER_BOTTOMRIGHT: + n = screen_desktop_layout.rows * screen_desktop_layout.columns - 1; + horz_inc = -1; + vert_inc = -screen_desktop_layout.columns; break; - } - break; - case OB_CORNER_BOTTOMLEFT: - n = screen_desktop_layout.rows; - switch (screen_desktop_layout.orientation) { - case OB_ORIENTATION_HORZ: + case OB_CORNER_BOTTOMLEFT: + n = (screen_desktop_layout.rows - 1) + * screen_desktop_layout.columns; horz_inc = 1; vert_inc = -screen_desktop_layout.columns; break; - case OB_ORIENTATION_VERT: - horz_inc = screen_desktop_layout.rows; - vert_inc = -1; - break; + default: + g_assert_not_reached(); } break; - case OB_CORNER_BOTTOMRIGHT: - n = MAX(self->desks, - screen_desktop_layout.rows * screen_desktop_layout.columns); - switch (screen_desktop_layout.orientation) { - case OB_ORIENTATION_HORZ: - horz_inc = -1; - vert_inc = -screen_desktop_layout.columns; + case OB_ORIENTATION_VERT: + switch (screen_desktop_layout.start_corner) { + case OB_CORNER_TOPLEFT: + n = 0; + horz_inc = screen_desktop_layout.rows; + vert_inc = 1; break; - case OB_ORIENTATION_VERT: + case OB_CORNER_TOPRIGHT: + n = screen_desktop_layout.rows + * (screen_desktop_layout.columns - 1); + horz_inc = -screen_desktop_layout.rows; + vert_inc = 1; + break; + case OB_CORNER_BOTTOMRIGHT: + n = screen_desktop_layout.rows * screen_desktop_layout.columns - 1; horz_inc = -screen_desktop_layout.rows; vert_inc = -1; break; + case OB_CORNER_BOTTOMLEFT: + n = screen_desktop_layout.rows - 1; + horz_inc = screen_desktop_layout.rows; + vert_inc = -1; + break; + default: + g_assert_not_reached(); } break; + default: + g_assert_not_reached(); } - g_message("%d %d %d", n, horz_inc, vert_inc); - rown = n; - i = 0; for (r = 0, y = 0; r < screen_desktop_layout.rows; ++r, y += eachh + ob_rr_theme->bwidth) { @@ -348,23 +368,17 @@ static void pager_popup_draw_icon(gint px, gint py, gint w, gint h, { RrAppearance *a; - g_message("i %d n %d", i, n); - - if (i >= self->desks) - break; - - a = (n == self->curdesk ? self->hilight : self->unhilight); - - a->surface.parent = self->popup->a_bg; - a->surface.parentx = x + px; - a->surface.parenty = y + py; - XMoveResizeWindow(ob_display, self->wins[i], - x + px, y + py, eachw, eachh); - RrPaint(a, self->wins[i], eachw, eachh); + if (n < self->desks) { + a = (n == self->curdesk ? self->hilight : self->unhilight); + a->surface.parent = self->popup->a_bg; + a->surface.parentx = x + px; + a->surface.parenty = y + py; + XMoveResizeWindow(ob_display, self->wins[n], + x + px, y + py, eachw, eachh); + RrPaint(a, self->wins[n], eachw, eachh); + } n += horz_inc; - - ++i; } n = rown += vert_inc; }