From: Christophe CURIS <christophe.cu...@free.fr> Using a variable to store the return value that will be used later is not a good idea, because it forces to track everywhere in the function when needing to work on the function.
This patch removes the variables and places explicit return if each case, so on first look it is clear where the code stops. It also fixes a bug where the function would handle an event but still returns False (meaning the event was not treated), whose root cause was coming from the complexity brought by the variable. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> --- src/wmspec.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/wmspec.c b/src/wmspec.c index d2a9555..d6bb61c 100644 --- a/src/wmspec.c +++ b/src/wmspec.c @@ -1472,7 +1472,6 @@ Bool wNETWMProcessClientMessage(XClientMessageEvent *event) { WScreen *scr; WWindow *wwin; - Bool done = True; #ifdef DEBUG_WMSPEC wmessage("processClientMessage type %s", XGetAtomName(dpy, event->message_type)); @@ -1483,6 +1482,8 @@ Bool wNETWMProcessClientMessage(XClientMessageEvent *event) /* generic client messages */ if (event->message_type == net_current_desktop) { wWorkspaceChange(scr, event->data.l[0]); + return True; + } else if (event->message_type == net_number_of_desktops) { long value; @@ -1503,16 +1504,16 @@ Bool wNETWMProcessClientMessage(XClientMessageEvent *event) if (rebuild) updateWorkspaceCount(scr); } + return True; + } else if (event->message_type == net_showing_desktop) { wNETWMShowingDesktop(scr, event->data.l[0]); + return True; + } else if (event->message_type == net_desktop_names) { handleDesktopNames(scr); - } else { - done = False; - } - - if (done) return True; + } } /* window specific client messages */ @@ -1535,12 +1536,16 @@ Bool wNETWMProcessClientMessage(XClientMessageEvent *event) wNETWMShowingDesktop(scr, False); wMakeWindowVisible(wwin); } + return True; + } else if (event->message_type == net_close_window) { if (!WFLAGP(wwin, no_closable)) { if (wwin->protocols.DELETE_WINDOW) wClientSendProtocol(wwin, w_global.atom.wm.delete_window, w_global.timestamp.last_event); } + return True; + } else if (event->message_type == net_wm_state) { int maximized = wwin->flags.maximized; long set = event->data.l[0]; @@ -1563,10 +1568,15 @@ Bool wNETWMProcessClientMessage(XClientMessageEvent *event) } } updateStateHint(wwin, False, False); + return True; + } else if (event->message_type == net_wm_handled_icons || event->message_type == net_wm_icon_geometry) { updateNetIconInfo(wwin); + return True; + } else if (event->message_type == net_wm_desktop) { long desktop = event->data.l[0]; + if (desktop == -1) { wWindowSetOmnipresent(wwin, True); } else { @@ -1574,11 +1584,10 @@ Bool wNETWMProcessClientMessage(XClientMessageEvent *event) wWindowSetOmnipresent(wwin, False); wWindowChangeWorkspace(wwin, desktop); } - } else { - done = False; + return True; } - return done; + return False; } void wNETWMCheckClientHintChange(WWindow *wwin, XPropertyEvent *event) -- 2.1.1 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.