Are you sure it's safe to change the test in that following code ?
- if (shortenTitle wPreferences.miniwin_title_balloon) {
+ if (shortenTitle != NULL) {
On Sun, Nov 16, 2014 at 2:40 AM, Christophe christophe.cu...@free.fr wrote:
From: Christophe CURIS christophe.cu...@free.fr
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.cu...@free.fr
---
src/WindowMaker.h | 2 +-
src/balloon.c | 29 +
src/defaults.c| 15 +++
src/icon.c| 4 ++--
src/icon.h| 3 ++-
5 files changed, 37 insertions(+), 16 deletions(-)
diff --git a/src/WindowMaker.h b/src/WindowMaker.h
index 17462f8..0663b54 100644
--- a/src/WindowMaker.h
+++ b/src/WindowMaker.h
@@ -444,7 +444,7 @@ extern struct WPreferences {
char cycle_ignore_minimized;/* Ignore minimized windows when
cycling */
char strict_windoze_cycle; /* don't close switch panel when
shift is released */
char panel_only_open; /* Only open the switch panel;
don't switch */
- char apercu_size; /* Size of apercu preview as a
multiple of icon size */
+ int apercu_size;/* Size of apercu preview in
pixels */
/* All delays here are in ms. 0 means instant auto-action. */
int clip_auto_raise_delay; /* Delay after which the clip
will be raised when entered */
diff --git a/src/balloon.c b/src/balloon.c
index de003aa..c989803 100644
--- a/src/balloon.c
+++ b/src/balloon.c
@@ -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),
+