1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 21:08:08 +01:00

fixed bug in window switching

This commit is contained in:
kojima
2004-10-14 15:53:17 +00:00
parent 440f2abe6f
commit 62590be0db
2 changed files with 30 additions and 23 deletions

View File

@@ -219,9 +219,11 @@ StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next)
swpanel = wInitSwitchPanel(scr, 0); swpanel = wInitSwitchPanel(scr, 0);
oldFocused = wwin; oldFocused = wwin;
newFocused = wSwitchPanelSelectNext(swpanel, next); if (swpanel) {
wWindowFocus(newFocused, oldFocused); newFocused = wSwitchPanelSelectNext(swpanel, next);
oldFocused = newFocused; wWindowFocus(newFocused, oldFocused);
oldFocused = newFocused;
}
#else /* !MOX_CYCLING */ #else /* !MOX_CYCLING */
if (next) { if (next) {
if (wPreferences.windows_cycling) if (wPreferences.windows_cycling)
@@ -260,9 +262,11 @@ StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next)
|| ev.xkey.keycode == rightKey) { || ev.xkey.keycode == rightKey) {
#ifdef MOX_CYCLING #ifdef MOX_CYCLING
newFocused = wSwitchPanelSelectNext(swpanel, False); if (swpanel) {
wWindowFocus(newFocused, oldFocused); newFocused = wSwitchPanelSelectNext(swpanel, False);
oldFocused = newFocused; wWindowFocus(newFocused, oldFocused);
oldFocused = newFocused;
}
#else /* !MOX_CYCLING */ #else /* !MOX_CYCLING */
newFocused = nextToFocusAfter(newFocused); newFocused = nextToFocusAfter(newFocused);
wWindowFocus(newFocused, oldFocused); wWindowFocus(newFocused, oldFocused);
@@ -279,9 +283,11 @@ StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next)
|| ev.xkey.keycode == leftKey) { || ev.xkey.keycode == leftKey) {
#ifdef MOX_CYCLING #ifdef MOX_CYCLING
newFocused = wSwitchPanelSelectNext(swpanel, True); if (swpanel) {
wWindowFocus(newFocused, oldFocused); newFocused = wSwitchPanelSelectNext(swpanel, True);
oldFocused = newFocused; wWindowFocus(newFocused, oldFocused);
oldFocused = newFocused;
}
#else /* !MOX_CYCLING */ #else /* !MOX_CYCLING */
newFocused = nextToFocusBefore(newFocused); newFocused = nextToFocusBefore(newFocused);
wWindowFocus(newFocused, oldFocused); wWindowFocus(newFocused, oldFocused);
@@ -294,13 +300,15 @@ StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next)
} }
#endif /* !MOX_CYCLING */ #endif /* !MOX_CYCLING */
} else if (ev.type == MotionNotify) { } else if (ev.type == MotionNotify) {
WWindow *tmp; WWindow *tmp;
tmp = wSwitchPanelHandleEvent(swpanel, &ev); if (swpanel) {
if (tmp) { tmp = wSwitchPanelHandleEvent(swpanel, &ev);
newFocused = tmp; if (tmp) {
wWindowFocus(newFocused, oldFocused); newFocused = tmp;
oldFocused = newFocused; wWindowFocus(newFocused, oldFocused);
} oldFocused = newFocused;
}
}
} else { } else {
#ifdef DEBUG #ifdef DEBUG
printf("Got something else\n"); printf("Got something else\n");
@@ -340,7 +348,7 @@ StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next)
wSwitchPanelDestroy(swpanel); wSwitchPanelDestroy(swpanel);
#endif #endif
if (wPreferences.circ_raise) { if (wPreferences.circ_raise && newFocused) {
wRaiseFrame(newFocused->frame->core); wRaiseFrame(newFocused->frame->core);
CommitStacking(scr); CommitStacking(scr);
} }

View File

@@ -50,6 +50,7 @@ struct SwitchPanel {
extern WPreferences wPreferences; extern WPreferences wPreferences;
#define ICON_IDEAL_SIZE 64
#define ICON_EXTRASPACE 4 #define ICON_EXTRASPACE 4
static void addIconForWindow(WSwitchPanel *panel, WWindow *wwin, int iconWidth) static void addIconForWindow(WSwitchPanel *panel, WWindow *wwin, int iconWidth)
@@ -64,11 +65,9 @@ static void addIconForWindow(WSwitchPanel *panel, WWindow *wwin, int iconWidth)
image = RRetainImage(wwin->net_icon_image); image = RRetainImage(wwin->net_icon_image);
if (!image) if (!image)
image = wDefaultGetImage(panel->scr, wwin->wm_instance, wwin->wm_class); image = wDefaultGetImage(panel->scr, wwin->wm_instance, wwin->wm_class);
if (!image)
if (image && (abs(image->width - iconWidth) > 4 || abs(image->height - iconWidth) > 4)) { if (image && (abs(image->width - iconWidth) > 2 || abs(image->height - iconWidth) > 2)) {
RImage *nimage; RImage *nimage;
nimage= RScaleImage(image, iconWidth, (image->height * iconWidth / image->width)); nimage= RScaleImage(image, iconWidth, (image->height * iconWidth / image->width));
RReleaseImage(image); RReleaseImage(image);
image= nimage; image= nimage;
@@ -116,7 +115,7 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, int workspace)
int i; int i;
int width; int width;
int height; int height;
int iconWidth = 48; int iconWidth = ICON_IDEAL_SIZE;
WMBox *vbox; WMBox *vbox;
panel->current= 0; panel->current= 0;
@@ -143,7 +142,7 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, int workspace)
iconWidth = width / WMGetArrayItemCount(panel->windows) - ICON_EXTRASPACE; iconWidth = width / WMGetArrayItemCount(panel->windows) - ICON_EXTRASPACE;
} }
if (iconWidth < 16) if (iconWidth < 16 || WMGetArrayItemCount(panel->windows) == 0)
{ {
/* if there are too many windows, don't bother trying to show the panel */ /* if there are too many windows, don't bother trying to show the panel */
WMFreeArray(panel->windows); WMFreeArray(panel->windows);
@@ -151,7 +150,7 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, int workspace)
return NULL; return NULL;
} }
height= 48 + 20 + 10 + ICON_EXTRASPACE; height= iconWidth + 20 + 10 + ICON_EXTRASPACE;
panel->icons= WMCreateArray(WMGetArrayItemCount(panel->windows)); panel->icons= WMCreateArray(WMGetArrayItemCount(panel->windows));