mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-22 05:48:01 +01:00
wmaker: minor fixes for the size of an aperçu
There was a probable bug when reading settings, because the function used was 'getInt' which would try to store the result in a 'char'. As it would be probably easier for user to have the value directly in pixels, the storage is now done in an int so there won't be problem anymore. Changed the behaviour of the constant APERCU_BORDER, which would be assumed to be the size of the border in pixel, but in previous code it was actually the sum of the two border (1 on each side). All maths have been changed to have it as a single border width. Took opportunity to group variable assignation for titleHeight and shortenTitle in a single place, because it is not convenient to have them spread around (one value in the beginning and others later in the code) and using default values prevents some checks that modern compiler can do to help produce safer code. Signed-off-by: Christophe CURIS <christophe.curis@free.fr> Signed-off-by: Carlos R. Mafra <crmafra@gmail.com>
This commit is contained in:
committed by
Carlos R. Mafra
parent
572af55c9f
commit
38d160cb8c
@@ -376,26 +376,33 @@ static void showText(WScreen *scr, int x, int y, int h, int w, const char *text)
|
||||
}
|
||||
#endif /* !SHAPED_BALLOON */
|
||||
|
||||
static void showApercu(WScreen *scr, int x, int y, int height, int width, char *title, Pixmap apercu)
|
||||
static void showApercu(WScreen *scr, int x, int y, const char *title, Pixmap apercu)
|
||||
{
|
||||
Pixmap pixmap;
|
||||
WMFont *font = scr->info_text_font;
|
||||
int titleHeight = 0;
|
||||
char *shortenTitle = title;
|
||||
int width, height;
|
||||
int titleHeight;
|
||||
char *shortenTitle;
|
||||
|
||||
if (scr->balloon->contents)
|
||||
XFreePixmap(dpy, scr->balloon->contents);
|
||||
|
||||
width = wPreferences.apercu_size;
|
||||
height = wPreferences.apercu_size;
|
||||
|
||||
if (wPreferences.miniwin_title_balloon) {
|
||||
shortenTitle = ShrinkString(font, title, width - APERCU_BORDER);
|
||||
shortenTitle = ShrinkString(font, title, width - APERCU_BORDER * 2);
|
||||
titleHeight = countLines(shortenTitle) * WMFontHeight(font) + 4;
|
||||
height += titleHeight;
|
||||
} else {
|
||||
shortenTitle = NULL;
|
||||
titleHeight = 0;
|
||||
}
|
||||
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
else if (x + width > scr->scr_width - 1)
|
||||
x = scr->scr_width - width - APERCU_BORDER;
|
||||
x = scr->scr_width - width - 1;
|
||||
|
||||
if (y - height - 2 < 0) {
|
||||
y += wPreferences.icon_size;
|
||||
@@ -413,16 +420,16 @@ static void showApercu(WScreen *scr, int x, int y, int height, int width, char *
|
||||
pixmap = XCreatePixmap(dpy, scr->root_win, width, height, scr->w_depth);
|
||||
XFillRectangle(dpy, pixmap, scr->draw_gc, 0, 0, width, height);
|
||||
|
||||
if (shortenTitle && wPreferences.miniwin_title_balloon) {
|
||||
if (shortenTitle != NULL) {
|
||||
drawMultiLineString(scr->wmscreen, pixmap, scr->window_title_color[0], font,
|
||||
APERCU_BORDER, APERCU_BORDER, shortenTitle, strlen(shortenTitle));
|
||||
wfree(shortenTitle);
|
||||
}
|
||||
|
||||
XCopyArea(dpy, apercu, pixmap, scr->draw_gc,
|
||||
0, 0, (wPreferences.icon_size - 1 - APERCU_BORDER) * wPreferences.apercu_size,
|
||||
(wPreferences.icon_size - 1 - APERCU_BORDER) * wPreferences.apercu_size,
|
||||
APERCU_BORDER, APERCU_BORDER + titleHeight);
|
||||
0, 0, (wPreferences.apercu_size - 1 - APERCU_BORDER * 2),
|
||||
(wPreferences.apercu_size - 1 - APERCU_BORDER * 2),
|
||||
APERCU_BORDER, APERCU_BORDER + titleHeight);
|
||||
|
||||
#ifdef SHAPED_BALLOON
|
||||
XShapeCombineMask(dpy, scr->balloon->window, ShapeBounding, 0, 0, None, ShapeSet);
|
||||
@@ -457,9 +464,7 @@ static void showBalloon(WScreen *scr)
|
||||
|
||||
if (wPreferences.miniwin_apercu_balloon && scr->balloon->apercu != None)
|
||||
/* used to display either the apercu alone or the apercu and the title */
|
||||
showApercu(scr, x, y, (wPreferences.icon_size - 1) * wPreferences.apercu_size,
|
||||
(wPreferences.icon_size - 1) * wPreferences.apercu_size,
|
||||
scr->balloon->text, scr->balloon->apercu);
|
||||
showApercu(scr, x, y, scr->balloon->text, scr->balloon->apercu);
|
||||
else
|
||||
showText(scr, x, y, scr->balloon->h, w, scr->balloon->text);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user