1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

Add KEY_CONTROL_WINDOW_WEIGHT to keyboard move window code and bugs fixes.

This commit is contained in:
id
1999-04-23 07:12:01 +00:00
parent 553c61ee3b
commit a8b7216c31
2 changed files with 132 additions and 112 deletions

View File

@@ -1118,8 +1118,6 @@ updateWindowPosition(WWindow *wwin, MoveData *data, Bool doResistance,
} }
#if 0 #if 0
typedef struct _looper { typedef struct _looper {
WWindow *wwin; WWindow *wwin;
@@ -1152,7 +1150,8 @@ _keyloop(_looper *lpr){
} }
#endif #endif
#define _KS 20
#define _KS KEY_CONTROL_WINDOW_WEIGHT
int int
wKeyboardMoveResizeWindow(WWindow *wwin) wKeyboardMoveResizeWindow(WWindow *wwin)
@@ -1168,9 +1167,10 @@ wKeyboardMoveResizeWindow(WWindow *wwin)
int src_x = wwin->frame_x; int src_x = wwin->frame_x;
int src_y = wwin->frame_y; int src_y = wwin->frame_y;
int done,off_x,off_y,ww,wh; int done,off_x,off_y,ww,wh;
int kspeed = 1; int kspeed = _KS;
Time lastTime = 0; Time lastTime = 0;
KeySym keysym=NoSymbol; KeySym keysym=NoSymbol;
int moment=0;
KeyCode shiftl,shiftr,ctrll,ctrlmode; KeyCode shiftl,shiftr,ctrll,ctrlmode;
/* /*
@@ -1199,13 +1199,13 @@ wKeyboardMoveResizeWindow(WWindow *wwin)
GrabModeAsync, None, wCursor[WCUR_DEFAULT], CurrentTime); GrabModeAsync, None, wCursor[WCUR_DEFAULT], CurrentTime);
if (wwin->flags.shaded || scr->selected_windows) { if (wwin->flags.shaded || scr->selected_windows) {
if(scr->selected_windows) if(scr->selected_windows)
drawFrames(wwin,scr->selected_windows,off_x,off_y); drawFrames(wwin,scr->selected_windows,off_x,off_y);
else drawTransparentFrame(wwin, src_x+off_x, src_y+off_y, w, h); else drawTransparentFrame(wwin, src_x+off_x, src_y+off_y, w, h);
if(!scr->selected_windows) if(!scr->selected_windows)
mapPositionDisplay(wwin, src_x, src_y, w, h); mapPositionDisplay(wwin, src_x, src_y, w, h);
} else { } else {
drawTransparentFrame(wwin, src_x+off_x, src_y+off_y, w, h); drawTransparentFrame(wwin, src_x+off_x, src_y+off_y, w, h);
} }
ww=w; ww=w;
wh=h; wh=h;
@@ -1233,106 +1233,125 @@ wKeyboardMoveResizeWindow(WWindow *wwin)
XSync(dpy, False); XSync(dpy, False);
switch (event.type) { switch (event.type) {
case KeyPress: case KeyPress:
/* accelerate */ /* accelerate */
if (event.xkey.time - lastTime > 50) { if (event.xkey.time - lastTime > 50) {
kspeed = 1; kspeed/=(1 + (event.xkey.time - lastTime)/100);
} else { } else {
if (kspeed < 20) if (kspeed < 20) {
kspeed++; kspeed++;
} }
lastTime = event.xkey.time; }
if (kspeed < _KS) kspeed = _KS;
lastTime = event.xkey.time;
if (event.xkey.state & ControlMask && !wwin->flags.shaded){ if (event.xkey.state & ControlMask && !wwin->flags.shaded) {
ctrlmode=1; ctrlmode=1;
wUnselectWindows(scr); wUnselectWindows(scr);
} }
else { else {
ctrlmode=0; ctrlmode=0;
} }
if (event.xkey.keycode == shiftl || event.xkey.keycode == shiftr){ if (event.xkey.keycode == shiftl || event.xkey.keycode == shiftr) {
if(ctrlmode) if (ctrlmode)
cycleGeometryDisplay(wwin, src_x+off_x, src_y+off_y, ww, wh, 0); cycleGeometryDisplay(wwin, src_x+off_x, src_y+off_y, ww, wh, 0);
else else
cyclePositionDisplay(wwin, src_x+off_x, src_y+off_y, ww, wh); cyclePositionDisplay(wwin, src_x+off_x, src_y+off_y, ww, wh);
} }
else { else {
keysym = XLookupKeysym(&event.xkey, 0);
switch(keysym){ keysym = XLookupKeysym(&event.xkey, 0);
case XK_Return: switch (keysym) {
done=2; case XK_Return:
break; done=2;
case XK_Escape: break;
done=1; case XK_Escape:
break; done=1;
case XK_Up: break;
case XK_KP_Up: case XK_Up:
case XK_k: case XK_KP_Up:
if (ctrlmode){ case XK_k:
h-=kspeed; if (ctrlmode){
} if (moment != UP)
else off_y-=kspeed; h = wh;
break; h-=kspeed;
case XK_Down: moment = UP;
case XK_KP_Down: if (h < 1) h = 1;
case XK_j: }
if (ctrlmode){ else off_y-=kspeed;
h+=kspeed; break;
} case XK_Down:
else off_y+=kspeed; case XK_KP_Down:
break; case XK_j:
case XK_Left: if (ctrlmode){
case XK_KP_Left: if (moment != DOWN)
case XK_h: h = wh;
if (ctrlmode){ h+=kspeed;
w-=kspeed; moment = DOWN;
} }
else off_x-=kspeed; else off_y+=kspeed;
break; break;
case XK_Right: case XK_Left:
case XK_KP_Right: case XK_KP_Left:
case XK_l: case XK_h:
if (ctrlmode){ if (ctrlmode) {
w+=kspeed; if (moment != LEFT)
} w = ww;
else off_x+=kspeed; w-=kspeed;
break; if (w < 1) w = 1;
} moment = LEFT;
ww=w;wh=h; }
wh-=vert_border; else off_x-=kspeed;
wWindowConstrainSize(wwin, &ww, &wh); break;
wh+=vert_border; case XK_Right:
case XK_KP_Right:
if (wPreferences.ws_cycle){ case XK_l:
if (src_x + off_x + wwin->frame->core->width < 20){ if (ctrlmode) {
if(!scr->current_workspace) { if (moment != RIGHT)
wWorkspaceChange(scr, scr->workspace_count-1); w = ww;
} w+=kspeed;
else wWorkspaceChange(scr, scr->current_workspace-1); moment = RIGHT;
off_x += scr_width; }
} else off_x+=kspeed;
else if (src_x + off_x + 20 > scr_width){ break;
if(scr->current_workspace == scr->workspace_count-1) { }
wWorkspaceChange(scr, 0);
} ww=w;wh=h;
else wWorkspaceChange(scr, scr->current_workspace+1); wh-=vert_border;
off_x -= scr_width; wWindowConstrainSize(wwin, &ww, &wh);
} wh+=vert_border;
}
else { if (wPreferences.ws_cycle){
if (src_x + off_x + wwin->frame->core->width < 20) if (src_x + off_x + ww < 20){
off_x = 20 - wwin->frame->core->width - src_x; if(!scr->current_workspace) {
else if (src_x + off_x + 20 > scr_width) wWorkspaceChange(scr, scr->workspace_count-1);
off_x = scr_width - 20 - src_x; }
} else wWorkspaceChange(scr, scr->current_workspace-1);
off_x += scr_width;
if (src_y + off_y + wwin->frame->core->height < 20) }
off_y = 20 - wwin->frame->core->height - src_y; else if (src_x + off_x + 20 > scr_width){
else if (src_y + off_y + 20 > scr_height) if(scr->current_workspace == scr->workspace_count-1) {
off_y = scr_height - 20 - src_y; wWorkspaceChange(scr, 0);
}
} else wWorkspaceChange(scr, scr->current_workspace+1);
break; off_x -= scr_width;
}
}
else {
if (src_x + off_x + ww < 20)
off_x = 20 - ww - src_x;
else if (src_x + off_x + 20 > scr_width)
off_x = scr_width - 20 - src_x;
}
if (src_y + off_y + wh < 20) {
off_y = 20 - wh - src_y;
}
else if (src_y + off_y + 20 > scr_height) {
off_y = scr_height - 20 - src_y;
}
}
break;
case ButtonPress: case ButtonPress:
case ButtonRelease: case ButtonRelease:
done=1; done=1;
@@ -1359,10 +1378,10 @@ wKeyboardMoveResizeWindow(WWindow *wwin)
} }
} }
if (wwin->flags.shaded || scr->selected_windows) { if (wwin->flags.shaded || scr->selected_windows) {
if(scr->selected_windows) if(scr->selected_windows)
drawFrames(wwin,scr->selected_windows,off_x,off_y); drawFrames(wwin,scr->selected_windows,off_x,off_y);
else drawTransparentFrame(wwin, src_x+off_x, src_y+off_y, w, h); else drawTransparentFrame(wwin, src_x+off_x, src_y+off_y, w, h);
} }
else { else {
drawTransparentFrame(wwin, src_x+off_x, src_y+off_y, ww, wh); drawTransparentFrame(wwin, src_x+off_x, src_y+off_y, ww, wh);

View File

@@ -475,6 +475,7 @@
#define MOVE_THRESHOLD 5 /* how many pixels to move before dragging windows #define MOVE_THRESHOLD 5 /* how many pixels to move before dragging windows
* and other objects */ * and other objects */
#define KEY_CONTROL_WINDOW_WEIGHT 1
#define HRESIZE_THRESHOLD 3 #define HRESIZE_THRESHOLD 3