Carlos R. Mafra wrote:
> Do you have an idea of how that code quaduplication can be avoided?

Actually I fixed my helper function to work, and now I have
a working "escape-handling swpanel" and the code is cleaner and
smaller.

I uploaded a branch called swpanel-escape in my git repo, and
you can see it directly here:

http://repo.or.cz/w/wmaker-crm.git?a=shortlog;h=refs/heads/swpanel-escape

It passed all my tests so far :-)

The escape handling patch is the last one, the others before it are
code cleanups.

Any comment is appreciated, and I apologize for not basing it on
top of the mercurial repo.

As I was doing more cleanups and little fixings before, it would be
a pain to undo those things to match the mercurial repo.

But anyway, that git repo is for my personal use and it has nothing
to do with any _official_ wmaker development, although I try really
hard to be sensible and stick to the principles :-)

Regards,
Carlos

PS: The patch which handles the escape key is inlined (but
Thunderbird will screw up the tabs)

>From f9bb2a428a52ee6aba07d160412478744c805751 Mon Sep 17 00:00:00 2001
From: Carlos R. Mafra <[email protected]>
Date: Thu, 20 Aug 2009 16:00:26 +0200
Subject: [PATCH] Escape key handling in switchpanel

Pressing the escape key (ESC) while the switchpanel is active
cancels it and gives the focus back to the window which had it
before the switchpanel was invoked.

If all windows are minimized before the switchpanel was called,
they will continue to be if ESC is pressed.

In other words, pressing ESC is like going to the parallel universe
where you never entered the switchpanel in the first place.

Based on a patch by Nicolas Bonifas from 17.08.2009.
---
 src/cycling.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/src/cycling.c b/src/cycling.c
index 87e23ee..8e9473e 100644
--- a/src/cycling.c
+++ b/src/cycling.c
@@ -86,6 +86,8 @@ void StartWindozeCycle(WWindow * wwin, XEvent * event, Bool 
next)
        KeyCode         endKey         = XKeysymToKeycode(dpy, XK_End);
        KeyCode         shiftLKey      = XKeysymToKeycode(dpy, XK_Shift_L);
        KeyCode         shiftRKey      = XKeysymToKeycode(dpy, XK_Shift_R);
+       KeyCode         escapeKey      = XKeysymToKeycode(dpy, XK_Escape);
+       Bool            esc_cancel     = False;
        Bool            somethingElse  = False;
        Bool            done           = False;
        Bool            hasModifier;
@@ -164,6 +166,14 @@ void StartWindozeCycle(WWindow * wwin, XEvent * event, 
Bool next)
                                newFocused = wSwitchPanelSelectFirst(swpanel, 
ev.xkey.keycode != homeKey);
                                if (newFocused)
                                        oldFocused = 
change_focus_and_raise(newFocused, oldFocused, swpanel, scr);
+                       } else if (ev.xkey.keycode == escapeKey) {
+                               /* Focus the first window of the swpanel, 
despite the 'False' */
+                               newFocused = wSwitchPanelSelectFirst(swpanel, 
False);
+                               if (newFocused) {
+                                       oldFocused = 
change_focus_and_raise(newFocused, oldFocused, swpanel, scr);
+                               esc_cancel = True;
+                               done = True;
+                               }
                        } else if (ev.xkey.keycode != shiftLKey && 
ev.xkey.keycode != shiftRKey) {
 
                                somethingElse = True;
@@ -215,7 +225,7 @@ void StartWindozeCycle(WWindow * wwin, XEvent * event, Bool 
next)
        if (swpanel)
                wSwitchPanelDestroy(swpanel);
 
-       if (newFocused) {
+       if (newFocused && !esc_cancel) {
                wRaiseFrame(newFocused->frame->core);
                CommitStacking(scr);
                if (!newFocused->flags.mapped)
-- 
1.6.4.rc1.13.gec7b

Reply via email to