This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project wmaker-crm.git.
The branch, next has been updated discards a3f2e4b87da3339803e56255b3cfa963ea662958 (commit) discards 73e0a088b692f5fa04842c6d1571526e16bf10fb (commit) discards 424144254ea7d3b73606e00d3d4ed3a566afc121 (commit) discards 415a436f77e31a5962c8ff8b9d2ff31f9cc22834 (commit) discards 2f702495702ed26ba05181ddac6d18d8fee67ba0 (commit) discards 3dcd0df42c743098a6b8f5c65889c62d093814f6 (commit) discards b34a2dd7a0f4f2fe8e402829bf23626c3214fff7 (commit) discards 788383e79ed5972aba62b06ac959b1d506777b34 (commit) discards 8afe58d8ec3f76713ebde080e7b5c3e76258e7c1 (commit) discards 061c7636423a823ab8fa3d210a3c25431db7633b (commit) discards b0a2c9638f33d3b5a55f0a9b50b4987deb60ffef (commit) discards 790d967d3f762b72274fb552d579e294eca08511 (commit) discards c2aff8c51bdc19950a947d6e9a508c5bea302078 (commit) discards 09db9a4f12a451f211f94e9b45dde097f35ff953 (commit) discards 939b72393d81a3248fc6a05aecc3280a7564d7c4 (commit) discards 2dc9d4f4a9d4e35f31dc73e73a1807503a5f9961 (commit) discards 0bbfa2e01ef5eb599b90283c289a634965e3106d (commit) discards 15983dfafe0707d509b5b8bc5b774e51d8d8328f (commit) discards b4544617e3dd5dbda1f96ba06b815ffb652369c2 (commit) discards 703502480b9aaaf4a5599f0d6dd68ee27c310043 (commit) discards 20b76fc3b62a2bc50e9bf73d85fa25711507a3dd (commit) discards 9f4d568eb06753cc7197dbf73422267194af9805 (commit) discards 5eefe41b0a18ac32f1e734330cf2a2d899bf47fc (commit) discards 1e6740b34467cf9de4f7fb41b939bc3f0316e229 (commit) discards b190ab4b5ea9e3e3c7236f4146a5ff76dd2ac153 (commit) discards 86fea0978f0c20a6b3379d40f84a4ed3be134e75 (commit) discards 2a4750b049ec198bb3789dff1c93098119d7ba80 (commit) discards d606df893eb74e78b0e12346629e2f5e65d67336 (commit) discards 06d96ed18fc0bcadd9bb521e929acb2a970548cf (commit) discards 6f318e86f36bfa11535c0102225b8c575e61e2c5 (commit) discards 855544626f1a8d7174d5798713c2e7e4460d979e (commit) discards a4713cbb4d49b1b59eb5282e0c97554a7efe50e2 (commit) discards 252bd7359bcc2c686a4c6bb96e8875f302e21dbd (commit) discards a864f1988fd7fd044633b319c40a8f0ab1b85658 (commit) discards c94fc4ba39f2b3a0b8e3ed5e56a35c42cc36cd01 (commit) discards 467b7ee4560f124f7469a2a630cb35d477cc0444 (commit) via c6e323e75dafc7c5553dde448cc625304cab95b4 (commit) via 0e884f793a20e97ea25de9dc7102e4330d053c35 (commit) via f9b14d7824be478f70281ccf9935a52a35a2f8b2 (commit) via ee617cb29138d83ca820a86a6006b91a2a06cee2 (commit) via b3c20610e9f43ab71152738d4c20fe388e70052d (commit) via 1d1c5f77c744dff0aa7323e5defc4f89b8df97b9 (commit) via b5e89127ca9f2b9d01c521782b6a474b7fcbce22 (commit) via 7ce2636f6380be8db0ae8a90edd834d358cc66c8 (commit) via 10b890e920804337d5704454ac72f312dc0001dc (commit) via 4799df55067d40be997a5c255af40a111daa86fb (commit) via 723f2173555bde7ee3a131a86619b7ed2d49bc4e (commit) via 1d0f02f5ca877051583b85554d57b070cca2f1ec (commit) via bbd42b3a20a72862a87e42e57ce29ef1f07e208c (commit) via ff77b6b2e5e3882059de11d55b3a4d1cba38dfc8 (commit) via 3bf2978e63b2addb9600bc6c953fe6d4230b29f3 (commit) via 59106395c061f2343e37b3ba9b199987fe9d9507 (commit) via e09df40f78c5439ddc8fab65f7ec509879bea03a (commit) via 4b0838e93a753dfa8718e3e91899eb237af63de8 (commit) via 781fd777ebdb32c582a38bbbeea7605a2de99880 (commit) via 03385c3d78c49df0dc9eb46a20b55b6f48af80fa (commit) via e5efbe0cf28b0801fb57b423e6e33c82b3235405 (commit) via 149f6b0390d11a73e0c24b23c65a1c13092abf0e (commit) via 30e1fad92675be833e6c3f61e3191b393da3b7e7 (commit) via 11fe8bd860af5a113af42d20caac525285cbf9a9 (commit) via fa4d50a0caa41c994128781b18ae48682cb64cd1 (commit) via 0c938a3c0c3c343845b175fde419f45e0971403e (commit) via be4849448f2039bbd47013ecb306df9e8d4e1581 (commit) via af1bcde13a89d1a3e30c3a244a134d7933f040b9 (commit) via 34d82e5462996c4912f29d7470c3fdea10785e6f (commit) via de00154fa171512532e44c706b6ed54e253c48cf (commit) via d9438e65efe4e80f5c9e825a7975bd4fded4f868 (commit) via 4bed8d14d77e5c66a5f635cc730c3458a1a292a5 (commit) via ad84a2dc8f59e05502928c8d5d4ab5d92e22321b (commit) via 41745d98d4bffac57787d6f9105d2c5819f73e79 (commit) via 519302223ceea9dd8eabb14d8e1dd3042b2dc66e (commit) via ea8f18aff10bcb2ef036124d646908c7117c65b5 (commit) This update added new revisions after undoing existing revisions. That is to say, the old revision is not a strict subset of the new revision. This situation occurs when you --force push a change and generate a repository containing something like this: * -- * -- B -- O -- O -- O (a3f2e4b87da3339803e56255b3cfa963ea662958) N -- N -- N (c6e323e75dafc7c5553dde448cc625304cab95b4) When this happens we assume that you've already had alert emails for all of the O revisions, and so we here report only the revisions in the N branch from the common base, B. Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://repo.or.cz/w/wmaker-crm.git/commit/c6e323e75dafc7c5553dde448cc625304cab95b4 commit c6e323e75dafc7c5553dde448cc625304cab95b4 Author: David Maciejak <david.macie...@gmail.com> Date: Wed Dec 10 12:27:05 2014 +0700 WINGs: increment version This patch is incrementing version number as the API changed. diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h index ca7be553..47981744 100644 --- a/WINGs/WINGs/WINGs.h +++ b/WINGs/WINGs/WINGs.h @@ -26,7 +26,7 @@ #include <WINGs/WUtil.h> #include <X11/Xlib.h> -#define WINGS_H_VERSION 20140612 +#define WINGS_H_VERSION 20141205 #ifdef __cplusplus diff --git a/configure.ac b/configure.ac index 63f7fa39..c9ed50ce 100644 --- a/configure.ac +++ b/configure.ac @@ -47,9 +47,9 @@ WRASTER_VERSION=$WRASTER_CURRENT:$WRASTER_REVISION:$WRASTER_AGE AC_SUBST(WRASTER_VERSION) dnl dnl libWINGs -WINGS_CURRENT=3 +WINGS_CURRENT=4 WINGS_REVISION=0 -WINGS_AGE=0 +WINGS_AGE=1 WINGS_VERSION=$WINGS_CURRENT:$WINGS_REVISION:$WINGS_AGE AC_SUBST(WINGS_VERSION) dnl http://repo.or.cz/w/wmaker-crm.git/commit/0e884f793a20e97ea25de9dc7102e4330d053c35 commit 0e884f793a20e97ea25de9dc7102e4330d053c35 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:44 2014 +0100 util: remove local constants GLOBAL_DEFAULTS_SUBDIR that are not used As pointed by gcc, this macro is not used anywhere in the 2 files. Because the code also suggests that they should be inherited from any other place anyway, remove them from the file to prevent them from being used in the future. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/util/getstyle.c b/util/getstyle.c index da211acb..f0de4c49 100644 --- a/util/getstyle.c +++ b/util/getstyle.c @@ -54,9 +54,6 @@ #include "../src/wconfig.h" -#ifndef GLOBAL_DEFAULTS_SUBDIR -#define GLOBAL_DEFAULTS_SUBDIR "WindowMaker" -#endif /* table of style related options */ static char *options[] = { diff --git a/util/wmsetbg.c b/util/wmsetbg.c index aee1b567..7253517e 100644 --- a/util/wmsetbg.c +++ b/util/wmsetbg.c @@ -53,9 +53,6 @@ #include "../src/wconfig.h" -#ifndef GLOBAL_DEFAULTS_SUBDIR -#define GLOBAL_DEFAULTS_SUBDIR "WindowMaker" -#endif #include <WINGs/WINGs.h> #include <wraster.h> http://repo.or.cz/w/wmaker-crm.git/commit/f9b14d7824be478f70281ccf9935a52a35a2f8b2 commit f9b14d7824be478f70281ccf9935a52a35a2f8b2 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:43 2014 +0100 WPrefs: remove unused constants ICON_TITLE_*FONT Apparently, there was a time when it was though to add a label below (?) the icons of the list of panels, but this has never been finished and the unfinished code to do this was even removed in commit 0e01e6920572b3d3a7a8df2872513144225440a8 So, as it is unlikely that the "feature" will return, and if it did the font should be handled in a better way, this patch removes the definition of the constants with the names for the font used for those labels. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WPrefs.app/WPrefs.c b/WPrefs.app/WPrefs.c index c3274ee3..02b06d0e 100644 --- a/WPrefs.app/WPrefs.c +++ b/WPrefs.app/WPrefs.c @@ -29,9 +29,6 @@ #endif -#define ICON_TITLE_FONT "sans serif:pixelsize=9" -#define ICON_TITLE_VFONT "sans serif:pixelsize=9:weight=100" - #define MAX_SECTIONS 16 typedef struct _WPrefs { http://repo.or.cz/w/wmaker-crm.git/commit/ee617cb29138d83ca820a86a6006b91a2a06cee2 commit ee617cb29138d83ca820a86a6006b91a2a06cee2 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:42 2014 +0100 wmaker: comment out definition of wm-spec constant that we do not use Include a comment to explain what their aim is, and why WindowMaker is not making use of them. They are not simply removed because it is informative for future contributors that we know about them and we purposedly decided to not use them. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/wmspec.c b/src/wmspec.c index d6bb61c6..89d8fac6 100644 --- a/src/wmspec.c +++ b/src/wmspec.c @@ -217,6 +217,22 @@ static atomitem_t atomNames[] = { #define _NET_WM_STATE_ADD 1 #define _NET_WM_STATE_TOGGLE 2 +#if 0 +/* + * These constant provide information on the kind of window move/resize when + * it is initiated by the application instead of by WindowMaker. They are + * parameter for the client message _NET_WM_MOVERESIZE, as defined by the + * FreeDesktop wm-spec standard: + * http://standards.freedesktop.org/wm-spec/1.5/ar01s04.html + * + * Today, WindowMaker does not support this at all (the corresponding Atom + * is not added to the list in setSupportedHints), probably because there is + * nothing it needs to do about it, the application is assumed to know what + * it is doing, and WindowMaker won't get in the way. + * + * The definition of the constants (taken from the standard) are disabled to + * avoid a spurious warning (-Wunused-macros). + */ #define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0 #define _NET_WM_MOVERESIZE_SIZE_TOP 1 #define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2 @@ -228,6 +244,7 @@ static atomitem_t atomNames[] = { #define _NET_WM_MOVERESIZE_MOVE 8 /* movement only */ #define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9 /* size via keyboard */ #define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10 /* move via keyboard */ +#endif static void observer(void *self, WMNotification *notif); static void wsobserver(void *self, WMNotification *notif); http://repo.or.cz/w/wmaker-crm.git/commit/b3c20610e9f43ab71152738d4c20fe388e70052d commit b3c20610e9f43ab71152738d4c20fe388e70052d Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:41 2014 +0100 wmaker: remove parameter 'which' from local function 'restoreMenu' This parameter is given always the same value, so there is not reason to keep it. The code is updated to take this value into account, and the related constants are removed. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/menu.c b/src/menu.c index e573b395..8322dbb1 100644 --- a/src/menu.c +++ b/src/menu.c @@ -56,10 +56,6 @@ /***** Local Stuff ******/ -#define WSS_ROOTMENU (1<<0) -#define WSS_SWITCHMENU (1<<1) -#define WSS_WSMENU (1<<2) - static struct { int steps; int delay; @@ -2382,7 +2378,7 @@ static Bool getMenuInfo(WMPropList * info, int *x, int *y, Bool * lowered) return True; } -static int restoreMenu(WScreen * scr, WMPropList * menu, int which) +static int restoreMenu(WScreen *scr, WMPropList *menu) { int x, y; Bool lowered = False; @@ -2394,10 +2390,8 @@ static int restoreMenu(WScreen * scr, WMPropList * menu, int which) if (!getMenuInfo(menu, &x, &y, &lowered)) return False; - if (which & WSS_SWITCHMENU) { - OpenSwitchMenu(scr, x, y, False); - pmenu = scr->switch_menu; - } + OpenSwitchMenu(scr, x, y, False); + pmenu = scr->switch_menu; if (pmenu) { int width = MENUW(pmenu); @@ -2508,7 +2502,7 @@ void wMenuRestoreState(WScreen * scr) skey = WMCreatePLString("SwitchMenu"); menu = WMGetFromPLDictionary(menus, skey); WMReleasePropList(skey); - restoreMenu(scr, menu, WSS_SWITCHMENU); + restoreMenu(scr, menu); if (!scr->root_menu) { OpenRootMenu(scr, scr->scr_width * 2, 0, False); http://repo.or.cz/w/wmaker-crm.git/commit/1d1c5f77c744dff0aa7323e5defc4f89b8df97b9 commit 1d1c5f77c744dff0aa7323e5defc4f89b8df97b9 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:40 2014 +0100 wmaker: remove constants HORIZONTAL and VERTICAL from moveres.c These 2 constants have been defined at the beginning of the project, but where never used later. As the use of the associated constants suggests that they are not bringing anything useful, this patch simply removes them. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/moveres.c b/src/moveres.c index 8640511c..b271f324 100644 --- a/src/moveres.c +++ b/src/moveres.c @@ -50,10 +50,8 @@ #define LEFT 1 #define RIGHT 2 -#define HORIZONTAL (LEFT|RIGHT) #define UP 4 #define DOWN 8 -#define VERTICAL (UP|DOWN) /* True if window currently has a border. This also includes borderless * windows which are currently selected @@ -2268,10 +2266,8 @@ void wMouseResizeWindow(WWindow * wwin, XEvent * ev) #undef LEFT #undef RIGHT -#undef HORIZONTAL #undef UP #undef DOWN -#undef VERTICAL #undef HCONSTRAIN #undef RESIZEBAR http://repo.or.cz/w/wmaker-crm.git/commit/b5e89127ca9f2b9d01c521782b6a474b7fcbce22 commit b5e89127ca9f2b9d01c521782b6a474b7fcbce22 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:39 2014 +0100 wmaker: add code to explicitly ignore Motif-WM flags we don't want to handle The goal is to explain the reason why we don't do anything about them, so people looking at the code in the future will know why it is this way. The expected side effect is also to silent warnings [-Wunused-macros] from gcc. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/motif.c b/src/motif.c index 5fca916b..7eaba31c 100644 --- a/src/motif.c +++ b/src/motif.c @@ -92,6 +92,16 @@ static void setupMWMHints(WWindow *wwin, MWMHints *mwm_hints) WSETUFLAG(wwin, no_resizable, 0); } + if (mwm_hints->decorations & MWM_DECOR_BORDER) { + /* + * WindowMaker is drawing only a discreet 1 pixel border without + * any decoration like a few other X window managers used to do, so + * we assume it is not worth spending the time to add extra + * complexity to handle this special request, considering also that + * the Motif toolkit is not used anymore nowadays. + */ + } + if (mwm_hints->decorations & MWM_DECOR_RESIZEH) WSETUFLAG(wwin, no_resizebar, 0); @@ -101,10 +111,26 @@ static void setupMWMHints(WWindow *wwin, MWMHints *mwm_hints) WSETUFLAG(wwin, no_closable, 0); } + if (mwm_hints->decorations * MWM_DECOR_MENU) { + /* + * WindowMaker does not include a button to display the menu + * for windows, this is done using right mouse button on the + * title bar. As a consequence, we ignore this flag because we + * have nothing to hide. + */ + } + if (mwm_hints->decorations & MWM_DECOR_MINIMIZE) { WSETUFLAG(wwin, no_miniaturize_button, 0); WSETUFLAG(wwin, no_miniaturizable, 0); } + + if (mwm_hints->decorations & MWM_DECOR_MAXIMIZE) { + /* + * WindowMaker does not display a button to maximize windows, + * so we don't need to hide anything more for that flag + */ + } } if (mwm_hints->flags & MWM_HINTS_FUNCTIONS) { @@ -120,6 +146,13 @@ static void setupMWMHints(WWindow *wwin, MWMHints *mwm_hints) if (mwm_hints->functions & MWM_FUNC_RESIZE) WSETUFLAG(wwin, no_resizable, 0); + if (mwm_hints->functions & MWM_FUNC_MOVE) { + /* + * WindowMaker does not allow a window to not be moved, and this + * is a good thing, so we explicitly ignore this flag. + */ + } + if (mwm_hints->functions & MWM_FUNC_MINIMIZE) WSETUFLAG(wwin, no_miniaturizable, 0); http://repo.or.cz/w/wmaker-crm.git/commit/7ce2636f6380be8db0ae8a90edd834d358cc66c8 commit 7ce2636f6380be8db0ae8a90edd834d358cc66c8 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:38 2014 +0100 wmaker: removed unused constant SCROLL_STEPS in the switchpanel code As pointed by gcc, this constant is not used anywhere in the code. It seems to have been prepared for a scroll animation when the switchpanel would be too big to fit the screen, but the code looks like to never have been activated, and was cleaned away in commit 6d08aa22d824d6abe5edb4c4892bbf9eaec3175b If the feature were to be re-added, it would be better to use something proportional to the menu scroll speed parameter that can be configured by user anyway. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/switchpanel.c b/src/switchpanel.c index f048ac52..b3832f16 100644 --- a/src/switchpanel.c +++ b/src/switchpanel.c @@ -68,7 +68,6 @@ struct SwitchPanel { #define ICON_TILE_SIZE 64 #define LABEL_HEIGHT 25 #define SCREEN_BORDER_SPACING 2*20 -#define SCROLL_STEPS (ICON_TILE_SIZE/2) #define ICON_SELECTED (1<<1) #define ICON_DIM (1<<2) http://repo.or.cz/w/wmaker-crm.git/commit/10b890e920804337d5704454ac72f312dc0001dc commit 10b890e920804337d5704454ac72f312dc0001dc Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:37 2014 +0100 wmaker: removed unused macro DBLCLICK_TIME As pointed by gcc, this macro is not used anywhere, that is probably because the code have been relying on the function "IsDoubleClick" for a very long time now. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/framewin.c b/src/framewin.c index d045f63a..4233360d 100644 --- a/src/framewin.c +++ b/src/framewin.c @@ -43,8 +43,6 @@ #include "misc.h" #include "event.h" -#define DBLCLICK_TIME wPreferences.dblclick_time - static void handleExpose(WObjDescriptor * desc, XEvent * event); static void handleButtonExpose(WObjDescriptor * desc, XEvent * event); http://repo.or.cz/w/wmaker-crm.git/commit/4799df55067d40be997a5c255af40a111daa86fb commit 4799df55067d40be997a5c255af40a111daa86fb Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:36 2014 +0100 replaced all local definitions of PI by a single one For code maintainability, it is better to have a single definition of the constant than many ones dispatched in many places. In addition, we try to count on the constant M_PI that can be defined by the header <math.h> if possible because it may have the best accuracy for the platform. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c index 12d54480..f23c91d2 100644 --- a/WINGs/wcolorpanel.c +++ b/WINGs/wcolorpanel.c @@ -265,9 +265,6 @@ enum { #define COLORWHEEL_PART 1 #define CUSTOMPALETTE_PART 2 -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif static char *generateNewFilename(const char *curName); static void convertCPColor(CPColor * color); @@ -1951,7 +1948,7 @@ static void wheelInitMatrix(W_ColorPanel * panel) if (sat < 256) { if (xcor != 0) dhue[0] = rint(atan((double)ycor / (double)xcor) * - (180.0 / M_PI)) + (xcor < 0 ? 180.0 : 0.0); + (180.0 / WM_PI)) + (xcor < 0 ? 180.0 : 0.0); else dhue[0] = 270; @@ -2237,7 +2234,7 @@ static void wheelPositionSelectionOutBounds(W_ColorPanel * panel, int x, int y) panel->color.hsv.value = 255 - WMGetSliderValue(panel->wheelBrightnessS); if (xcor != 0) - hue = rint(atan(-(double)ycor / (double)xcor) * (180.0 / M_PI)); + hue = rint(atan(-(double)ycor / (double)xcor) * (180.0 / WM_PI)); else { if (ycor < 0) hue = 90; @@ -2257,9 +2254,9 @@ static void wheelPositionSelectionOutBounds(W_ColorPanel * panel, int x, int y) wheelUndrawSelection(panel); - panel->colx = 2 + rint((colorWheelSize * (1.0 + cos(panel->color.hsv.hue * (M_PI / 180.0)))) / 2.0); + panel->colx = 2 + rint((colorWheelSize * (1.0 + cos(panel->color.hsv.hue * (WM_PI / 180.0)))) / 2.0); /* "+2" because of "colorWheelSize + 4" */ - panel->coly = 2 + rint((colorWheelSize * (1.0 + sin(-panel->color.hsv.hue * (M_PI / 180.0)))) / 2.0); + panel->coly = 2 + rint((colorWheelSize * (1.0 + sin(-panel->color.hsv.hue * (WM_PI / 180.0)))) / 2.0); wheelUpdateSelection(panel); cpColor = panel->color; @@ -3357,10 +3354,10 @@ static void wheelInit(W_ColorPanel * panel) panel->colx = 2 + rint((colorWheelSize / 2.0) * (1 + (panel->color.hsv.saturation / 255.0) * - cos(panel->color.hsv.hue * M_PI / 180.0))); + cos(panel->color.hsv.hue * WM_PI / 180.0))); panel->coly = 2 + rint((colorWheelSize / 2.0) * (1 + (panel->color.hsv.saturation / 255.0) * - sin(-panel->color.hsv.hue * M_PI / 180.0))); + sin(-panel->color.hsv.hue * WM_PI / 180.0))); wheelCalculateValues(panel, panel->color.hsv.value); diff --git a/m4/wm_libmath.m4 b/m4/wm_libmath.m4 index 8d056a2e..d21493f7 100644 --- a/m4/wm_libmath.m4 +++ b/m4/wm_libmath.m4 @@ -30,5 +30,24 @@ AC_CHECK_FUNC(atan, [LIBM=-lm], [AC_MSG_WARN(Could not find Math library, you may experience problems) LIBM=] )] ) dnl +AC_CACHE_CHECK([if M_PI is defined in math.h], [wm_cv_libm_pi], + [wm_cv_libm_pi="no" + wm_save_CFLAGS="$CFLAGS" + for wm_arg in dnl + "% yes" dnl natively available (Unix98 compliant?) + "-D_XOPEN_SOURCE=500" ; dnl Explicit request + do + AS_IF([wm_fn_lib_try_compile "math.h" "double val;" "val = M_PI" dnl + "`echo "$wm_arg" | sed -e 's, *%.*$,,' `"], + [wm_cv_libm_pi="`echo "$wm_arg" | sed -e 's,^.*% *,,' `" ; break]) + done + CFLAGS="$wm_save_CFLAGS"]) +AS_IF([test "x$wm_cv_libm_pi" = "xno"], + [AC_DEFINE([WM_PI], [(3.14159265358979323846)], + [Defines how to access the value of Pi])], + [AC_DEFINE([WM_PI], [(M_PI)], + [Defines how to access the value of Pi]) + AS_IF([test "x$wm_cv_libm_pi" != "xyes"], + [CFLAGS="$CFLAGS $wm_cv_libm_pi"]) ]) AC_SUBST(LIBM) dnl ]) diff --git a/src/wconfig.h.in b/src/wconfig.h.in index c1548ee6..2930bcb0 100644 --- a/src/wconfig.h.in +++ b/src/wconfig.h.in @@ -334,7 +334,6 @@ /* number of window shortcuts */ #define MAX_WINDOW_SHORTCUTS 10 -#define WM_PI 3.14159265358979323846 #define MIN_TITLEFONT_HEIGHT(h) ((h)>14 ? (h) : 14) #define TITLEBAR_HEIGHT 18 /* window's titlebar height */ #define RESIZEBAR_HEIGHT 8 /* height of the resizebar */ diff --git a/wrlib/rotate.c b/wrlib/rotate.c index 84b34b7a..482b3174 100644 --- a/wrlib/rotate.c +++ b/wrlib/rotate.c @@ -33,9 +33,6 @@ #include <math.h> -#ifndef PI -#define PI 3.14159265358979323846 -#endif static RImage *rotate_image_90(RImage *source); static RImage *rotate_image_270(RImage *source); @@ -347,13 +344,13 @@ static RImage *rotate_image_any(RImage *source, float angle) if (angle > 180.0) angle -= 180.0; - angle = (angle * PI) / 180.0; + angle = (angle * WM_PI) / 180.0; nwidth = ceil(abs(cos(angle) * image->width)) - + ceil(abs(cos(PI / 2 - angle) * image->width)); + + ceil(abs(cos(WM_PI / 2 - angle) * image->width)); nheight = ceil(abs(sin(angle) * image->height)) - + ceil(abs(cos(PI / 2 - angle) * image->height)); + + ceil(abs(cos(WM_PI / 2 - angle) * image->height)); img = RCreateImage(nwidth, nheight, True); if (!img) @@ -362,16 +359,16 @@ static RImage *rotate_image_any(RImage *source, float angle) src = image->data; dst = img->data; - x1 = floor(abs(cos(PI / 2 - angle) * image->width)); + x1 = floor(abs(cos(WM_PI / 2 - angle) * image->width)); y1 = 0; x2 = 0; - y2 = floor(abs(sin(PI / 2 - angle) * image->width)); + y2 = floor(abs(sin(WM_PI / 2 - angle) * image->width)); xx = floor(abs(cos(angle) * image->height)) - 1; yy = nheight - 1; - printf("%ix%i, %i %i %i %i %in", nwidth, nheight, x1, y1, x2, y2, (int)((angle * 180.0) / PI)); + printf("%ix%i, %i %i %i %i %in", nwidth, nheight, x1, y1, x2, y2, (int)((angle * 180.0) / WM_PI)); dx = abs(x2 - x1); dy = abs(y2 - y1); @@ -414,8 +411,8 @@ static RImage *rotate_image_any(RImage *source, float angle) p = dpr - dy; while (dy-- >= 0) { - xx = abs(x1 * sin(angle * PI / 180.0)); - yy = abs(y1 * cos(angle * PI / 180.0)); + xx = abs(x1 * sin(angle * WM_PI / 180.0)); + yy = abs(y1 * cos(angle * WM_PI / 180.0)); copyLine(x1, y1, xx, yy, nwidth, image->format, dst, &src); diff --git a/wrlib/scale.c b/wrlib/scale.c index eafe40f9..0f5952c8 100644 --- a/wrlib/scale.c +++ b/wrlib/scale.c @@ -27,11 +27,6 @@ #include <string.h> #include <X11/Xlib.h> #include <math.h> - -#ifndef PI -#define PI 3.14159265358979323846 -#endif - #include <assert.h> #include "wraster.h" @@ -200,7 +195,7 @@ static double sinc(double x) * The goal was to avoid a Divide-by-0 error, now we also * avoid a +/-inf result too */ - x *= PI; + x *= WM_PI; if (x > 1.0E-9) return (sin(x) / x); return (1.0); http://repo.or.cz/w/wmaker-crm.git/commit/723f2173555bde7ee3a131a86619b7ed2d49bc4e commit 723f2173555bde7ee3a131a86619b7ed2d49bc4e Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:35 2014 +0100 remove unused macros defining corner positions As pointed by gcc, the 4 constant the define the corner positions are not used anywhere in the code, and it looks like it has always been like this. As it is a cost for maintainability, get rid of them. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WINGs/wballoon.c b/WINGs/wballoon.c index 78fac113..c87b6c9e 100644 --- a/WINGs/wballoon.c +++ b/WINGs/wballoon.c @@ -229,11 +229,6 @@ void W_BalloonHandleEnterView(WMView * view) #define LEFT 0 #define RIGHT 2 -#define TLEFT (TOP|LEFT) -#define TRIGHT (TOP|RIGHT) -#define BLEFT (BOTTOM|LEFT) -#define BRIGHT (BOTTOM|RIGHT) - #define SPACE 12 static void drawBalloon(WMScreen * scr, Pixmap bitmap, Pixmap pix, int x, int y, int w, int h, int side) diff --git a/src/balloon.c b/src/balloon.c index c989803e..25998e1f 100644 --- a/src/balloon.c +++ b/src/balloon.c @@ -72,11 +72,6 @@ typedef struct _WBalloon { #define LEFT 0 #define RIGHT 2 -#define TLEFT (TOP|LEFT) -#define TRIGHT (TOP|RIGHT) -#define BLEFT (BOTTOM|LEFT) -#define BRIGHT (BOTTOM|RIGHT) - static int countLines(const char *text) { const char *p = text; http://repo.or.cz/w/wmaker-crm.git/commit/1d0f02f5ca877051583b85554d57b070cca2f1ec commit 1d0f02f5ca877051583b85554d57b070cca2f1ec Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:34 2014 +0100 remove a few unused constant for size of buffers As pointed by gcc, a few constants which contain sizes for buffers are not used anywhere in the code. This is probably due to code cleanup, where these buffers have been removed or where size is automatically calculated by using 'sizeof' instead to reduce risk of bugs. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c index 9cb004e5..12d54480 100644 --- a/WINGs/wcolorpanel.c +++ b/WINGs/wcolorpanel.c @@ -264,9 +264,6 @@ enum { #define COLORWHEEL_PART 1 #define CUSTOMPALETTE_PART 2 -#define BUFSIZE 1024 - -#define MAX_LENGTH 1024 #ifndef M_PI #define M_PI 3.14159265358979323846 diff --git a/WINGs/wfontpanel.c b/WINGs/wfontpanel.c index aede6ddc..2d6f77f7 100644 --- a/WINGs/wfontpanel.c +++ b/WINGs/wfontpanel.c @@ -43,8 +43,6 @@ typedef struct W_FontPanel { #define MIN_UPPER_HEIGHT 20 #define MIN_LOWER_HEIGHT 140 -#define MAX_FONTS_TO_RETRIEVE 2000 - #define BUTTON_SPACE_HEIGHT 40 #define MIN_WIDTH 250 diff --git a/WPrefs.app/Menu.c b/WPrefs.app/Menu.c index db5b6c18..5f0f0171 100644 --- a/WPrefs.app/Menu.c +++ b/WPrefs.app/Menu.c @@ -42,7 +42,6 @@ typedef enum { } InfoType; #define MAX_SECTION_SIZE 4 -#define PATH_LEN 256 typedef struct _Panel { WMBox *box; diff --git a/src/workspace.c b/src/workspace.c index 9a820574..380ffec0 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -57,7 +57,6 @@ /* index of the first workspace menu entry */ #define MC_WORKSPACE1 3 -#define MAX_SHORTCUT_LENGTH 32 #define WORKSPACE_NAME_DISPLAY_PADDING 32 static WMPropList *dWorkspaces = NULL; http://repo.or.cz/w/wmaker-crm.git/commit/bbd42b3a20a72862a87e42e57ce29ef1f07e208c commit bbd42b3a20a72862a87e42e57ce29ef1f07e208c Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:33 2014 +0100 WINGs: reuse GNUstep header instead of duplicating stuff in wwindow.c There is a header that defines the stucts and constants to support GNUstep specific things, and it is already used somewhere else in WINGs, so instead of duplicating locally the stuff we re-use the header, it makes code easier to maintain. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WINGs/wwindow.c b/WINGs/wwindow.c index 23badf5b..503611d0 100644 --- a/WINGs/wwindow.c +++ b/WINGs/wwindow.c @@ -3,6 +3,8 @@ #include "WINGsP.h" +#include "GNUstep.h" + #include <X11/Xatom.h> typedef struct W_Window { @@ -46,32 +48,6 @@ typedef struct W_Window { } flags; } _Window; -typedef struct { - CARD32 flags; - CARD32 window_style; - CARD32 window_level; - CARD32 reserved; - Pixmap miniaturize_pixmap; /* pixmap for miniaturize button */ - Pixmap close_pixmap; /* pixmap for close button */ - Pixmap miniaturize_mask; /* miniaturize pixmap mask */ - Pixmap close_mask; /* close pixmap mask */ - CARD32 extra_flags; -} GNUstepWMAttributes; - -#define GSWindowStyleAttr (1<<0) -#define GSWindowLevelAttr (1<<1) -#define GSMiniaturizePixmapAttr (1<<3) -#define GSClosePixmapAttr (1<<4) -#define GSMiniaturizeMaskAttr (1<<5) -#define GSCloseMaskAttr (1<<6) -#define GSExtraFlagsAttr (1<<7) - -/* extra flags */ -#define GSDocumentEditedFlag (1<<0) -#define GSNoApplicationIconFlag (1<<5) - -#define WMFHideOtherApplications 10 -#define WMFHideApplication 12 static void willResizeWindow(W_ViewDelegate *, WMView *, unsigned *, unsigned *); http://repo.or.cz/w/wmaker-crm.git/commit/ff77b6b2e5e3882059de11d55b3a4d1cba38dfc8 commit ff77b6b2e5e3882059de11d55b3a4d1cba38dfc8 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:32 2014 +0100 WINGs: remove internal XDND macros that are not used The group of XDND_* macro do not bring a lot in term of clarity, so it is probable that they will get away someday, but at current time as 2 of them are not used anywhere they get removed to prevent their use in the future. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WINGs/dragdestination.c b/WINGs/dragdestination.c index 2833b886..a3ce8713 100644 --- a/WINGs/dragdestination.c +++ b/WINGs/dragdestination.c @@ -19,9 +19,7 @@ #define XDND_REQUIRED_TYPES(dragInfo) dragInfo->destInfo->requiredTypes #define XDND_SOURCE_ACTION(dragInfo) dragInfo->sourceAction #define XDND_DEST_ACTION(dragInfo) dragInfo->destinationAction -#define XDND_SOURCE_OPERATIONS(dragInfo) dragInfo->destInfo->sourceOperations #define XDND_DROP_DATAS(dragInfo) dragInfo->destInfo->dropDatas -#define XDND_DROP_DATA_COUNT(dragInfo) dragInfo->destInfo->dropDataCount #define XDND_DEST_VIEW_IS_REGISTERED(dragInfo) ((dragInfo->destInfo) != NULL) && ((dragInfo->destInfo->destView->dragDestinationProcs) != NULL) http://repo.or.cz/w/wmaker-crm.git/commit/3bf2978e63b2addb9600bc6c953fe6d4230b29f3 commit 3bf2978e63b2addb9600bc6c953fe6d4230b29f3 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:31 2014 +0100 WINGs: remove macro ABS_SHIFT from the wcolorpanel code This macro was define a *very* long time ago, in commit d98f1fa645be332b35e8f8d1c2b7ce8ab1231be0 but was not used at that time, and have never been used anywhere since then. As the macro does not look like a good idea for performance anyway, get rid of it before anyone could get tempted to use it. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c index 0b3fc159..9cb004e5 100644 --- a/WINGs/wcolorpanel.c +++ b/WINGs/wcolorpanel.c @@ -3525,9 +3525,6 @@ static void convertCPColor(CPColor * color) } } -#define ABS_SHIFT(val, shift) - (((shift) > 0) ? (val) >> (shift) : (val) << -(shift)) - static RColor ulongToRColor(WMScreen * scr, unsigned long value) { RColor color; http://repo.or.cz/w/wmaker-crm.git/commit/59106395c061f2343e37b3ba9b199987fe9d9507 commit 59106395c061f2343e37b3ba9b199987fe9d9507 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:30 2014 +0100 WINGs: remove dead code from 'loadPixmaps' It seems the code had the possibility to load a default icon, probably to be used on the windows if the main program does not provide any. This code however have never been enabled, probably because it is better to not provide an icon and let the window manager use its own. This patch then removes that dead code, but keeps the image as part of the WINGs resource for the case where an application would have been using it. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WINGs/widgets.c b/WINGs/widgets.c index 87fa9d62..2cb27b8a 100644 --- a/WINGs/widgets.c +++ b/WINGs/widgets.c @@ -363,10 +363,7 @@ static WMPixmap *makePixmap(W_Screen * sPtr, char **data, int width, int height, } #define T_WINGS_IMAGES_FILE RESOURCE_PATH"/Images.tiff" -#define T_DEFAULT_OBJECT_ICON_FILE RESOURCE_PATH"/defaultIcon.tiff" - #define X_WINGS_IMAGES_FILE RESOURCE_PATH"/Images.xpm" -#define X_DEFAULT_OBJECT_ICON_FILE RESOURCE_PATH"/defaultIcon.xpm" static Bool loadPixmaps(WMScreen * scr) { @@ -474,16 +471,6 @@ static Bool loadPixmaps(WMScreen * scr) RReleaseImage(image); -#if 0 - scr->defaultObjectIcon = WMCreatePixmapFromFile(scr, T_DEFAULT_OBJECT_ICON_FILE); - if (!scr->defaultObjectIcon) { - scr->defaultObjectIcon = WMCreatePixmapFromFile(scr, X_DEFAULT_OBJECT_ICON_FILE); - } - if (!scr->defaultObjectIcon) { - wwarning("WINGs: could not load default icon file"); - return False; - } -#endif return True; } http://repo.or.cz/w/wmaker-crm.git/commit/e09df40f78c5439ddc8fab65f7ec509879bea03a commit e09df40f78c5439ddc8fab65f7ec509879bea03a Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:29 2014 +0100 WINGs: remove unused macro NFONT in wbutton As pointed by gcc, this macro is never used in the code; when no font is defined by user the 'paintButton' code already falls back to the 'normalFont' of the screen, and this code could not need the macro anyway. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WINGs/wbutton.c b/WINGs/wbutton.c index c217edd4..8c8e4dce 100644 --- a/WINGs/wbutton.c +++ b/WINGs/wbutton.c @@ -98,7 +98,6 @@ static void handleActionEvents(XEvent * event, void *data); static char *WMPushedRadioNotification = "WMPushedRadioNotification"; -#define NFONT(b) (b)->view->screen->normalFont WMButton *WMCreateCustomButton(WMWidget * parent, int behaviourMask) { http://repo.or.cz/w/wmaker-crm.git/commit/4b0838e93a753dfa8718e3e91899eb237af63de8 commit 4b0838e93a753dfa8718e3e91899eb237af63de8 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:28 2014 +0100 WINGs: remove unused constant DEFAULT_BORDER_WIDTH in wcolorwell As pointed by gcc, this constant is not used anywhere, and it looks like it have always been the case. As there's no reason to specifically add a border to this widget, remove the constant. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WINGs/wcolorwell.c b/WINGs/wcolorwell.c index 595531c4..a5d1a1da 100644 --- a/WINGs/wcolorwell.c +++ b/WINGs/wcolorwell.c @@ -80,7 +80,6 @@ static WMDragDestinationProcs _DragDestinationProcs = { #define DEFAULT_WIDTH 60 #define DEFAULT_HEIGHT 30 -#define DEFAULT_BORDER_WIDTH 6 #define MIN_WIDTH 16 #define MIN_HEIGHT 8 http://repo.or.cz/w/wmaker-crm.git/commit/781fd777ebdb32c582a38bbbeea7605a2de99880 commit 781fd777ebdb32c582a38bbbeea7605a2de99880 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:27 2014 +0100 WINGs: remove constants used for default width+height for the widget As pointed by gcc, the height is never used and the code make use of the SCROLLER_WIDTH constant anyway, so this patch updates the code to directly use that constant instead of intermediate values that just adds noise for code maintainability. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WINGs/wscroller.c b/WINGs/wscroller.c index 4a5ae8c4..f1daa3a6 100644 --- a/WINGs/wscroller.c +++ b/WINGs/wscroller.c @@ -64,8 +64,6 @@ typedef struct W_Scroller { } flags; } Scroller; -#define DEFAULT_HEIGHT 60 -#define DEFAULT_WIDTH SCROLLER_WIDTH #define DEFAULT_ARROWS_POSITION WSAMinEnd #define BUTTON_SIZE ((SCROLLER_WIDTH) - 4) @@ -108,7 +106,7 @@ WMScroller *WMCreateScroller(WMWidget * parent) WMCreateEventHandler(sPtr->view, ExposureMask | StructureNotifyMask | ClientMessageMask, handleEvents, sPtr); - W_ResizeView(sPtr->view, DEFAULT_WIDTH, DEFAULT_WIDTH); + W_ResizeView(sPtr->view, SCROLLER_WIDTH, SCROLLER_WIDTH); sPtr->flags.arrowsPosition = DEFAULT_ARROWS_POSITION; WMCreateEventHandler(sPtr->view, ButtonPressMask | ButtonReleaseMask http://repo.or.cz/w/wmaker-crm.git/commit/03385c3d78c49df0dc9eb46a20b55b6f48af80fa commit 03385c3d78c49df0dc9eb46a20b55b6f48af80fa Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:26 2014 +0100 WINGs: remove the macro DEFAULT_TITLE because it is not used As pointed by gcc, the macro is not used, that is probably because it is totally ok to never provide a title from X point of view, so there is now reason to fall back to that empty constant. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WINGs/wwindow.c b/WINGs/wwindow.c index 28844fb9..23badf5b 100644 --- a/WINGs/wwindow.c +++ b/WINGs/wwindow.c @@ -85,7 +85,6 @@ struct W_ViewDelegate _WindowViewDelegate = { #define DEFAULT_WIDTH 400 #define DEFAULT_HEIGHT 180 -#define DEFAULT_TITLE "" static void destroyWindow(_Window * win); http://repo.or.cz/w/wmaker-crm.git/commit/e5efbe0cf28b0801fb57b423e6e33c82b3235405 commit e5efbe0cf28b0801fb57b423e6e33c82b3235405 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:25 2014 +0100 configure: make the gcc check for trampolines stronger Because the use of trampolines can be a lot of problems, this patch changes the use of the flag to: - make it an error if possible, so coders are forced to not use them; - always enable them, not just for debug, so we increase the probability to get them caught. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/configure.ac b/configure.ac index 93cd6ebd..63f7fa39 100644 --- a/configure.ac +++ b/configure.ac @@ -104,6 +104,16 @@ AS_IF([test "x$debug" = "xyes"], AX_CFLAGS_GCC_OPTION(-Wall) AX_CFLAGS_GCC_OPTION(-Wextra -Wno-sign-compare) +dnl +dnl The use of trampolines cause code that can crash on some secured OS, it is +dnl also known to be a source of crash if not used properly, in a more general +dnl way it tends to generate binary code that may not be optimal, and it is +dnl not compatible with the 'nested-func-to-macro' workaround +WM_CFLAGS_CHECK_FIRST([-Wtrampolines], + [-Werror=trampolines dnl try to generate an error if possible + -Wtrampolines dnl if not, try to fall back to a simple warning + ]) +dnl AS_IF([test "x$debug" = "xyes"], [dnl When debug is enabled, we try to activate more checks from dnl the compiler. They are on independant check because the @@ -172,11 +182,6 @@ AS_IF([test "x$debug" = "xyes"], -Wmissing-noreturn dnl clang syntax ]) dnl - dnl The use of trampolines cause code that can crash on some - dnl secured OS, and in a more general way generate binary code - dnl that may not be optimal - AX_CFLAGS_GCC_OPTION([-Wtrampolines]) - dnl dnl GCC provides a couple of checks to detect incorrect macro uses AX_CFLAGS_GCC_OPTION([-Wundef]) WM_CFLAGS_GCC_OPTION_UNUSEDMACROS http://repo.or.cz/w/wmaker-crm.git/commit/149f6b0390d11a73e0c24b23c65a1c13092abf0e commit 149f6b0390d11a73e0c24b23c65a1c13092abf0e Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:24 2014 +0100 configure: add a few warning flags for gcc and clang to help catch bugs They concern topics like: - portability; - dangerous constructs; - clearer code for maintainability Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/configure.ac b/configure.ac index db34dd3a..93cd6ebd 100644 --- a/configure.ac +++ b/configure.ac @@ -111,17 +111,40 @@ AS_IF([test "x$debug" = "xyes"], dnl where some options are not supported and we don't want to dnl loose all of them. dnl + dnl clang, suggest parenthesis on bit operations that could be + dnl misunderstood due to C operator precedence + AX_CFLAGS_GCC_OPTION([-Wbitwise-op-parentheses]) + dnl + dnl Points at code that gcc thinks is so complicated that gcc + dnl gives up trying to optimize, which probably also means it is + dnl too complicated to maintain + AX_CFLAGS_GCC_OPTION([-Wdisabled-optimization]) + dnl dnl Floating-point comparison is not a good idea AX_CFLAGS_GCC_OPTION([-Wfloat-equal]) dnl + dnl clang warns about constants that may have portability issues due + dnl to the endianness of the host + AX_CFLAGS_GCC_OPTION([-Wfour-char-constants]) + dnl + dnl clang warns about constant that may be too big to be portable + AX_CFLAGS_GCC_OPTION([-Wliteral-range]) + dnl dnl Try to report misuses of '&' versus '&&' and similar AX_CFLAGS_GCC_OPTION([-Wlogical-op]) dnl + dnl clang, reports cases where the code assumes everyone is an + dnl expert in C operator precedence... which is unlikely! + AX_CFLAGS_GCC_OPTION([-Wlogical-op-parentheses]) + dnl dnl Reports declaration of global things that are done inside dnl a local environment, instead of using the appropriate dnl header AX_CFLAGS_GCC_OPTION([-Wnested-externs]) dnl + dnl Warn about constant strings that could pose portability issues + AX_CFLAGS_GCC_OPTION([-Woverlength-strings]) + dnl dnl Use of 'sizeof()' on inappropriate pointer types AX_CFLAGS_GCC_OPTION([-Wpointer-arith]) dnl @@ -129,6 +152,11 @@ AS_IF([test "x$debug" = "xyes"], dnl more difficult, so try to avoid it AX_CFLAGS_GCC_OPTION([-Wredundant-decls]) dnl + dnl clang, detect some misuses of sizeof. We also count in our code + dnl on the use of the macro 'wlength' which contains a check if the + dnl compiler support C11's static_assert + AX_CFLAGS_GCC_OPTION([-Wsizeof-array-argument]) + dnl dnl Prototype of function must be explicit, no deprecated K&R syntax dnl and no empty argument list which prevents compiler from doing dnl type checking when using the function @@ -152,6 +180,9 @@ AS_IF([test "x$debug" = "xyes"], dnl GCC provides a couple of checks to detect incorrect macro uses AX_CFLAGS_GCC_OPTION([-Wundef]) WM_CFLAGS_GCC_OPTION_UNUSEDMACROS + dnl + dnl clang reports stuff marked unused but which is actually used + AX_CFLAGS_GCC_OPTION([-Wused-but-marked-unused]) ], [dnl dnl When debug not enabled, we try to avoid some non-necessary dnl messages from the compiler http://repo.or.cz/w/wmaker-crm.git/commit/30e1fad92675be833e6c3f61e3191b393da3b7e7 commit 30e1fad92675be833e6c3f61e3191b393da3b7e7 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:23 2014 +0100 configure: add macro to check compiler flag '-Wstrict-prototype' Strict prototype are better for portability and to avoid bugs because it makes sure the compiler has the information to properly validate the arguments given when a function is called. This flag however need special care when checking for it, because the declaration for 'main' generated by autoconf cannot be a strict prototype so the detection would always see the flag as failing. This patch handles this by creating a dedicated macro for this detection which uses a good prototype because we're in a case where it is possible, so the detection will not always fail; it also makes sure to add the flag to CFLAG only at the end, to avoid falsely crashing any further test done in the configure script. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/configure.ac b/configure.ac index 05831a88..db34dd3a 100644 --- a/configure.ac +++ b/configure.ac @@ -129,6 +129,11 @@ AS_IF([test "x$debug" = "xyes"], dnl more difficult, so try to avoid it AX_CFLAGS_GCC_OPTION([-Wredundant-decls]) dnl + dnl Prototype of function must be explicit, no deprecated K&R syntax + dnl and no empty argument list which prevents compiler from doing + dnl type checking when using the function + WM_CFLAGS_GCC_OPTION_STRICTPROTO + dnl dnl Proper attributes helps the compiler to produce better code WM_CFLAGS_CHECK_FIRST([format attribute suggest], [-Wsuggest-attribute=format dnl new gcc syntax diff --git a/m4/wm_cflags_check.m4 b/m4/wm_cflags_check.m4 index 26745b69..b61b16d4 100644 --- a/m4/wm_cflags_check.m4 +++ b/m4/wm_cflags_check.m4 @@ -122,6 +122,44 @@ _ACEOF ]) +# WM_CFLAGS_GCC_OPTION_STRICTPROTO +# -------------------------------- +# +# Check if the compiler support '-Wstrict-prototypes'. This would be done +# traditionally using AX_CFLAGS_GCC_OPTION(...), but in the present case it +# always fail because the test program generated by autoconf always use a +# non-compliant prototype (this is needed for portability to avoid possible +# function declaration mismatch on 'main'). +# +# This macro works around this by providing a strict prototype for 'main' +# in this case because we are in a very known case. +AC_DEFUN([WM_CFLAGS_GCC_OPTION_STRICTPROTO], +[AC_CACHE_CHECK([CFLAGS for gcc -Wstrict-prototypes], [wm_cv_c_checks_compopt_Wstrict_prototypes], + [AC_LANG_COMPILER_REQUIRE()dnl + AC_LANG_PUSH([C]) + wm_save_CFLAGS="$CFLAGS" + CFLAGS="$wm_save_CFLAGS -pedantic -Werror -Wstrict-prototypes" + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([dnl +int +main(int argc, char **argv) +{ + /* to avoid failing on -Wunused-parameter */ + (void) argc; + (void) argv; + + return 0; +}])], + [wm_cv_c_checks_compopt_Wstrict_prototypes="-Wstrict-prototypes"], + [wm_cv_c_checks_compopt_Wstrict_prototypes="no"]) + CFLAGS="$wm_save_CFLAGS" + AC_LANG_POP([C]) ]) +# We cannot add this flag now to CFLAGS because it could break all further +# detections done by configure, the flag will be added at the end by the +# macro WM_CFLAGS_GCC_OPTION_POSTPONED +]) + + # WM_CFLAGS_GCC_OPTION_POSTPONED # ------------------------------ # @@ -133,7 +171,7 @@ _ACEOF AC_DEFUN_ONCE([WM_CFLAGS_GCC_OPTION_POSTPONED], [# WM_CFLAGS_GCC_OPTION_POSTPONED: add compiler flags at the end of the autoconf flow AS_IF([test "x$debug" = "xyes"], - [m4_foreach([arg_name], [[Wunused_macros]], + [m4_foreach([arg_name], [[Wstrict_prototypes], [Wunused_macros]], [AS_CASE([$wm_cv_c_checks_compopt_[]arg_name], [no*], [], [AS_IF([echo " $CFLAGS " | grep " $wm_cv_c_checks_compopt_[]arg_name " 2>&1 > /dev/null], http://repo.or.cz/w/wmaker-crm.git/commit/11fe8bd860af5a113af42d20caac525285cbf9a9 commit 11fe8bd860af5a113af42d20caac525285cbf9a9 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Mon Dec 8 22:42:22 2014 +0100 configure: rewrote the detection for -Wunused-macro This flag is always detected as unsupported because every time autoconf is generating a test program for any feature, it puts at the beginning of the test source all the '#define' that have been detected so far, which is what we expect normally. But for this option, as we cannot reasonably make a dummy use of every macro, the warning triggers and falsely gets autoconf into thinking it does not work. This patch creates a dedicated macro (WM_CFLAGS_GCC_OPTION_UNUSEDMACROS) for this flag, which works around the problem by having no '#define' in the test source. It also adds a new macro WM_CFLAGS_GCC_OPTION_POSTPONED because if the flag works, we still cannot add it to the compilation command because it could fail all further tests done, so the macro will add it to CFLAGS only at the end. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/configure.ac b/configure.ac index d7ccdaec..05831a88 100644 --- a/configure.ac +++ b/configure.ac @@ -146,7 +146,7 @@ AS_IF([test "x$debug" = "xyes"], dnl dnl GCC provides a couple of checks to detect incorrect macro uses AX_CFLAGS_GCC_OPTION([-Wundef]) - AX_CFLAGS_GCC_OPTION([-Wunused-macros]) + WM_CFLAGS_GCC_OPTION_UNUSEDMACROS ], [dnl dnl When debug not enabled, we try to avoid some non-necessary dnl messages from the compiler @@ -845,6 +845,12 @@ fi gl_LD_VERSION_SCRIPT + +dnl Add the post-poned compilation options +dnl ====================================== +WM_CFLAGS_GCC_OPTION_POSTPONED + + AC_OUTPUT(Makefile po/Makefile util/Makefile util/po/Makefile test/Makefile WINGs/Makefile WINGs/WINGs/Makefile WINGs/Documentation/Makefile WINGs/Examples/Makefile WINGs/Resources/Makefile WINGs/Tests/Makefile diff --git a/m4/wm_cflags_check.m4 b/m4/wm_cflags_check.m4 index d46511a1..26745b69 100644 --- a/m4/wm_cflags_check.m4 +++ b/m4/wm_cflags_check.m4 @@ -75,3 +75,71 @@ wm_fn_c_try_compile_cflag () AS_SET_STATUS([$wm_retval]) } ]) + + +# WM_CFLAGS_GCC_OPTION_UNUSEDMACROS +# --------------------------------- +# +# Check if the compiler support '-Wunused-macros'. This would be done +# traditionally using AX_CFLAGS_GCC_OPTION(...), but in the present case it +# always fail because the test program defines many macro (all the stuff +# detected so far) so the warning always trigger, the compilation then fail, +# and the option is then marked as never supported. +# +# This macro works around this by using a basic program without any #define +AC_DEFUN([WM_CFLAGS_GCC_OPTION_UNUSEDMACROS], +[AC_CACHE_CHECK([CFLAGS for gcc -Wunused-macros], [wm_cv_c_checks_compopt_Wunused_macros], + [AC_LANG_COMPILER_REQUIRE()dnl + AC_LANG_PUSH([C]) + wm_save_CFLAGS="$CFLAGS" + CFLAGS="$wm_save_CFLAGS -pedantic -Werror -Wunused-macros" + dnl Similar to AC_LANG_CONFTEST(C), except we do not include the 'confdefs.h' + dnl directly in the source to avoid an "unused macro" error, but we include + dnl it in the same way we will include the "config.h", so we get in the same + dnl condition as WindowMaker's source + cat <<_ACEOF >conftest.$ac_ext +@%:@include "confdefs.h" + +int +main(int argc, char **argv) +{ + /* to avoid failing on -Wunused-parameter */ + (void) argc; + (void) argv; + + return 0; +} +_ACEOF + AS_IF([ac_fn_[]_AC_LANG_ABBREV[]_try_compile "$LINENO"], + [wm_cv_c_checks_compopt_Wunused_macros="-Wunused-macros"], + [wm_cv_c_checks_compopt_Wunused_macros="no"]) + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="$wm_save_CFLAGS" + AC_LANG_POP([C]) ]) +# We cannot add this flag now to CFLAGS because it could break all further +# detections done by configure, the flag will be added at the end by the +# macro WM_CFLAGS_GCC_OPTION_POSTPONED +]) + + +# WM_CFLAGS_GCC_OPTION_POSTPONED +# ------------------------------ +# +# Some options cannot be added to the compilation command as soon as they have +# been detected because they can break the detection done in autoconf, because +# the template are cannot always be perfect. +# This macro takes care of making them effective, so it should be called just +# before AC_OUTPUT. +AC_DEFUN_ONCE([WM_CFLAGS_GCC_OPTION_POSTPONED], +[# WM_CFLAGS_GCC_OPTION_POSTPONED: add compiler flags at the end of the autoconf flow +AS_IF([test "x$debug" = "xyes"], + [m4_foreach([arg_name], [[Wunused_macros]], + [AS_CASE([$wm_cv_c_checks_compopt_[]arg_name], + [no*], [], + [AS_IF([echo " $CFLAGS " | grep " $wm_cv_c_checks_compopt_[]arg_name " 2>&1 > /dev/null], + [AC_MSG_WARN([option $wm_cv_c_checks_compopt_[]arg_name already present in $CFLAGS, not appended])], + [CFLAGS="$CFLAGS $wm_cv_c_checks_compopt_[]arg_name"])dnl + ]) + ])dnl + ])dnl +]) http://repo.or.cz/w/wmaker-crm.git/commit/fa4d50a0caa41c994128781b18ae48682cb64cd1 commit fa4d50a0caa41c994128781b18ae48682cb64cd1 Author: David Maciejak <david.macie...@gmail.com> Date: Mon Dec 8 10:10:31 2014 +0700 wrlib: Merge some duplicate code when allocating color This patch is adding a static function named allocateColor to merge some duplicate code. diff --git a/wrlib/context.c b/wrlib/context.c index 1b216a00..4c40c88e 100644 --- a/wrlib/context.c +++ b/wrlib/context.c @@ -142,13 +142,83 @@ static Bool setupStandardColormap(RContext * ctx, Atom property) return True; } -static Bool allocatePseudoColor(RContext * ctx) +static XColor *allocateColor(RContext *ctx, XColor *colors, int ncolors) { - XColor *colors; XColor avcolors[256]; int avncolors; - int i, ncolors, r, g, b; + int i, r, g, b; int retries; + + for (i = 0; i < ncolors; i++) { +#ifdef WRLIB_DEBUG + fprintf(stderr, "trying:%x,%x,%xn", colors[i].red, colors[i].green, colors[i].blue); +#endif + if (!XAllocColor(ctx->dpy, ctx->cmap, &(colors[i]))) { + colors[i].flags = 0; /* failed */ +#ifdef WRLIB_DEBUG + fprintf(stderr, "failed:%x,%x,%xn", colors[i].red, colors[i].green, colors[i].blue); +#endif + } else { + colors[i].flags = DoRed | DoGreen | DoBlue; +#ifdef WRLIB_DEBUG + fprintf(stderr, "success:%x,%x,%xn", colors[i].red, colors[i].green, colors[i].blue); +#endif + } + } + /* try to allocate close values for the colors that couldn't + * be allocated before */ + avncolors = (1 << ctx->depth > 256 ? 256 : 1 << ctx->depth); + for (i = 0; i < avncolors; i++) + avcolors[i].pixel = i; + + XQueryColors(ctx->dpy, ctx->cmap, avcolors, avncolors); + + for (i = 0; i < ncolors; i++) { + if (colors[i].flags == 0) { + int j; + unsigned long cdiff = 0xffffffff, diff; + unsigned long closest = 0; + + retries = 2; + + while (retries--) { + /* find closest color */ + for (j = 0; j < avncolors; j++) { + r = (colors[i].red - avcolors[i].red) >> 8; + g = (colors[i].green - avcolors[i].green) >> 8; + b = (colors[i].blue - avcolors[i].blue) >> 8; + diff = r * r + g * g + b * b; + if (diff < cdiff) { + cdiff = diff; + closest = j; + } + } + /* allocate closest color found */ +#ifdef WRLIB_DEBUG + fprintf(stderr, "best match:%x,%x,%x => %x,%x,%xn", + colors[i].red, colors[i].green, colors[i].blue, + avcolors[closest].red, avcolors[closest].green, avcolors[closest].blue); +#endif + colors[i].red = avcolors[closest].red; + colors[i].green = avcolors[closest].green; + colors[i].blue = avcolors[closest].blue; + if (XAllocColor(ctx->dpy, ctx->cmap, &colors[i])) { + colors[i].flags = DoRed | DoGreen | DoBlue; + break; /* succeeded, don't need to retry */ + } +#ifdef WRLIB_DEBUG + fputs("close color allocation failed. Retrying...n", stderr); +#endif + } + } + } + return colors; +} + +static Bool allocatePseudoColor(RContext *ctx) +{ + XColor *colors; + int i, ncolors, r, g, b; int cpc = ctx->attribs->colors_per_channel; ncolors = cpc * cpc * cpc; @@ -221,57 +291,7 @@ static Bool allocatePseudoColor(RContext * ctx) } } /* try to allocate the colors */ - for (i = 0; i < ncolors; i++) { - if (!XAllocColor(ctx->dpy, ctx->cmap, &(colors[i]))) { - colors[i].flags = 0; /* failed */ - } else { - colors[i].flags = DoRed | DoGreen | DoBlue; - } - } - /* try to allocate close values for the colors that couldn't - * be allocated before */ - avncolors = (1 << ctx->depth > 256 ? 256 : 1 << ctx->depth); - for (i = 0; i < avncolors; i++) - avcolors[i].pixel = i; - - XQueryColors(ctx->dpy, ctx->cmap, avcolors, avncolors); - - for (i = 0; i < ncolors; i++) { - if (colors[i].flags == 0) { - int j; - unsigned long cdiff = 0xffffffff, diff; - unsigned long closest = 0; - - retries = 2; - - while (retries--) { - /* find closest color */ - for (j = 0; j < avncolors; j++) { - r = (colors[i].red - avcolors[i].red) >> 8; - g = (colors[i].green - avcolors[i].green) >> 8; - b = (colors[i].blue - avcolors[i].blue) >> 8; - diff = r * r + g * g + b * b; - if (diff < cdiff) { - cdiff = diff; - closest = j; - } - } - /* allocate closest color found */ - colors[i].red = avcolors[closest].red; - colors[i].green = avcolors[closest].green; - colors[i].blue = avcolors[closest].blue; - if (XAllocColor(ctx->dpy, ctx->cmap, &colors[i])) { - colors[i].flags = DoRed | DoGreen | DoBlue; - break; /* succeeded, don't need to retry */ - } -#ifdef WRLIB_DEBUG - fputs("close color allocation failed. Retrying...n", stderr); -#endif - } - } - } - - ctx->colors = colors; + ctx->colors = allocateColor(ctx, colors, ncolors); ctx->ncolors = ncolors; /* fill the pixels shortcut array */ @@ -285,10 +305,7 @@ static Bool allocatePseudoColor(RContext * ctx) static XColor *allocateGrayScale(RContext * ctx) { XColor *colors; - XColor avcolors[256]; - int avncolors; - int i, ncolors, r, g, b; - int retries; + int i, ncolors; int cpc = ctx->attribs->colors_per_channel; ncolors = cpc * cpc * cpc; @@ -322,71 +339,9 @@ static XColor *allocateGrayScale(RContext * ctx) colors[i].blue = (i * 0xffff) / (ncolors - 1); colors[i].flags = DoRed | DoGreen | DoBlue; } - /* try to allocate the colors */ - for (i = 0; i < ncolors; i++) { -#ifdef WRLIB_DEBUG - fprintf(stderr, "trying:%x,%x,%xn", colors[i].red, colors[i].green, colors[i].blue); -#endif - if (!XAllocColor(ctx->dpy, ctx->cmap, &(colors[i]))) { - colors[i].flags = 0; /* failed */ -#ifdef WRLIB_DEBUG - fprintf(stderr, "failed:%x,%x,%xn", colors[i].red, colors[i].green, colors[i].blue); -#endif - } else { - colors[i].flags = DoRed | DoGreen | DoBlue; -#ifdef WRLIB_DEBUG - fprintf(stderr, "success:%x,%x,%xn", colors[i].red, colors[i].green, colors[i].blue); -#endif - } - } - /* try to allocate close values for the colors that couldn't - * be allocated before */ - avncolors = (1 << ctx->depth > 256 ? 256 : 1 << ctx->depth); - for (i = 0; i < avncolors; i++) - avcolors[i].pixel = i; - - XQueryColors(ctx->dpy, ctx->cmap, avcolors, avncolors); - - for (i = 0; i < ncolors; i++) { - if (colors[i].flags == 0) { - int j; - unsigned long cdiff = 0xffffffff, diff; - unsigned long closest = 0; - retries = 2; - - while (retries--) { - /* find closest color */ - for (j = 0; j < avncolors; j++) { - r = (colors[i].red - avcolors[i].red) >> 8; - g = (colors[i].green - avcolors[i].green) >> 8; - b = (colors[i].blue - avcolors[i].blue) >> 8; - diff = r * r + g * g + b * b; - if (diff < cdiff) { - cdiff = diff; - closest = j; - } - } - /* allocate closest color found */ -#ifdef WRLIB_DEBUG - fprintf(stderr, "best match:%x,%x,%x => %x,%x,%xn", - colors[i].red, colors[i].green, colors[i].blue, - avcolors[closest].red, avcolors[closest].green, avcolors[closest].blue); -#endif - colors[i].red = avcolors[closest].red; - colors[i].green = avcolors[closest].green; - colors[i].blue = avcolors[closest].blue; - if (XAllocColor(ctx->dpy, ctx->cmap, &colors[i])) { - colors[i].flags = DoRed | DoGreen | DoBlue; - break; /* succeeded, don't need to retry */ - } -#ifdef WRLIB_DEBUG - fputs("close color allocation failed. Retrying...n", stderr); -#endif - } - } - } - return colors; + /* try to allocate the colors */ + return allocateColor(ctx, colors, ncolors); } static Bool setupPseudoColorColormap(RContext * context) http://repo.or.cz/w/wmaker-crm.git/commit/0c938a3c0c3c343845b175fde419f45e0971403e commit 0c938a3c0c3c343845b175fde419f45e0971403e Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sun Dec 7 17:10:22 2014 +0100 WPrefs: fix icon used in the Opaque/Non-opaque Move setting Apparently, some pixels from the close button on the window image were missing from the Non-opaque image, they have been added in the XPM file which was then converted to TIFF with ImageMagick's command: convert -depth 8 -compress lzw xpm/nonopaque.xpm tiff/nonopaque.tiff to have a file similar to what was there before Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WPrefs.app/tiff/nonopaque.tiff b/WPrefs.app/tiff/nonopaque.tiff index 5d11957a..6cadf983 100644 Binary files a/WPrefs.app/tiff/nonopaque.tiff and b/WPrefs.app/tiff/nonopaque.tiff differ diff --git a/WPrefs.app/xpm/nonopaque.xpm b/WPrefs.app/xpm/nonopaque.xpm index 0ec95b3f..696a0b3a 100644 --- a/WPrefs.app/xpm/nonopaque.xpm +++ b/WPrefs.app/xpm/nonopaque.xpm @@ -117,9 +117,9 @@ static char * image_name[] = { " . O O O O O g i = y u > : = = = = h j q h u 1 O O O O O O < . . ", " . O O . O O 1 : 0 4 q w e = = = k + < h = % l z 1 O O O 5 w . . ", " . O O . O O . x * 8 9 c 7 7 v 7 @ b n m 7 7 7 M 6 . . . . c N . . . X . . . . . ", -" . O O O O O . q 4 b w e = 7 v B V C Z 7 7 7 7 7 7 A . . g S c n . . X . . . O . ", +" . O O O O O . q 4 b w e = 7 v B V C Z 7 7 7 7 7 7 A . . g S c n . . X . O . O . ", " . O O . O O O o z 9 : 7 = 7 v @ C n m 7 7 7 7 7 7 6 . . D 7 F n . . X . . O . . ", -" . O O . O O . O G . i = = 7 H V C Z 7 7 7 7 7 7 m n 8 @ S 7 7 J . . X . . . O . ", +" . O O . O O . O G . i = = 7 H V C Z 7 7 7 7 7 7 m n 8 @ S 7 7 J . . X . O . O . ", " . O O O O O . O p K S 7 7 7 L C n m 7 7 7 7 7 7 Z 8 V D 7 7 7 B n . X . . . . . ", " . O O . O O O O d > P I U Y w + T U U U U U U R E > W U U U U Q ! o o o o o o o ", " . . . . . . . . . n ~ m S @ b n m 7 7 7 7 7 7 Z C V B 7 7 7 7 7 @ . . . . . . . ", http://repo.or.cz/w/wmaker-crm.git/commit/be4849448f2039bbd47013ecb306df9e8d4e1581 commit be4849448f2039bbd47013ecb306df9e8d4e1581 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sun Dec 7 17:10:21 2014 +0100 WPrefs: fix memory leak when storing the list of texture in Appearence panel (Coverity #50112) As pointed by Coverity, the PLStrings created to store the information on the texture leak. This is due to the fact that they are created with a refCount of 1, then the PLArray in which they are placed increments that count, so at list destruction the count would return to 1 instead of 0, meaning the PLStrings won't be freed. This patch release the PLStrings once after adding them to the PLArray so the count will go back to 1, which means they will be properly freed when the PLArray will be released. Took opportunity to remove the call to WMRetainPropList on the titem-prop because it artificially increases the refCount but this is already done when adding to the PLArray. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WPrefs.app/Appearance.c b/WPrefs.app/Appearance.c index c8cbc75e..276933bb 100644 --- a/WPrefs.app/Appearance.c +++ b/WPrefs.app/Appearance.c @@ -2207,11 +2207,16 @@ static void prepareForClose(_Panel * panel) /* store list of textures */ for (i = 8; i < WMGetListNumberOfRows(panel->texLs); i++) { + WMPropList *pl_title, *pl_path; + item = WMGetListItem(panel->texLs, i); titem = (TextureListItem *) item->clientData; - texture = WMCreatePLArray(WMCreatePLString(titem->title), - WMRetainPropList(titem->prop), WMCreatePLString(titem->path), NULL); + pl_title = WMCreatePLString(titem->title); + pl_path = WMCreatePLString(titem->path); + texture = WMCreatePLArray(pl_title, titem->prop, pl_path, NULL); + WMReleasePropList(pl_title); + WMReleasePropList(pl_path); WMAddToPLArray(textureList, texture); } http://repo.or.cz/w/wmaker-crm.git/commit/af1bcde13a89d1a3e30c3a244a134d7933f040b9 commit af1bcde13a89d1a3e30c3a244a134d7933f040b9 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sun Dec 7 17:10:20 2014 +0100 checkpatch: fix bug in regular expression Recent version of perl seem to report incorrect stuff in regular expression and this seems to be fixed in the kernel reference file, so this patch brings the fix to our (older) version so we won't get that spurious message when running the script. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/checkpatch.pl b/checkpatch.pl index edbfa6b1..86155bdb 100755 --- a/checkpatch.pl +++ b/checkpatch.pl @@ -1911,7 +1911,7 @@ sub process { "please, no space before tabsn" . $herevet) && $fix) { while ($fixed[$linenr - 1] =~ - s/(^+.*) {8,8}+t/$1tt/) {} + s/(^+.*) {8,8}t/$1tt/) {} while ($fixed[$linenr - 1] =~ s/(^+.*) +t/$1t/) {} } http://repo.or.cz/w/wmaker-crm.git/commit/34d82e5462996c4912f29d7470c3fdea10785e6f commit 34d82e5462996c4912f29d7470c3fdea10785e6f Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sun Dec 7 17:10:19 2014 +0100 wmaker: replaced macro 'store_modifier' by an inline function, in X Modifier initialisation A macro can be a source of problems, because the compiler has no type on the arguments to make checks. Using an inline function allows to do those checks, meaning clearer error messages, it provides clear info in case of name collision, it is easier to maintain (no need for the hacky '' for multi-lines) and the scope of visibility can be controlled more easily (no need for #undef). The macro store_modifier had to face a slight change because its 2nd parameter is used as a reference, which is now clearly visible in the prototype of the function. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/Makefile.am b/src/Makefile.am index 8f1afbfa..78b0a75c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -140,7 +140,7 @@ misc.hack_nf.c: misc.c $(top_srcdir)/script/nested-func-to-macro.sh xmodifier.hack_nf.c: xmodifier.c $(top_srcdir)/script/nested-func-to-macro.sh $(AM_V_GEN)$(top_srcdir)/script/nested-func-to-macro.sh $(srcdir)/xmodifier.c -o $(builddir)/xmodifier.hack_nf.c - -f "modwarn" -f "modbarf" -f "check_modifier" + -f "modwarn" -f "modbarf" -f "check_modifier" -f "store_modifier" endif diff --git a/src/xmodifier.c b/src/xmodifier.c index bc525736..2fb246c8 100644 --- a/src/xmodifier.c +++ b/src/xmodifier.c @@ -120,27 +120,6 @@ static void x_reset_modifier_mapping(Display * display) int mode_bit = 0; XModifierKeymap *x_modifier_keymap = XGetModifierMapping(display); -#define store_modifier(name,old) - if (old && old != modifier_index) - wwarning ("%s (0x%x) generates both %s and %s, which is nonsensical.", - name, code, index_to_name (old), - index_to_name (modifier_index)); - if (modifier_index == ShiftMapIndex) { modbarf (name,"ModShift"); } - else if (modifier_index == LockMapIndex) { modbarf (name,"ModLock"); } - else if (modifier_index == ControlMapIndex) { modbarf (name,"ModControl"); } - else if (sym == XK_Mode_switch) - mode_bit = modifier_index; /* Mode_switch is special, see below... */ - else if (modifier_index == meta_bit && old != meta_bit) { - modwarn (name, meta_bit, "Meta"); - } else if (modifier_index == super_bit && old != super_bit) { - modwarn (name, super_bit, "Super"); - } else if (modifier_index == hyper_bit && old != hyper_bit) { - modwarn (name, hyper_bit, "Hyper"); - } else if (modifier_index == alt_bit && old != alt_bi t) { - modwarn (name, alt_bit, "Alt"); - } else - old = modifier_index; - mkpm = x_modifier_keymap->max_keypermod; for (modifier_index = 0; modifier_index < 8; modifier_index++) for (modifier_key = 0; modifier_key < mkpm; modifier_key++) { @@ -168,6 +147,32 @@ static void x_reset_modifier_mapping(Display * display) modbarf(key_name, index_to_name(modifier_index)); } + inline void store_modifier(const char *key_name, int *old_mod) + { + if (*old_mod && *old_mod != modifier_index) + wwarning("key %s (0x%x) generates both %s and %s, which is nonsensical", + key_name, code, index_to_name(*old_mod), index_to_name(modifier_index)); + if (modifier_index == ShiftMapIndex) { + modbarf(key_name, "ModShift"); + } else if (modifier_index == LockMapIndex) { + modbarf(key_name, "ModLock"); + } else if (modifier_index == ControlMapIndex) { + modbarf(key_name, "ModControl"); + } else if (sym == XK_Mode_switch) { + mode_bit = modifier_index; /* Mode_switch is special, see below... */ + } else if (modifier_index == meta_bit && *old_mod != meta_bit) { + modwarn(key_name, meta_bit, "Meta"); + } else if (modifier_index == super_bit && *old_mod != super_bit) { + modwarn(key_name, super_bit, "Super"); + } else if (modifier_index == hyper_bit && *old_mod != hyper_bit) { + modwarn(key_name, hyper_bit, "Hyper"); + } else if (modifier_index == alt_bit && *old_mod != alt_bit) { + modwarn(key_name, alt_bit, "Alt"); + } else { + *(old_mod) = modifier_index; + } + } + code = x_modifier_keymap->modifiermap[modifier_index * mkpm + modifier_key]; sym = (code ? XkbKeycodeToKeysym(display, code, 0, column) : NoSymbol); @@ -177,31 +182,31 @@ static void x_reset_modifier_mapping(Display * display) switch (sym) { case XK_Mode_switch: - store_modifier("Mode_switch", mode_bit); + store_modifier("Mode_switch", &mode_bit); break; case XK_Meta_L: - store_modifier("Meta_L", meta_bit); + store_modifier("Meta_L", &meta_bit); break; case XK_Meta_R: - store_modifier("Meta_R", meta_bit); + store_modifier("Meta_R", &meta_bit); break; case XK_Super_L: - store_modifier("Super_L", super_bit); + store_modifier("Super_L", &super_bit); break; case XK_Super_R: - store_modifier("Super_R", super_bit); + store_modifier("Super_R", &super_bit); break; case XK_Hyper_L: - store_modifier("Hyper_L", hyper_bit); + store_modifier("Hyper_L", &hyper_bit); break; case XK_Hyper_R: - store_modifier("Hyper_R", hyper_bit); + store_modifier("Hyper_R", &hyper_bit); break; case XK_Alt_L: - store_modifier("Alt_L", alt_bit); + store_modifier("Alt_L", &alt_bit); break; case XK_Alt_R: - store_modifier("Alt_R", alt_bit); + store_modifier("Alt_R", &alt_bit); break; case XK_Control_L: check_modifier("Control_L", ControlMask); http://repo.or.cz/w/wmaker-crm.git/commit/de00154fa171512532e44c706b6ed54e253c48cf commit de00154fa171512532e44c706b6ed54e253c48cf Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sun Dec 7 17:10:18 2014 +0100 wmaker: replaced macro by an inline function, in X Modifier initialisation A macro can be a source of problems, because the compiler has no type on the arguments to make checks. Using an inline function allows to do those checks, meaning clearer error messages, it provides clear info in case of name collision, it is easier to maintain (no need for the hacky '' for multi-lines) and the scope of visibility can be controlled more easily (no need for #undef). Took opportunity to change a 0 to the constant NoSymbol which is the name defined by X for this case and another to NULL which is the right way to set a null pointer in C. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/Makefile.am b/src/Makefile.am index 76fc18f9..8f1afbfa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -90,7 +90,6 @@ wmaker_SOURCES = xinerama.h xinerama.c xmodifier.h - xmodifier.c xutil.c xutil.h wconfig.h @@ -125,9 +124,11 @@ wmaker_SOURCES += osdep_stub.c endif if USE_NESTED_FUNC -wmaker_SOURCES += misc.c +wmaker_SOURCES += misc.c + xmodifier.c else -nodist_wmaker_SOURCES = misc.hack_nf.c +nodist_wmaker_SOURCES = misc.hack_nf.c + xmodifier.hack_nf.c CLEANFILES = $(nodist_wmaker_SOURCES) @@ -135,6 +136,11 @@ misc.hack_nf.c: misc.c $(top_srcdir)/script/nested-func-to-macro.sh $(AM_V_GEN)$(top_srcdir)/script/nested-func-to-macro.sh $(srcdir)/misc.c -o $(builddir)/misc.hack_nf.c -f "append_string" -f "append_modifier" + +xmodifier.hack_nf.c: xmodifier.c $(top_srcdir)/script/nested-func-to-macro.sh + $(AM_V_GEN)$(top_srcdir)/script/nested-func-to-macro.sh + $(srcdir)/xmodifier.c -o $(builddir)/xmodifier.hack_nf.c + -f "modwarn" -f "modbarf" -f "check_modifier" endif diff --git a/src/xmodifier.c b/src/xmodifier.c index 641a8e35..bc525736 100644 --- a/src/xmodifier.c +++ b/src/xmodifier.c @@ -120,51 +120,61 @@ static void x_reset_modifier_mapping(Display * display) int mode_bit = 0; XModifierKeymap *x_modifier_keymap = XGetModifierMapping(display); -#define modwarn(name,old,other) - wwarning ("%s (0x%x) generates %s, which is generated by %s.", - name, code, index_to_name (old), other) - -#define modbarf(name,other) - wwarning ("%s (0x%x) generates %s, which is nonsensical.", - name, code, other) - -#define check_modifier(name,mask) - if ((1<<modifier_index) != mask) - wwarning ("%s (0x%x) generates %s, which is nonsensical.", - name, code, index_to_name (modifier_index)) - #define store_modifier(name,old) if (old && old != modifier_index) wwarning ("%s (0x%x) generates both %s and %s, which is nonsensical.", name, code, index_to_name (old), index_to_name (modifier_index)); - if (modifier_index == ShiftMapIndex) modbarf (name,"ModShift"); - else if (modifier_index == LockMapIndex) modbarf (name,"ModLock"); - else if (modifier_index == ControlMapIndex) modbarf (name,"ModControl"); + if (modifier_index == ShiftMapIndex) { modbarf (name,"ModShift"); } + else if (modifier_index == LockMapIndex) { modbarf (name,"ModLock"); } + else if (modifier_index == ControlMapIndex) { modbarf (name,"ModControl"); } else if (sym == XK_Mode_switch) mode_bit = modifier_index; /* Mode_switch is special, see below... */ - else if (modifier_index == meta_bit && old != meta_bit) + else if (modifier_index == meta_bit && old != meta_bit) { modwarn (name, meta_bit, "Meta"); - else if (modifier_index == super_bit && old != super_bit) + } else if (modifier_index == super_bit && old != super_bit) { modwarn (name, super_bit, "Super"); - else if (modifier_index == hyper_bit && old != hyper_bit) + } else if (modifier_index == hyper_bit && old != hyper_bit) { modwarn (name, hyper_bit, "Hyper"); - else if (modifier_index == alt_bit && old != alt_bit) + } else if (modifier_index == alt_bit && old != alt_bit) { modwarn (name, alt_bit, "Alt"); - else + } else old = modifier_index; mkpm = x_modifier_keymap->max_keypermod; for (modifier_index = 0; modifier_index < 8; modifier_index++) for (modifier_key = 0; modifier_key < mkpm; modifier_key++) { KeySym last_sym = 0; + for (column = 0; column < 4; column += 2) { - KeyCode code = x_modifier_keymap->modifiermap[modifier_index * mkpm - + modifier_key]; - KeySym sym = (code ? XkbKeycodeToKeysym(display, code, 0, column) : 0); + KeyCode code; + KeySym sym; + + inline void modwarn(const char *key_name, int old_mod, const char *other_key) + { + wwarning("key %s (0x%x) generates %s, which is generated by %s", + key_name, code, index_to_name(old_mod), other_key); + } + + inline void modbarf(const char *key_name, const char *other_mod) + { + wwarning("key %s (0x%x) generates %s, which is nonsensical", + key_name, code, other_mod); + } + + inline void check_modifier(const char *key_name, int mask) + { + if ((1 << modifier_index) != mask) + modbarf(key_name, index_to_name(modifier_index)); + } + + code = x_modifier_keymap->modifiermap[modifier_index * mkpm + modifier_key]; + sym = (code ? XkbKeycodeToKeysym(display, code, 0, column) : NoSymbol); + if (sym == last_sym) continue; last_sym = sym; + switch (sym) { case XK_Mode_switch: store_modifier("Mode_switch", mode_bit); @@ -220,10 +230,6 @@ static void x_reset_modifier_mapping(Display * display) } } } -#undef store_modifier -#undef check_modifier -#undef modwarn -#undef modbarf /* If there was no Meta key, then try using the Alt key instead. If there is both a Meta key and an Alt key, then the Alt key @@ -238,7 +244,8 @@ static void x_reset_modifier_mapping(Display * display) not interpret it as Mode_switch; and interpreting it as both would be totally wrong. */ if (mode_bit) { - const char *warn = 0; + const char *warn = NULL; + if (mode_bit == meta_bit) warn = "Meta", meta_bit = 0; else if (mode_bit == hyper_bit) http://repo.or.cz/w/wmaker-crm.git/commit/d9438e65efe4e80f5c9e825a7975bd4fded4f868 commit d9438e65efe4e80f5c9e825a7975bd4fded4f868 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sun Dec 7 17:10:17 2014 +0100 makefile: make silent rule work also for generated files A few files are generated using custom commands, which so far did not follow the silent rule as the compilation stuff. This patch adds the needed stuff so they will also be silent if the user wants so, leading to a cleaner build process where warning/error messages are more visible. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WindowMaker/Defaults/Makefile.am b/WindowMaker/Defaults/Makefile.am index 33975eab..344c0bf2 100644 --- a/WindowMaker/Defaults/Makefile.am +++ b/WindowMaker/Defaults/Makefile.am @@ -10,22 +10,18 @@ EXTRA_DIST = WMGLOBAL WMWindowAttributes.in WindowMaker.in WMState.in CLEANFILES = WMWindowAttributes WindowMaker WMState WMRootMenu WMWindowAttributes: $(srcdir)/WMWindowAttributes.in - -rm -f WMWindowAttributes - sed -e "s:#extension#:@ICONEXT@:" - $(srcdir)/WMWindowAttributes.in > WMWindowAttributes + $(AM_V_GEN)sed -e "s:#extension#:@ICONEXT@:" + $(srcdir)/WMWindowAttributes.in > WMWindowAttributes ; chmod 644 WMWindowAttributes WindowMaker: $(srcdir)/WindowMaker.in - -rm -f WindowMaker - sed -e "s:#pkgdatadir#:$(pkgdatadir):" $(srcdir)/WindowMaker.in - > WindowMaker + $(AM_V_GEN)sed -e "s:#pkgdatadir#:$(pkgdatadir):" $(srcdir)/WindowMaker.in + > WindowMaker ; chmod 644 WindowMaker WMState: $(srcdir)/WMState.in - -rm -f WMState - sed -e "s:#wprefs#:$(wpexecbindir)/WPrefs:" $(srcdir)/WMState.in > WMState + $(AM_V_GEN)sed -e "s:#wprefs#:$(wpexecbindir)/WPrefs:" $(srcdir)/WMState.in > WMState ; chmod 644 WMState WMRootMenu: $(srcdir)/../plmenu - -cp -f $(srcdir)/../plmenu WMRootMenu - + $(AM_V_GEN)cp -f $(srcdir)/../plmenu WMRootMenu diff --git a/WindowMaker/IconSets/Makefile.am b/WindowMaker/IconSets/Makefile.am index ec5ca124..ed4317da 100644 --- a/WindowMaker/IconSets/Makefile.am +++ b/WindowMaker/IconSets/Makefile.am @@ -8,10 +8,7 @@ EXTRA_DIST = CLEANFILES = Default.iconset Default.iconset: $(top_builddir)/WindowMaker/Defaults/WMWindowAttributes - -rm -f Default.iconset - echo '{' > Default.iconset - grep Icon $(top_builddir)/WindowMaker/Defaults/WMWindowAttributes >> Default.iconset - echo '}' >> Default.iconset + $(AM_V_GEN)echo '{' > Default.iconset ; + grep Icon $(top_builddir)/WindowMaker/Defaults/WMWindowAttributes >> Default.iconset ; + echo '}' >> Default.iconset ; chmod 644 Default.iconset - - diff --git a/src/Makefile.am b/src/Makefile.am index a7aa1d09..76fc18f9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -132,7 +132,7 @@ nodist_wmaker_SOURCES = misc.hack_nf.c CLEANFILES = $(nodist_wmaker_SOURCES) misc.hack_nf.c: misc.c $(top_srcdir)/script/nested-func-to-macro.sh - $(top_srcdir)/script/nested-func-to-macro.sh + $(AM_V_GEN)$(top_srcdir)/script/nested-func-to-macro.sh $(srcdir)/misc.c -o $(builddir)/misc.hack_nf.c -f "append_string" -f "append_modifier" endif diff --git a/util/Makefile.am b/util/Makefile.am index b5c9d042..cf07fd5f 100644 --- a/util/Makefile.am +++ b/util/Makefile.am @@ -80,12 +80,9 @@ wmiv_SOURCES = wmiv.c wmiv.h CLEANFILES = wmaker.inst wmaker.inst: $(srcdir)/wmaker.inst.in ./Makefile - -rm -f wmaker.inst - sed -e "s|#pkgdatadir#|$(pkgdatadir)|" + $(AM_V_GEN)sed -e "s|#pkgdatadir#|$(pkgdatadir)|" -e "s|#sysconfdir#|$(sysconfdir)/WindowMaker|" -e "s|#version#|$(VERSION)|" -e "s|#bindir#|$(bindir)|" - $(srcdir)/wmaker.inst.in >wmaker.inst - + $(srcdir)/wmaker.inst.in >wmaker.inst ; chmod 755 wmaker.inst - http://repo.or.cz/w/wmaker-crm.git/commit/4bed8d14d77e5c66a5f635cc730c3458a1a292a5 commit 4bed8d14d77e5c66a5f635cc730c3458a1a292a5 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sun Dec 7 17:10:16 2014 +0100 wmaker: remove unnecessary null pointer checks in handle_event of wsmap The function is called only if wsmap is not null, and the function is not modifying its value so it won't become null. Removed the checks to keep the code as simple as possible for maintainability. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/wsmap.c b/src/wsmap.c index ee667f9f..bc7a2ff1 100755 --- a/src/wsmap.c +++ b/src/wsmap.c @@ -487,8 +487,6 @@ static void handle_event(WWorkspaceMap *wsmap, W_WorkspaceMap *wsmap_array) WMMaskEvent(dpy, KeyPressMask | KeyReleaseMask | ExposureMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask, &ev); - if (!wsmap) - break; modifiers = ev.xkey.state & w_global.shortcut.modifiers_mask; switch (ev.type) { @@ -539,8 +537,7 @@ static void handle_event(WWorkspaceMap *wsmap, W_WorkspaceMap *wsmap_array) XUngrabPointer(dpy, CurrentTime); XUngrabKeyboard(dpy, CurrentTime); - if (wsmap) - workspace_map_destroy(wsmap); + workspace_map_destroy(wsmap); } static WWorkspaceMap *init_workspace_map(WScreen *scr, W_WorkspaceMap *wsmap_array) http://repo.or.cz/w/wmaker-crm.git/commit/ad84a2dc8f59e05502928c8d5d4ab5d92e22321b commit ad84a2dc8f59e05502928c8d5d4ab5d92e22321b Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sun Dec 7 17:10:15 2014 +0100 wmaker: moved the variable 'process_workspacemap_event' to the global namespace The definition in the local header was not correct; it works because gcc is tolerant to this kind of errors but other compilers are not. The declaration was creating a local variable in each file that call header, and because it is not static gcc's linker will merge them. Other compilers will at best complain for duplicate symbol, and at worst silently duplicate the variable so it will not work as expected. The variable is now moved to the existing structure meant for global variables, so now the code is really clear about using a global variable instead of a static/local one. Took opportunity to add some missing 'static' attributes to some variables. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/WindowMaker.h b/src/WindowMaker.h index ce0a86c9..2d9ed1af 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -522,6 +522,13 @@ extern struct wmaker_global_variables { */ Bool ignore_workspace_change; + /* + * Process WorkspaceMap Event: + * this variable is set when the Workspace Map window is being displayed, + * it is mainly used to avoid re-opening another one at the same time + */ + Bool process_workspacemap_event; + #ifdef HAVE_INOTIFY struct { int fd_event_queue; /* Inotify's queue file descriptor */ diff --git a/src/workspace.c b/src/workspace.c index 165e3011..9a820574 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -476,7 +476,7 @@ void wWorkspaceForceChange(WScreen * scr, int workspace) if (workspace >= MAX_WORKSPACES || workspace < 0) return; - if (!wPreferences.disable_workspace_pager && !process_workspacemap_event) + if (!wPreferences.disable_workspace_pager && !w_global.process_workspacemap_event) wWorkspaceMapUpdate(scr); SendHelperMessage(scr, 'C', workspace + 1, NULL); diff --git a/src/wsmap.c b/src/wsmap.c index 244df94b..ee667f9f 100755 --- a/src/wsmap.c +++ b/src/wsmap.c @@ -46,9 +46,9 @@ static const int mini_workspace_per_line = 5; * will be 0 for workspaces number 0 to 9 * 1 for workspaces number 10 -> 19 */ -int wsmap_bulk_index; -WMPixmap *frame_bg_focused; -WMPixmap *frame_bg_unfocused; +static int wsmap_bulk_index; +static WMPixmap *frame_bg_focused; +static WMPixmap *frame_bg_unfocused; typedef struct { WScreen *scr; @@ -147,7 +147,7 @@ static void selected_workspace_callback(WMWidget *w, void *data) int workspace_id = atoi(WMGetButtonText(click_button)); wWorkspaceChange(wsmap->scr, workspace_id); - process_workspacemap_event = False; + w_global.process_workspacemap_event = False; } } @@ -482,8 +482,8 @@ static void handle_event(WWorkspaceMap *wsmap, W_WorkspaceMap *wsmap_array) ButtonMotionMask | ButtonReleaseMask | ButtonPressMask, GrabModeAsync, GrabModeAsync, WMWidgetXID(wsmap->win), None, CurrentTime); - process_workspacemap_event = True; - while (process_workspacemap_event) { + w_global.process_workspacemap_event = True; + while (w_global.process_workspacemap_event) { WMMaskEvent(dpy, KeyPressMask | KeyReleaseMask | ExposureMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask, &ev); @@ -496,7 +496,7 @@ static void handle_event(WWorkspaceMap *wsmap, W_WorkspaceMap *wsmap_array) if (ev.xkey.keycode == escKey || (wKeyBindings[WKBD_WORKSPACEMAP].keycode != 0 && wKeyBindings[WKBD_WORKSPACEMAP].keycode == ev.xkey.keycode && wKeyBindings[WKBD_WORKSPACEMAP].modifier == modifiers)) { - process_workspacemap_event = False; + w_global.process_workspacemap_event = False; } else { KeySym ks; int bulk_id; diff --git a/src/wsmap.h b/src/wsmap.h index 2133bd52..27a45cc4 100644 --- a/src/wsmap.h +++ b/src/wsmap.h @@ -20,8 +20,6 @@ #ifndef WSMAP_H #define WSMAP_H -Bool process_workspacemap_event; - void wWorkspaceMapUpdate(WScreen *scr); void StartWorkspaceMap(WScreen *scr); http://repo.or.cz/w/wmaker-crm.git/commit/41745d98d4bffac57787d6f9105d2c5819f73e79 commit 41745d98d4bffac57787d6f9105d2c5819f73e79 Author: David Maciejak <david.macie...@gmail.com> Date: Thu Dec 4 13:37:36 2014 +0700 wmaker: add core workspace pager functions This patch is adding the core code needed to run the workspace pager. Currently when called, a new frame presenting mini workspace images are displayed at the bottom of the screen above other windows. When clicking on one of the miniatures, the workspace is switched and the frame is closed. Drawbacks: a screenshot of the workspace is used for the miniatures. This screenshot is taken only when a workspace switched event occurs. First, it means that the workspace switching process can be longer than usual. Secondly, updated minitatures can only be available when the workspace is "opened" (cause windows have to be mapped to be able to be copied). So when wmaker is (re)started or when for example a window is moved to another workspace the corresponding miniature is NOT updated. (I did not find a clean and easy way to do so, feel free to share if you have some ideas) diff --git a/src/Makefile.am b/src/Makefile.am index 6c20e63a..a7aa1d09 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -107,7 +107,9 @@ wmaker_SOURCES = wmspec.h wmspec.c workspace.c - workspace.h + workspace.h + wsmap.c + wsmap.h if WM_OSDEP_BSD wmaker_SOURCES += osdep_bsd.c diff --git a/src/event.c b/src/event.c index 9a8a3e3f..6b2e0db0 100644 --- a/src/event.c +++ b/src/event.c @@ -77,6 +77,7 @@ #include "event.h" #include "winmenu.h" #include "switchmenu.h" +#include "wsmap.h" #define MOD_MASK wPreferences.modifier_mask @@ -1606,6 +1607,12 @@ static void handleKeyPress(XEvent * event) wSelectWindow(wwin, !wwin->flags.selected); } break; + + case WKBD_WORKSPACEMAP: + if (!wPreferences.disable_workspace_pager) + StartWorkspaceMap(scr); + break; + case WKBD_FOCUSNEXT: StartWindozeCycle(wwin, event, True, False); break; diff --git a/src/misc.c b/src/misc.c index 3b9299d4..a12a97de 100644 --- a/src/misc.c +++ b/src/misc.c @@ -245,7 +245,7 @@ void SlideWindows(Window *wins[], int n, int from_x, int from_y, int to_x, int t if (slide_delay > 0) { wusleep(slide_delay * 1000L); } else { - wusleep(10); + wusleep(1000L); } if (time(NULL) - time0 > MAX_ANIMATION_TIME) break; diff --git a/src/workspace.c b/src/workspace.c index 107db2aa..165e3011 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -49,6 +49,7 @@ #include "wmspec.h" #include "xinerama.h" #include "event.h" +#include "wsmap.h" #define MC_NEW 0 #define MC_DESTROY_LAST 1 @@ -160,6 +161,8 @@ Bool wWorkspaceDelete(WScreen * scr, int workspace) } else { if (scr->workspaces[i]->name) wfree(scr->workspaces[i]->name); + if (scr->workspaces[i]->map) + RReleaseImage(scr->workspaces[i]->map); wfree(scr->workspaces[i]); } } @@ -473,6 +476,9 @@ void wWorkspaceForceChange(WScreen * scr, int workspace) if (workspace >= MAX_WORKSPACES || workspace < 0) return; + if (!wPreferences.disable_workspace_pager && !process_workspacemap_event) + wWorkspaceMapUpdate(scr); + SendHelperMessage(scr, 'C', workspace + 1, NULL); if (workspace > scr->workspace_count - 1) diff --git a/src/workspace.h b/src/workspace.h index 69d1b187..0c93a2fc 100644 --- a/src/workspace.h +++ b/src/workspace.h @@ -27,6 +27,7 @@ typedef struct WWorkspace { char *name; struct WDock *clip; + RImage *map; } WWorkspace; void wWorkspaceMake(WScreen *scr, int count); diff --git a/src/wsmap.c b/src/wsmap.c new file mode 100755 index 00000000..244df94b --- /dev/null +++ b/src/wsmap.c @@ -0,0 +1,567 @@ +/* wsmap.c - worskpace map + * + * Window Maker window manager + * + * Copyright (c) 2014 Window Maker Team - David Maciejak + * + * 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. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "wconfig.h" + +#include <stdlib.h> +#include <stdio.h> + +#ifdef USE_XSHAPE +#include <X11/extensions/shape.h> +#endif + +#include "screen.h" +#include "window.h" +#include "misc.h" +#include "workspace.h" +#include "wsmap.h" + +#include "WINGs/WINGsP.h" + + +static const int WORKSPACE_MAP_RATIO = 10; +static const int WORKSPACE_SEPARATOR_WIDTH = 12; +static const int mini_workspace_per_line = 5; + +/* + * Used to store the index of the tenth displayed mini workspace + * will be 0 for workspaces number 0 to 9 + * 1 for workspaces number 10 -> 19 + */ +int wsmap_bulk_index; +WMPixmap *frame_bg_focused; +WMPixmap *frame_bg_unfocused; + +typedef struct { + WScreen *scr; + WMWindow *win; + int xcount, ycount; + int wswidth, wsheight; + int mini_workspace_width, mini_workspace_height; + int edge; + int border_width; +} WWorkspaceMap; + +typedef struct { + WMButton *workspace_img_button; + WMLabel *workspace_label; +} W_WorkspaceMap; + +void wWorkspaceMapUpdate(WScreen *scr) +{ + XImage *pimg; + + pimg = XGetImage(dpy, scr->root_win, 0, 0, + scr->scr_width, scr->scr_height, + AllPlanes, ZPixmap); + if (pimg) { + RImage *apercu; + + apercu = RCreateImageFromXImage(scr->rcontext, pimg, NULL); + XDestroyImage(pimg); + + if (apercu) { + RImage *tmp = scr->workspaces[scr->current_workspace]->map; + + if (tmp) + RReleaseImage(tmp); + + scr->workspaces[scr->current_workspace]->map = + RSmoothScaleImage(apercu, + scr->scr_width / WORKSPACE_MAP_RATIO, + scr->scr_height / WORKSPACE_MAP_RATIO); + RReleaseImage(apercu); + } + } +} + +static void workspace_map_slide(WWorkspaceMap *wsmap) +{ + if (wsmap->edge == WD_TOP) + SlideWindow(WMWidgetXID(wsmap->win), 0, -1 * wsmap->wsheight, wsmap->xcount, wsmap->ycount); + else + SlideWindow(WMWidgetXID(wsmap->win), 0, wsmap->scr->scr_height, wsmap->xcount, wsmap->ycount); +} + +static void workspace_map_unslide(WWorkspaceMap *wsmap) +{ + if (wsmap->edge == WD_TOP) + SlideWindow(WMWidgetXID(wsmap->win), wsmap->xcount, wsmap->ycount, 0, -1 * wsmap->wsheight); + else + SlideWindow(WMWidgetXID(wsmap->win), wsmap->xcount, wsmap->ycount, 0, wsmap->scr->scr_height); +} + +static void workspace_map_destroy(WWorkspaceMap *wsmap) +{ + workspace_map_unslide(wsmap); + WMUnmapWidget(wsmap->win); + + if (wsmap->win) { + Window info_win = wsmap->scr->info_window; + XEvent ev; + + ev.xclient.type = ClientMessage; + ev.xclient.message_type = w_global.atom.wm.ignore_focus_events; + ev.xclient.format = 32; + ev.xclient.data.l[0] = True; + + XSendEvent(dpy, info_win, True, EnterWindowMask, &ev); + WMUnmapWidget(wsmap->win); + + ev.xclient.data.l[0] = False; + XSendEvent(dpy, info_win, True, EnterWindowMask, &ev); + WMDestroyWidget(wsmap->win); + + if (frame_bg_focused) + WMReleasePixmap(frame_bg_focused); + if (frame_bg_unfocused) + WMReleasePixmap(frame_bg_unfocused); + } + wfree(wsmap); +} + +static void selected_workspace_callback(WMWidget *w, void *data) +{ + WWorkspaceMap *wsmap = (WWorkspaceMap *) data; + WMButton *click_button = w; + + if (w && wsmap) { + int workspace_id = atoi(WMGetButtonText(click_button)); + + wWorkspaceChange(wsmap->scr, workspace_id); + process_workspacemap_event = False; + } +} + +static void set_workspace_map_background_image(WWorkspaceMap *wsmap) +{ + Pixmap pixmap, mask; + + if (wPreferences.wsmbackTexture->any.type == WTEX_PIXMAP) { + RImage *tmp = wTextureRenderImage(wPreferences.wsmbackTexture, wsmap->wswidth, wsmap->wsheight, WREL_FLAT); + + if (!tmp) + return; + + RConvertImageMask(wsmap->scr->rcontext, tmp, &pixmap, &mask, 250); + RReleaseImage(tmp); + + if (!pixmap) + return; + + XSetWindowBackgroundPixmap(dpy, WMWidgetXID(wsmap->win), pixmap); + +#ifdef USE_XSHAPE + if (mask && w_global.xext.shape.supported) + XShapeCombineMask(dpy, WMWidgetXID(wsmap->win), ShapeBounding, 0, 0, mask, ShapeSet); +#endif + + if (pixmap) + XFreePixmap(dpy, pixmap); + if (mask) + XFreePixmap(dpy, mask); + } +} + +static void workspace_map_show(WWorkspaceMap *wsmap) +{ + WMMapSubwidgets(wsmap->win); + WMMapWidget(wsmap->win); + workspace_map_slide(wsmap); +} + +static WMPixmap *get_frame_background_color(WWorkspaceMap *wsmap, unsigned int width, unsigned int height, int type) +{ + RImage *img; + WMPixmap *pix; + + if (!wsmap->scr->window_title_texture[type]) + return NULL; + + img = wTextureRenderImage(wsmap->scr->window_title_texture[type], width, height, WREL_FLAT); + if (!img) + return NULL; + + pix = WMCreatePixmapFromRImage(wsmap->scr->wmscreen, img, 128); + RReleaseImage(img); + + return pix; +} + +static void workspace_map_realize(WWorkspaceMap *wsmap, WMFrame *frame_border, W_WorkspaceMap *wsmap_array) +{ + int i, mini_workspace_cnt, general_index; + WMPixmap *frame_border_pixmap; + WMSize label_size; + + WMRealizeWidget(wsmap->win); + set_workspace_map_background_image(wsmap); + + frame_border_pixmap = get_frame_background_color(wsmap, wsmap->wswidth, wsmap->border_width, WS_FOCUSED); + WMSetWidgetBackgroundPixmap(frame_border, frame_border_pixmap); + WMReleasePixmap(frame_border_pixmap); + + label_size = WMGetViewSize(W_VIEW(wsmap_array[0].workspace_label)); + frame_bg_focused = get_frame_background_color(wsmap, label_size.width, label_size.height, WS_FOCUSED); + frame_bg_unfocused = get_frame_background_color(wsmap, label_size.width, label_size.height, WS_UNFOCUSED); + + mini_workspace_cnt = (wsmap->scr->workspace_count <= 2 * mini_workspace_per_line) ? wsmap->scr->workspace_count : 2 * mini_workspace_per_line; + for (i = 0; i < mini_workspace_cnt; i++) { + general_index = i + wsmap_bulk_index * 2 * mini_workspace_per_line; + if (general_index == wsmap->scr->current_workspace) { + WMSetWidgetBackgroundPixmap(wsmap_array[i].workspace_label, frame_bg_focused); + WMSetLabelTextColor(wsmap_array[i].workspace_label, wsmap->scr->window_title_color[WS_FOCUSED]); + } else { + WMSetWidgetBackgroundPixmap(wsmap_array[i].workspace_label, frame_bg_unfocused); + WMSetLabelTextColor(wsmap_array[i].workspace_label, wsmap->scr->window_title_color[WS_UNFOCUSED]); + } + } +} + +static WMPixmap *enlight_workspace(WScreen *scr, RImage *mini_wkspace_map) +{ + RImage *tmp = RCloneImage(mini_wkspace_map); + RColor color; + WMPixmap *icon; + + color.red = color.green = color.blue = 0; + color.alpha = 160; + RLightImage(tmp, &color); + icon = WMCreatePixmapFromRImage(scr->wmscreen, tmp, 128); + RReleaseImage(tmp); + + return icon; +} + +static WMPixmap *dummy_background_pixmap(WWorkspaceMap *wsmap) +{ + RImage *img; + WMPixmap *icon; + + img = RCreateImage(wsmap->wswidth, wsmap->wsheight, 0); + + if (!img) + return NULL; + + /* the workspace texture is not saved anywhere, so just using the default unfocus color */ + if (wsmap->scr->window_title_texture[WS_UNFOCUSED]) { + RColor frame_bg_color; + + frame_bg_color.red = wsmap->scr->window_title_texture[WS_UNFOCUSED]->solid.normal.red; + frame_bg_color.green = wsmap->scr->window_title_texture[WS_UNFOCUSED]->solid.normal.green; + frame_bg_color.blue = wsmap->scr->window_title_texture[WS_UNFOCUSED]->solid.normal.blue; + RFillImage(img, &frame_bg_color); + } + + icon = WMCreatePixmapFromRImage(wsmap->scr->wmscreen, img, 128); + RReleaseImage(img); + + return icon; +} + +static void show_mini_workspace(WWorkspaceMap *wsmap, W_WorkspaceMap *wsmap_array, int max_mini_workspace) +{ + int index, space_width; + int border_width_adjustement = (wsmap->edge == WD_TOP) ? 0 : wsmap->border_width; + int font_height = WMFontHeight(wsmap->scr->info_text_font); + + if (max_mini_workspace > mini_workspace_per_line) + space_width = (wsmap->wswidth - mini_workspace_per_line * wsmap->mini_workspace_width) / (mini_workspace_per_line + 1); + else + space_width = (wsmap->wswidth - max_mini_workspace * wsmap->mini_workspace_width) / (max_mini_workspace + 1); + + for (index = 0; index < max_mini_workspace; index++) { + int i , j; + + j = index; + + if (index >= mini_workspace_per_line) { + i = 1; + j -= mini_workspace_per_line; + } else { + i = 0; + } + if (wsmap_array[index].workspace_img_button) { + WMResizeWidget(wsmap_array[index].workspace_img_button, wsmap->mini_workspace_width, wsmap->mini_workspace_height); + WMMoveWidget(wsmap_array[index].workspace_img_button, j * wsmap->mini_workspace_width + (j + 1) * space_width, + border_width_adjustement + WORKSPACE_SEPARATOR_WIDTH + + i * (wsmap->mini_workspace_height + 2 * WORKSPACE_SEPARATOR_WIDTH) + font_height); + WMMapWidget(wsmap_array[index].workspace_img_button); + } + if (wsmap_array[index].workspace_label) { + WMResizeWidget(wsmap_array[index].workspace_label, wsmap->mini_workspace_width, font_height); + WMMoveWidget(wsmap_array[index].workspace_label, j * wsmap->mini_workspace_width + (j + 1) * space_width, + border_width_adjustement + WORKSPACE_SEPARATOR_WIDTH + + i * (wsmap->mini_workspace_height + 2 * WORKSPACE_SEPARATOR_WIDTH)); + WMMapWidget(wsmap_array[index].workspace_label); + } + } +} + +static void hide_mini_workspace(W_WorkspaceMap *wsmap_array, int i) +{ + if (wsmap_array[i].workspace_img_button) + WMUnmapWidget(wsmap_array[i].workspace_img_button); + if (wsmap_array[i].workspace_label) + WMUnmapWidget(wsmap_array[i].workspace_label); +} + +static WMPixmap *get_mini_workspace(WWorkspaceMap *wsmap, int index) +{ + if (!wsmap->scr->workspaces[index]->map) + return dummy_background_pixmap(wsmap); + + if (index == wsmap->scr->current_workspace) + return enlight_workspace(wsmap->scr, wsmap->scr->workspaces[index]->map); + + return WMCreatePixmapFromRImage(wsmap->scr->wmscreen, wsmap->scr->workspaces[index]->map, 128); +} + +static void create_mini_workspace(WScreen *scr, WWorkspaceMap *wsmap, W_WorkspaceMap *wsmap_array) +{ + int workspace_index; + int mini_workspace_cnt; + char name[10]; + WMButton *mini_workspace_btn; + WMPixmap *icon; + + /* by default display the 10 first mini workspaces */ + wsmap_bulk_index = 0; + mini_workspace_cnt = (scr->workspace_count <= 2 * mini_workspace_per_line) ? scr->workspace_count : 2 * mini_workspace_per_line; + for (workspace_index = 0; workspace_index < mini_workspace_cnt; workspace_index++) { + mini_workspace_btn = WMCreateButton(wsmap->win, WBTOnOff); + WMSetButtonBordered(mini_workspace_btn, 0); + WMLabel *workspace_name_label = WMCreateLabel(wsmap->win); + WMSetLabelFont(workspace_name_label, scr->info_text_font); + WMSetLabelText(workspace_name_label, scr->workspaces[workspace_index]->name); + + wsmap_array[workspace_index].workspace_img_button = mini_workspace_btn; + wsmap_array[workspace_index].workspace_label = workspace_name_label; + + WMSetButtonImagePosition(mini_workspace_btn, WIPImageOnly); + icon = get_mini_workspace(wsmap, workspace_index); + if (icon) { + WMSetButtonImage(mini_workspace_btn, icon); + WMReleasePixmap(icon); + } + + snprintf(name, sizeof(name), "%d", workspace_index); + WMSetButtonText(mini_workspace_btn, name); + WMSetButtonAction(mini_workspace_btn, selected_workspace_callback, wsmap); + } + show_mini_workspace(wsmap, wsmap_array, mini_workspace_cnt); +} + +static WWorkspaceMap *create_workspace_map(WScreen *scr, W_WorkspaceMap *wsmap_array, int edge) +{ + WWorkspaceMap *wsmap = wmalloc(sizeof(WWorkspaceMap)); + + wsmap->border_width = 5; + wsmap->edge = edge; + wsmap->mini_workspace_width = scr->scr_width / WORKSPACE_MAP_RATIO; + wsmap->mini_workspace_height = scr->scr_height / WORKSPACE_MAP_RATIO; + + if (scr->workspace_count == 0) + return NULL; + + wsmap->scr = scr; + wsmap->win = WMCreateWindow(scr->wmscreen, "wsmap"); + wsmap->wswidth = WidthOfScreen(DefaultScreenOfDisplay(dpy)); + wsmap->wsheight = WMFontHeight(scr->info_text_font) + (wsmap->mini_workspace_height + 2 * WORKSPACE_SEPARATOR_WIDTH) * + (scr->workspace_count > mini_workspace_per_line ? 2 : 1); + + if (wPreferences.wsmbackTexture->any.type == WTEX_SOLID) { + WMColor *tmp = WMCreateRGBColor(scr->wmscreen, + wPreferences.wsmbackTexture->any.color.red, + wPreferences.wsmbackTexture->any.color.green, + wPreferences.wsmbackTexture->any.color.blue, + False); + WMSetWidgetBackgroundColor(wsmap->win, tmp); + WMReleaseColor(tmp); + } + WMResizeWidget(wsmap->win, wsmap->wswidth, wsmap->wsheight + wsmap->border_width); + + WMFrame *framel = WMCreateFrame(wsmap->win); + WMResizeWidget(framel, wsmap->wswidth, wsmap->border_width); + WMSetFrameRelief(framel, WRSimple); + wWorkspaceMapUpdate(scr); + + wsmap->xcount = 0; + if (edge == WD_TOP) { + wsmap->ycount = 0; + WMMoveWidget(framel, 0, wsmap->wsheight); + } else { + wsmap->ycount = scr->scr_height - wsmap->wsheight - wsmap->border_width; + WMMoveWidget(framel, 0, 0); + } + + create_mini_workspace(scr, wsmap, wsmap_array); + workspace_map_realize(wsmap, framel, wsmap_array); + + return wsmap; +} + +static void update_mini_workspace(WWorkspaceMap *wsmap, W_WorkspaceMap *wsmap_array, int bulk_of_ten) +{ + int local_index, general_index; + int mini_workspace_cnt; + char name[10]; + WMPixmap *icon; + + if (bulk_of_ten == wsmap_bulk_index) + return; + + if (bulk_of_ten < 0) + return; + + if (wsmap->scr->workspace_count <= bulk_of_ten * 2 * mini_workspace_per_line) + return; + + wsmap_bulk_index = bulk_of_ten; + + mini_workspace_cnt = wsmap->scr->workspace_count - wsmap_bulk_index * 2 * mini_workspace_per_line; + if (mini_workspace_cnt > 2 * mini_workspace_per_line) + mini_workspace_cnt = 2 * mini_workspace_per_line; + + for (local_index = 0; local_index < 2 * mini_workspace_per_line; local_index++) { + general_index = local_index + wsmap_bulk_index * 2 * mini_workspace_per_line; + if (general_index < wsmap->scr->workspace_count) { + /* updating label */ + WMSetLabelText(wsmap_array[local_index].workspace_label, wsmap->scr->workspaces[general_index]->name); + snprintf(name, sizeof(name), "%d", general_index); + WMSetButtonText(wsmap_array[local_index].workspace_img_button, name); + + /* updating label background*/ + if (general_index == wsmap->scr->current_workspace) { + WMSetWidgetBackgroundPixmap(wsmap_array[local_index].workspace_label, frame_bg_focused); + WMSetLabelTextColor(wsmap_array[local_index].workspace_label, wsmap->scr->window_title_color[WS_FOCUSED]); + } else { + WMSetWidgetBackgroundPixmap(wsmap_array[local_index].workspace_label, frame_bg_unfocused); + WMSetLabelTextColor(wsmap_array[local_index].workspace_label, wsmap->scr->window_title_color[WS_UNFOCUSED]); + } + + icon = get_mini_workspace(wsmap, general_index); + if (icon) { + WMSetButtonImage(wsmap_array[local_index].workspace_img_button, icon); + WMReleasePixmap(icon); + } + } else { + if (local_index < wsmap->scr->workspace_count) + hide_mini_workspace(wsmap_array, local_index); + } + } + show_mini_workspace(wsmap, wsmap_array, mini_workspace_cnt); +} + +static void handle_event(WWorkspaceMap *wsmap, W_WorkspaceMap *wsmap_array) +{ + XEvent ev; + int modifiers; + KeyCode escKey = XKeysymToKeycode(dpy, XK_Escape); + + XGrabKeyboard(dpy, WMWidgetXID(wsmap->win), False, GrabModeAsync, GrabModeAsync, CurrentTime); + XGrabPointer(dpy, WMWidgetXID(wsmap->win), True, + ButtonMotionMask | ButtonReleaseMask | ButtonPressMask, + GrabModeAsync, GrabModeAsync, WMWidgetXID(wsmap->win), None, CurrentTime); + + process_workspacemap_event = True; + while (process_workspacemap_event) { + WMMaskEvent(dpy, KeyPressMask | KeyReleaseMask | ExposureMask + | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask, &ev); + + if (!wsmap) + break; + modifiers = ev.xkey.state & w_global.shortcut.modifiers_mask; + + switch (ev.type) { + case KeyPress: + if (ev.xkey.keycode == escKey || (wKeyBindings[WKBD_WORKSPACEMAP].keycode != 0 && + wKeyBindings[WKBD_WORKSPACEMAP].keycode == ev.xkey.keycode && + wKeyBindings[WKBD_WORKSPACEMAP].modifier == modifiers)) { + process_workspacemap_event = False; + } else { + KeySym ks; + int bulk_id; + + XLookupString(&ev.xkey, NULL, 16, &ks, NULL); + + bulk_id = -1; + if (ks >= 0x30 && ks <= 0x39) + bulk_id = ks - 0x30; + else + if (ks == XK_Left) + bulk_id = wsmap_bulk_index - 1; + else if (ks == XK_Right) + bulk_id = wsmap_bulk_index + 1; + + if (bulk_id >= 0) + update_mini_workspace(wsmap, wsmap_array, bulk_id); + } + break; + + case ButtonPress: + switch (ev.xbutton.button) { + case Button6: + update_mini_workspace(wsmap, wsmap_array, wsmap_bulk_index - 1); + break; + case Button7: + update_mini_workspace(wsmap, wsmap_array, wsmap_bulk_index + 1); + break; + default: + WMHandleEvent(&ev); + } + break; + + default: + WMHandleEvent(&ev); + break; + } + } + + XUngrabPointer(dpy, CurrentTime); + XUngrabKeyboard(dpy, CurrentTime); + + if (wsmap) + workspace_map_destroy(wsmap); +} + +static WWorkspaceMap *init_workspace_map(WScreen *scr, W_WorkspaceMap *wsmap_array) +{ + WWorkspaceMap *wsmap; + + wsmap = create_workspace_map(scr, wsmap_array, WD_BOTTOM); + return wsmap; +} + +void StartWorkspaceMap(WScreen *scr) +{ + WWorkspaceMap *wsmap; + W_WorkspaceMap wsmap_array[2 * mini_workspace_per_line]; + + /* save the current screen before displaying the workspace map */ + wWorkspaceMapUpdate(scr); + + wsmap = init_workspace_map(scr, wsmap_array); + if (wsmap) { + workspace_map_show(wsmap); + handle_event(wsmap, wsmap_array); + } +} diff --git a/src/wsmap.h b/src/wsmap.h new file mode 100644 index 00000000..2133bd52 --- /dev/null +++ b/src/wsmap.h @@ -0,0 +1,28 @@ +/* + * Window Maker window manager + * + * Copyright (c) 2014 Window Maker Team + * + * 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. + * + * You should have received a copy of the GNU General Public License along + * with this program, see the file COPYING. + */ + +#ifndef WSMAP_H +#define WSMAP_H + +Bool process_workspacemap_event; + +void wWorkspaceMapUpdate(WScreen *scr); +void StartWorkspaceMap(WScreen *scr); + +#endif http://repo.or.cz/w/wmaker-crm.git/commit/519302223ceea9dd8eabb14d8e1dd3042b2dc66e commit 519302223ceea9dd8eabb14d8e1dd3042b2dc66e Author: David Maciejak <david.macie...@gmail.com> Date: Thu Dec 4 13:34:56 2014 +0700 wmaker: add workspace pager underlying configuration This path is adding the functions and variables needed for workspace pager preferences. An option to enable/disable the workspace pager, and one to set a default background image. diff --git a/WindowMaker/Defaults/WindowMaker.in b/WindowMaker/Defaults/WindowMaker.in index 5b6203b3..c68feeff 100644 --- a/WindowMaker/Defaults/WindowMaker.in +++ b/WindowMaker/Defaults/WindowMaker.in @@ -3,6 +3,7 @@ PopupSwitchMenu = NO; MenuStyle = normal; DisableMiniwindows = NO; + DisableWorkspacePager = NO; OpenTransientOnOwnerWorkspace = NO; EdgeResistance = 30; WorkspaceBorderSize = 0; diff --git a/src/WindowMaker.h b/src/WindowMaker.h index 0663b546..ce0a86c9 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -393,6 +393,8 @@ extern struct WPreferences { char sticky_icons; /* If miniwindows will be onmipresent */ char dont_confirm_kill; /* do not confirm Kill application */ char disable_miniwindows; + char disable_workspace_pager; + char dont_blink; /* do not blink icon selection */ /* Appearance options */ @@ -455,6 +457,8 @@ extern struct WPreferences { RImage *swtileImage; RImage *swbackImage[9]; + union WTexture *wsmbackTexture; + int show_clip_title; struct { diff --git a/src/defaults.c b/src/defaults.c index fff239f2..b1b5050a 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -4,6 +4,8 @@ * * Copyright (c) 1997-2003 Alfredo K. Kojima * Copyright (c) 1998-2003 Dan Pascu + * Copyright (c) 2014 Window Maker Team + * * 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 @@ -144,6 +146,7 @@ static WDECallbackUpdate setHightlightText; static WDECallbackUpdate setKeyGrab; static WDECallbackUpdate setDoubleClick; static WDECallbackUpdate setIconPosition; +static WDECallbackUpdate setWorkspaceMapBackground; static WDECallbackUpdate setClipTitleFont; static WDECallbackUpdate setClipTitleColor; @@ -348,7 +351,9 @@ WDefaultEntry staticOptionList[] = { {"ClipMergedInDock", "NO", NULL, NULL, getBool, setClipMergedInDock, NULL, NULL}, {"DisableMiniwindows", "NO", NULL, - &wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL} + &wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL}, + {"DisableWorkspacePager", "NO", NULL, + &wPreferences.disable_workspace_pager, getBool, NULL, NULL, NULL} }; #define NUM2STRING_(x) #x @@ -598,6 +603,8 @@ WDefaultEntry optionList[] = { NULL, getColor, setFrameFocusedBorderColor, NULL, NULL}, {"FrameSelectedBorderColor", "white", NULL, NULL, getColor, setFrameSelectedBorderColor, NULL, NULL}, + {"WorkspaceMapBack", "(solid, black)", NULL, + NULL, getTexture, setWorkspaceMapBackground, NULL, NULL}, /* keybindings */ @@ -659,6 +666,8 @@ WDefaultEntry optionList[] = { NULL, getKeybind, setKeyGrab, NULL, NULL}, {"SelectKey", "None", (void *)WKBD_SELECT, NULL, getKeybind, setKeyGrab, NULL, NULL}, + {"WorkspaceMapKey", "None", (void *)WKBD_WORKSPACEMAP, + NULL, getKeybind, setKeyGrab, NULL, NULL}, {"FocusNextKey", "None", (void *)WKBD_FOCUSNEXT, NULL, getKeybind, setKeyGrab, NULL, NULL}, {"FocusPrevKey", "None", (void *)WKBD_FOCUSPREV, @@ -3242,6 +3251,22 @@ static int updateUsableArea(WScreen * scr, WDefaultEntry * entry, void *bar, voi return 0; } +static int setWorkspaceMapBackground(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo) +{ + WTexture **texture = tdata; + + /* Parameter not used, but tell the compiler that it is ok */ + (void) entry; + (void) foo; + + if (wPreferences.wsmbackTexture) + wTextureDestroy(scr, wPreferences.wsmbackTexture); + + wPreferences.wsmbackTexture = *texture; + + return REFRESH_WINDOW_TEXTURES; +} + static int setMenuStyle(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo) { /* Parameter not used, but tell the compiler that it is ok */ diff --git a/src/keybind.h b/src/keybind.h index 4aaadd47..87a5cdc3 100644 --- a/src/keybind.h +++ b/src/keybind.h @@ -69,6 +69,7 @@ enum { WKBD_RAISELOWER, WKBD_MOVERESIZE, WKBD_SHADE, + WKBD_WORKSPACEMAP, WKBD_FOCUSNEXT, WKBD_FOCUSPREV, WKBD_GROUPNEXT, http://repo.or.cz/w/wmaker-crm.git/commit/ea8f18aff10bcb2ef036124d646908c7117c65b5 commit ea8f18aff10bcb2ef036124d646908c7117c65b5 Author: David Maciejak <david.macie...@gmail.com> Date: Thu Dec 4 13:30:27 2014 +0700 WPrefs: add workspace pager configuration This patch is adding a checkbox in the expert zone to disable completely the workspace pager and add an entry in keyshortcut preference to set the shortcut used to open the pager with the action "Open workspace pager". The default frame background can be configured by setting an optional variable "WorkspaceMapBack" from WindowMaker conf file as in: WorkspaceMapBack = (tpixmap, "/tmp/testme.png", gray20); or WorkspaceMapBack = (solid, "#2c2482"); diff --git a/WPrefs.app/Expert.c b/WPrefs.app/Expert.c index 84e4eb40..dc455dd8 100644 --- a/WPrefs.app/Expert.c +++ b/WPrefs.app/Expert.c @@ -43,6 +43,9 @@ static const struct { { N_("Disable miniwindows (icons for minimized windows). For use with KDE/GNOME."), /* default: */ False, OPTION_WMAKER, "DisableMiniwindows" }, + { N_("Disable workspace pager"), + /* default: */ False, OPTION_WMAKER, "DisableWorkspacePager" }, + { N_("Do not set non-WindowMaker specific parameters (do not use xset)."), /* default: */ False, OPTION_USERDEF, "NoXSetStuff" }, diff --git a/WPrefs.app/KeyboardShortcuts.c b/WPrefs.app/KeyboardShortcuts.c index 414d479f..6984a918 100644 --- a/WPrefs.app/KeyboardShortcuts.c +++ b/WPrefs.app/KeyboardShortcuts.c @@ -102,6 +102,7 @@ static const struct { { "GroupPrevKey", N_("Focus previous group window") }, /* Workspace Related */ + { "WorkspaceMapKey", N_("Open workspace pager") }, { "NextWorkspaceKey", N_("Switch to next workspace") }, { "PrevWorkspaceKey", N_("Switch to previous workspace") }, { "LastWorkspaceKey", N_("Switch to last used workspace") }, ----------------------------------------------------------------------- Summary of changes: configure.ac | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) repo.or.cz automatic notification. Contact project admin crma...@gmail.com if you want to unsubscribe, or site admin ad...@repo.or.cz if you receive no reply. -- wmaker-crm.git ("The Window Maker window manager") -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.