From f6682a9aded416ebf73e93049ac1aaab0096f375 Mon Sep 17 00:00:00 2001 From: kojima Date: Wed, 20 Oct 2004 03:31:14 +0000 Subject: [PATCH] fixed bugs, re-enabled circulate raise --- WPrefs.app/FontSimple.c | 2 +- configure.ac | 2 +- src/cycling.c | 212 ++++++---------------------------------- src/main.c | 3 +- src/switchpanel.c | 12 ++- src/switchpanel.h | 2 + src/wconfig.h.in | 12 +-- 7 files changed, 52 insertions(+), 193 deletions(-) diff --git a/WPrefs.app/FontSimple.c b/WPrefs.app/FontSimple.c index aa6e029d..6b597901 100644 --- a/WPrefs.app/FontSimple.c +++ b/WPrefs.app/FontSimple.c @@ -693,7 +693,7 @@ createPanel(Panel *p) box = WMCreateBox(vbox); WMSetBoxHorizontal(box, True); - WMAddBoxSubview(vbox, WMWidgetView(box), True, True, 20, 0, 4); + WMAddBoxSubview(vbox, WMWidgetView(box), True, True, 20, 0, 0); panel->styleL = WMCreateList(box); WMAddBoxSubview(box, WMWidgetView(panel->styleL), True, True, 0, 0, 4); diff --git a/configure.ac b/configure.ac index 5a6d625a..2d9c9cc8 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ AC_INIT(src/WindowMaker.h) -AM_INIT_AUTOMAKE(WindowMaker, 0.85.0) +AM_INIT_AUTOMAKE(WindowMaker, 0.90.0) AC_PROG_LIBTOOL diff --git a/src/cycling.c b/src/cycling.c index e11f91b7..05fd2a4a 100644 --- a/src/cycling.c +++ b/src/cycling.c @@ -30,8 +30,6 @@ // fix the stacking/window raising during alt-tabbing // allow selection of icons with mouse -#define MOX_CYCLING - #include "WindowMaker.h" #include "GNUstep.h" #include "screen.h" @@ -51,133 +49,19 @@ extern WPreferences wPreferences; extern WShortKey wKeyBindings[WKBD_LAST]; - - - -#ifndef MOX_CYCLING -static WWindow* -nextToFocusAfter(WWindow *wwin) +static void raiseWindow(WSwitchPanel *swpanel, WWindow *wwin) { - WWindow *tmp = wwin->prev; - - while (tmp) { - if (wWindowCanReceiveFocus(tmp) && !WFLAGP(tmp, skip_window_list)) { - return tmp; - } - tmp = tmp->prev; + if (wwin->flags.mapped) { + Window win[2]; + + win[0]= wSwitchPanelGetWindow(swpanel); + win[1]= wwin->frame->core->window; + + XRestackWindows(dpy, win, 2); } - - tmp = wwin; - /* start over from the beginning of the list */ - while (tmp->next) - tmp = tmp->next; - - while (tmp && tmp != wwin) { - if (wWindowCanReceiveFocus(tmp) && !WFLAGP(tmp, skip_window_list)) { - return tmp; - } - tmp = tmp->prev; - } - - return wwin; } -static WWindow* -nextToFocusBefore(WWindow *wwin) -{ - WWindow *tmp = wwin->next; - - while (tmp) { - if (wWindowCanReceiveFocus(tmp) && !WFLAGP(tmp, skip_window_list)) { - return tmp; - } - tmp = tmp->next; - } - - /* start over from the beginning of the list */ - tmp = wwin; - while (tmp->prev) - tmp = tmp->prev; - - while (tmp && tmp != wwin) { - if (wWindowCanReceiveFocus(tmp) && !WFLAGP(tmp, skip_window_list)) { - - return tmp; - } - tmp = tmp->next; - } - - return wwin; -} - - - - -static WWindow* -nextFocusWindow(WWindow *wwin) -{ - WWindow *tmp, *closest, *min; - Window d; - - if (!wwin) - return NULL; - tmp = wwin->prev; - closest = NULL; - min = wwin; - d = 0xffffffff; - while (tmp) { - if (wWindowCanReceiveFocus(tmp) - && (!WFLAGP(tmp, skip_window_list)|| tmp->flags.internal_window)) { - if (min->client_win > tmp->client_win) - min = tmp; - if (tmp->client_win > wwin->client_win - && (!closest - || (tmp->client_win - wwin->client_win) < d)) { - closest = tmp; - d = tmp->client_win - wwin->client_win; - } - } - tmp = tmp->prev; - } - if (!closest||closest==wwin) - return min; - return closest; -} - - -static WWindow* -prevFocusWindow(WWindow *wwin) -{ - WWindow *tmp, *closest, *max; - Window d; - - if (!wwin) - return NULL; - tmp = wwin->prev; - closest = NULL; - max = wwin; - d = 0xffffffff; - while (tmp) { - if (wWindowCanReceiveFocus(tmp) && - (!WFLAGP(tmp, skip_window_list) || tmp->flags.internal_window)) { - if (max->client_win < tmp->client_win) - max = tmp; - if (tmp->client_win < wwin->client_win - && (!closest - || (wwin->client_win - tmp->client_win) < d)) { - closest = tmp; - d = wwin->client_win - tmp->client_win; - } - } - tmp = tmp->prev; - } - if (!closest||closest==wwin) - return max; - return closest; -} -#endif /* !MOX_CYCLING */ - void StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next) @@ -191,12 +75,10 @@ StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next) Bool hasModifier; Bool somethingElse = False; XEvent ev; -#ifdef MOX_CYCLING WSwitchPanel *swpanel = NULL; -#endif KeyCode leftKey, rightKey, homeKey, endKey; - if (!wwin) + if (!wwin || wwin->frame->workspace != scr->current_workspace) return; leftKey = XKeysymToKeycode(dpy, XK_Left); @@ -221,7 +103,6 @@ StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next) scr->flags.doing_alt_tab = 1; -#ifdef MOX_CYCLING swpanel = wInitSwitchPanel(scr, wwin, scr->current_workspace); oldFocused = wwin; @@ -230,28 +111,13 @@ StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next) if (newFocused) { wWindowFocus(newFocused, oldFocused); oldFocused = newFocused; + + if (wPreferences.circ_raise) + raiseWindow(swpanel, newFocused); } } else newFocused= wwin; -#else /* !MOX_CYCLING */ - if (next) { - if (wPreferences.windows_cycling) - newFocused = nextToFocusAfter(wwin); - else - newFocused = nextFocusWindow(wwin); - } else { - if (wPreferences.windows_cycling) - newFocused = nextToFocusBefore(wwin); - else - newFocused = prevFocusWindow(wwin); - } - - if (wPreferences.circ_raise) - XRaiseWindow(dpy, newFocused->frame->core->window); - wWindowFocus(newFocused, scr->focused_window); - oldFocused = newFocused; -#endif /* !MOX_CYCLING */ while (hasModifier && !done) { WMMaskEvent(dpy, KeyPressMask|KeyReleaseMask|ExposureMask|PointerMotionMask, &ev); @@ -271,54 +137,45 @@ StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next) && wKeyBindings[WKBD_FOCUSNEXT].modifier == modifiers) || ev.xkey.keycode == rightKey) { -#ifdef MOX_CYCLING if (swpanel) { newFocused = wSwitchPanelSelectNext(swpanel, False); if (newFocused) { wWindowFocus(newFocused, oldFocused); oldFocused = newFocused; + + if (wPreferences.circ_raise) { + CommitStacking(scr); + raiseWindow(swpanel, newFocused); + } } } -#else /* !MOX_CYCLING */ - newFocused = nextToFocusAfter(newFocused); - wWindowFocus(newFocused, oldFocused); - oldFocused = newFocused; - - if (wPreferences.circ_raise) { - /* restore order */ - CommitStacking(scr); - XRaiseWindow(dpy, newFocused->frame->core->window); - } -#endif /* !MOX_CYCLING */ } else if ((wKeyBindings[WKBD_FOCUSPREV].keycode == ev.xkey.keycode && wKeyBindings[WKBD_FOCUSPREV].modifier == modifiers) || ev.xkey.keycode == leftKey) { -#ifdef MOX_CYCLING if (swpanel) { newFocused = wSwitchPanelSelectNext(swpanel, True); if (newFocused) { wWindowFocus(newFocused, oldFocused); oldFocused = newFocused; + + if (wPreferences.circ_raise) { + CommitStacking(scr); + raiseWindow(swpanel, newFocused); + } } } -#else /* !MOX_CYCLING */ - newFocused = nextToFocusBefore(newFocused); - wWindowFocus(newFocused, oldFocused); - oldFocused = newFocused; - - if (wPreferences.circ_raise) { - /* restore order */ - CommitStacking(scr); - XRaiseWindow(dpy, newFocused->frame->core->window); - } -#endif /* !MOX_CYCLING */ } else if (ev.xkey.keycode == homeKey || ev.xkey.keycode == endKey) { if (swpanel) { newFocused = wSwitchPanelSelectFirst(swpanel, ev.xkey.keycode != homeKey); if (newFocused) { wWindowFocus(newFocused, oldFocused); oldFocused = newFocused; + + if (wPreferences.circ_raise) { + CommitStacking(scr); + raiseWindow(swpanel, newFocused); + } } } } else if (ev.type == MotionNotify) { @@ -365,25 +222,20 @@ StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next) } if (newFocused) { + CommitStacking(scr); + if (!newFocused->flags.mapped) + wMakeWindowVisible(newFocused); wSetFocusTo(scr, newFocused); - wMakeWindowVisible(newFocused); + wRaiseFrame(newFocused->frame->core); } -#ifdef MOX_CYCLING if (swpanel) wSwitchPanelDestroy(swpanel); -#endif - - if (wPreferences.circ_raise && newFocused) { - wRaiseFrame(newFocused->frame->core); - CommitStacking(scr); - } scr->flags.doing_alt_tab = 0; - if (somethingElse) { + if (somethingElse) WMHandleEvent(&ev); - } } diff --git a/src/main.c b/src/main.c index 14260a69..06f14bb7 100644 --- a/src/main.c +++ b/src/main.c @@ -466,7 +466,8 @@ check_defaults() { char *path; - path = wdefaultspathfordomain(""); + path = wdefaultspathfordomain("WindowMaker"); + if (access(path, R_OK)!=0) { #if 0 wfatal(_("could not find user GNUstep directory (%s).\n" diff --git a/src/switchpanel.c b/src/switchpanel.c index 0a070a0d..320e2c49 100644 --- a/src/switchpanel.c +++ b/src/switchpanel.c @@ -128,7 +128,7 @@ extern WPreferences wPreferences; #define ICON_IDEAL_SIZE 48 #define ICON_EXTRASPACE 16 - +#define LABEL_HEIGHT 25 static int canReceiveFocus(WWindow *wwin) @@ -288,7 +288,7 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, int workspace) return panel; } - height= iconWidth + 20 + 10 + ICON_EXTRASPACE + 10; + height= iconWidth + LABEL_HEIGHT + 10 + ICON_EXTRASPACE + 10; panel->icons= WMCreateArray(WMGetArrayItemCount(panel->windows)); panel->images= WMCreateArray(WMGetArrayItemCount(panel->windows)); @@ -307,7 +307,7 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, int workspace) WMSetBoxHorizontal(vbox, False); panel->label = WMCreateLabel(vbox); - WMAddBoxSubviewAtEnd(vbox, WMWidgetView(panel->label), False, True, 20, 0, 0); + WMAddBoxSubviewAtEnd(vbox, WMWidgetView(panel->label), False, True, LABEL_HEIGHT, 0, 0); if (scr->focused_window && scr->focused_window->frame->title) WMSetLabelText(panel->label, scr->focused_window->frame->title); else @@ -317,7 +317,7 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, int workspace) WMColor *color; WMFont *boldFont= WMBoldSystemFontOfSize(scr->wmscreen, 12); - WMSetLabelRelief(panel->label, WRSimple); + WMSetLabelRelief(panel->label, WRSunken); WMSetLabelFont(panel->label, boldFont); color = WMDarkGrayColor(scr->wmscreen); WMSetWidgetBackgroundColor(panel->label, color); @@ -477,3 +477,7 @@ WWindow *wSwitchPanelHandleEvent(WSwitchPanel *panel, XEvent *event) } +Window wSwitchPanelGetWindow(WSwitchPanel *swpanel) +{ + return WMWidgetXID(swpanel->win); +} diff --git a/src/switchpanel.h b/src/switchpanel.h index 855f8106..6a931b0f 100644 --- a/src/switchpanel.h +++ b/src/switchpanel.h @@ -33,4 +33,6 @@ WWindow *wSwitchPanelSelectFirst(WSwitchPanel *panel, int back); WWindow *wSwitchPanelHandleEvent(WSwitchPanel *panel, XEvent *event); +Window wSwitchPanelGetWindow(WSwitchPanel *swpanel); + #endif /* _SWITCHPANEL_H_ */ diff --git a/src/wconfig.h.in b/src/wconfig.h.in index fa74e289..4e97d554 100644 --- a/src/wconfig.h.in +++ b/src/wconfig.h.in @@ -269,12 +269,12 @@ #define DEF_FRAME_COLOR "white" -#define DEF_TITLE_FONT "Trebuchet MS,Luxi Sans:bold:pixelsize=12" -#define DEF_MENU_TITLE_FONT "Trebuchet MS,Luxi Sans:bold:pixelsize=12" -#define DEF_MENU_ENTRY_FONT "Trebuchet MS,Luxi Sans:pixelsize=12" -#define DEF_ICON_TITLE_FONT "Trebuchet MS,Luxi Sans:pixelsize=8" -#define DEF_CLIP_TITLE_FONT "Trebuchet MS,Luxi Sans:bold:pixelsize=10" -#define DEF_INFO_TEXT_FONT "Trebuchet MS,Luxi Sans:pixelsize=12" +#define DEF_TITLE_FONT "\"Trebuchet MS,Luxi Sans:bold:pixelsize=12\"" +#define DEF_MENU_TITLE_FONT "\"Trebuchet MS,Luxi Sans:bold:pixelsize=12\"" +#define DEF_MENU_ENTRY_FONT "\"Trebuchet MS,Luxi Sans:pixelsize=12\"" +#define DEF_ICON_TITLE_FONT "\"Trebuchet MS,Luxi Sans:pixelsize=8\"" +#define DEF_CLIP_TITLE_FONT "\"Trebuchet MS,Luxi Sans:bold:pixelsize=10\"" +#define DEF_INFO_TEXT_FONT "\"Trebuchet MS,Luxi Sans:pixelsize=12\"" #define DEF_WORKSPACE_NAME_FONT "Trebuchet MS,Luxi Sans:bold:pixelsize=24"