On Sat, 11 Sep 2010 at 12:35:16 +0200, Carlos R. Mafra wrote:
> On Fri, 10 Sep 2010 at 20:51:07 +0400, Alexey I. Froloff wrote:
> > This patch highlites appicon of a currently focused window.
> 
> Cool. But I have one comment.
> 
> > --- a/src/actions.c
> > +++ b/src/actions.c
> 
> > +#ifdef NEWAPPICON
> > +                   wApplicationDeactivate(oapp);
> > +#endif
> > +           }
> 
> 
> > +#ifdef NEWAPPICON
> > +                   wApplicationDeactivate(oapp);
> > +#endif
> > +           }
> 
> > +#ifdef NEWAPPICON
> > +           wApplicationActivate(napp);
> > +#endif
> 
> > --- a/src/application.c
> > +++ b/src/application.c
> 
> > +#ifdef NEWAPPICON
> > +   wApplicationDeactivate(wapp);
> > +#endif
> 
> > --- a/src/application.h
> > +++ b/src/application.h
> 
> 
> > +#ifdef NEWAPPICON
> > +
> > +#define wApplicationActivate(wapp) do { \
> > +           if (wapp->app_icon) { \
> > +                   wIconSetHighlited(wapp->app_icon->icon, True); \
> > +                   wAppIconPaint(wapp->app_icon);\
> > +           } \
> > +   } while(0)
> > +
> > +#define wApplicationDeactivate(wapp) do { \
> > +           if (wapp->app_icon) { \
> > +                   wIconSetHighlited(wapp->app_icon->icon, False); \
> > +                   wAppIconPaint(wapp->app_icon);\
> > +           } \
> > +   } while(0)
> > +
> >  #endif
> >  
> > +#endif
> 
> Wouldn't it be cleaner if you simply #define wApplicationActive() etc to
> do nothing in the non-NEWAPPICON case? Something like adding a 'else'
> in the above to do 
> 
> #else
> #define wApplicationDeactivate(wapp) do { 0 } while (0)
> #define wApplicationActivate(wapp) do { 0 } while (0)
> #endif
> 
> and then avoid all the #ifdefery in src/{actions.c,application.c} ?
> 
> That's the kind of cleanup I want to do in other places of wmaker-crm,
> so adding one more case now will give me more trouble in the future.

I folded in the patch below (ie, it will not be a separate patch). 
If you don't agree with the result, please let me know before 
it's too late :-)

---
 src/actions.c        |    6 ------
 src/application.c    |    3 +--
 src/application.h    |   12 ++++++------
 src/icon.c           |    5 ++---
 wrlib/libwraster.map |    1 +
 wrlib/misc.c         |   16 ++++++++--------
 6 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/src/actions.c b/src/actions.c
index ebd5db9..2c61cd5 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -134,9 +134,7 @@ void wSetFocusTo(WScreen *scr, WWindow *wwin)
                        wWindowUnfocus(old_focused);
                if (oapp) {
                        wAppMenuUnmap(oapp->menu);
-#ifdef NEWAPPICON
                        wApplicationDeactivate(oapp);
-#endif
                }
 
                WMPostNotificationName(WMNChangedFocus, NULL, (void *)True);
@@ -200,9 +198,7 @@ void wSetFocusTo(WScreen *scr, WWindow *wwin)
 
                if (oapp && oapp != napp) {
                        wAppMenuUnmap(oapp->menu);
-#ifdef NEWAPPICON
                        wApplicationDeactivate(oapp);
-#endif
                }
        }
 
@@ -215,9 +211,7 @@ void wSetFocusTo(WScreen *scr, WWindow *wwin)
 
                if (wwin->flags.mapped)
                        wAppMenuMap(napp->menu, wwin);
-#ifdef NEWAPPICON
                wApplicationActivate(napp);
-#endif
        }
 
        XFlush(dpy);
diff --git a/src/application.c b/src/application.c
index 9e511f8..21155c7 100644
--- a/src/application.c
+++ b/src/application.c
@@ -434,9 +434,8 @@ void wApplicationDestroy(WApplication * wapp)
 
        XDeleteContext(dpy, wapp->main_window, wAppWinContext);
        wAppMenuDestroy(wapp->menu);
-#ifdef NEWAPPICON
        wApplicationDeactivate(wapp);
-#endif
+
        if (wapp->app_icon) {
                if (wapp->app_icon->docked && !wapp->app_icon->attracted) {
                        wapp->app_icon->running = 0;
diff --git a/src/application.h b/src/application.h
index c408cf5..111491d 100644
--- a/src/application.h
+++ b/src/application.h
@@ -64,21 +64,21 @@ void wApplicationExtractDirPackIcon(WScreen *scr,char 
*path, char *wm_instance,
 void wAppBounce(WApplication *);
 
 #ifdef NEWAPPICON
-
 #define wApplicationActivate(wapp) do { \
                if (wapp->app_icon) { \
                        wIconSetHighlited(wapp->app_icon->icon, True); \
                        wAppIconPaint(wapp->app_icon);\
                } \
-       } while(0)
-
+       } while (0)
 #define wApplicationDeactivate(wapp) do { \
                if (wapp->app_icon) { \
                        wIconSetHighlited(wapp->app_icon->icon, False); \
                        wAppIconPaint(wapp->app_icon);\
                } \
-       } while(0)
-
-#endif
+       } while (0)
+#else
+#define wApplicationActivate(wapp) do { } while (0)
+#define wApplicationDeactivate(wapp) do { } while (0)
+#endif /* NEWAPPICON */
 
 #endif
diff --git a/src/icon.c b/src/icon.c
index d1392c8..fb98906 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -528,11 +528,10 @@ static void cycleColor(void *data)
 }
 
 #ifdef NEWAPPICON
-void wIconSetHighlited(WIcon * icon, Bool flag)
+void wIconSetHighlited(WIcon *icon, Bool flag)
 {
-       if (icon->highlighted == flag) {
+       if (icon->highlighted == flag)
                return;
-       }
 
        icon->highlighted = flag;
        icon->force_paint = True;
diff --git a/wrlib/libwraster.map b/wrlib/libwraster.map
index 895a7b1..9d05f2d 100644
--- a/wrlib/libwraster.map
+++ b/wrlib/libwraster.map
@@ -50,6 +50,7 @@ LIBWRASTER3
     RGetSubImage;
     RGetXImage;
     RHSVtoRGB;
+    RLightImage;
     RLoadImage;
     RMakeCenteredImage;
     RMakeTiledImage;
diff --git a/wrlib/misc.c b/wrlib/misc.c
index c8963af..7117d81 100644
--- a/wrlib/misc.c
+++ b/wrlib/misc.c
@@ -150,7 +150,7 @@ void RClearImage(RImage * image, RColor * color)
 
                s = (image->format == RRGBAFormat) ? 4 : 3;
 
-               for (i=0; i<bytes; i++, d+=s) {
+               for (i = 0; i < bytes; i++, d += s) {
                        d[0] = (((int)d[0] * nalpha) + r)/256;
                        d[1] = (((int)d[1] * nalpha) + g)/256;
                        d[2] = (((int)d[2] * nalpha) + b)/256;
@@ -158,14 +158,14 @@ void RClearImage(RImage * image, RColor * color)
        }
 }
 
-static __inline__ unsigned char
-clip(int c) {
-       if (c > 255) c=255;
+static __inline__ unsigned char clip(int c)
+{
+       if (c > 255)
+               c = 255;
        return (unsigned char)c;
 }
 
-void
-RLightImage(RImage *image, RColor *color)
+void RLightImage(RImage *image, RColor *color)
 {
        unsigned char *d = image->data;
        unsigned char *dd;
@@ -181,13 +181,13 @@ RLightImage(RImage *image, RColor *color)
        alpha = color->alpha;
 
        if (r == 0 && g == 0 && b == 0) {
-               for (; d<dd; d+=s) {
+               for (; d < dd; d += s) {
                        d[0] = clip(((int)d[0] * alpha)/128);
                        d[1] = clip(((int)d[1] * alpha)/128);
                        d[2] = clip(((int)d[2] * alpha)/128);
                }
        } else {
-               for (; d<dd; d+=s) {
+               for (; d < dd; d += s) {
                        d[0] = clip((((int)d[0] * alpha) + r)/128);
                        d[1] = clip((((int)d[1] * alpha) + g)/128);
                        d[2] = clip((((int)d[2] * alpha) + b)/128);
-- 
1.7.2.2.119.gf9c33


-- 
To unsubscribe, send mail to [email protected].

Reply via email to