Fix various edge flipping bugs (window moving, multihead, configuration).

SVN revision: 12686
This commit is contained in:
Kim Woelders 2005-01-02 15:38:52 +00:00
parent 06f4dd1baa
commit 65f82350c8
8 changed files with 103 additions and 68 deletions

14
src/E.h
View File

@ -849,12 +849,6 @@ WindowMatch;
/* Configuration parameters */ /* Configuration parameters */
typedef struct typedef struct
{ {
struct
{
int nx;
int ny;
char wraparound;
} areas;
struct struct
{ {
char enable; char enable;
@ -869,13 +863,16 @@ typedef struct
struct struct
{ {
int num; int num;
char wraparound;
int dragdir; int dragdir;
int dragbar_width; int dragbar_width;
int dragbar_ordering; int dragbar_ordering;
int dragbar_length; int dragbar_length;
char desks_wraparound;
char slidein; char slidein;
int slidespeed; int slidespeed;
int areas_nx;
int areas_ny;
char areas_wraparound;
} desks; } desks;
struct struct
{ {
@ -1581,6 +1578,7 @@ void ConfigurationSet(const char *params);
void ConfigurationShow(const char *params); void ConfigurationShow(const char *params);
/* edge.c */ /* edge.c */
void EdgeCheckMotion(int x, int y);
void EdgeWindowsShow(void); void EdgeWindowsShow(void);
void EdgeWindowsHide(void); void EdgeWindowsHide(void);
@ -2335,7 +2333,7 @@ Window GetWinParent(Window win);
int WinExists(Window win); int WinExists(Window win);
Window WindowAtXY_0(Window base, int bx, int by, int x, int y); Window WindowAtXY_0(Window base, int bx, int by, int x, int y);
Window WindowAtXY(int x, int y); Window WindowAtXY(int x, int y);
void PointerAt(int *x, int *y); Bool PointerAt(int *x, int *y);
void EDrawableDumpImage(Drawable draw, const char *txt); void EDrawableDumpImage(Drawable draw, const char *txt);
/* zoom.c */ /* zoom.c */

View File

@ -30,14 +30,14 @@ AreaFix(int *ax, int *ay)
{ {
if (*ax < 0) if (*ax < 0)
{ {
if (Conf.areas.wraparound) if (Conf.desks.areas_wraparound)
*ax = area_w - 1; *ax = area_w - 1;
else else
*ax = 0; *ax = 0;
} }
else if (*ax >= area_w) else if (*ax >= area_w)
{ {
if (Conf.areas.wraparound) if (Conf.desks.areas_wraparound)
*ax = 0; *ax = 0;
else else
*ax = area_w - 1; *ax = area_w - 1;
@ -45,14 +45,14 @@ AreaFix(int *ax, int *ay)
if (*ay < 0) if (*ay < 0)
{ {
if (Conf.areas.wraparound) if (Conf.desks.areas_wraparound)
*ay = area_h - 1; *ay = area_h - 1;
else else
*ay = 0; *ay = 0;
} }
else if (*ay >= area_h) else if (*ay >= area_h)
{ {
if (Conf.areas.wraparound) if (Conf.desks.areas_wraparound)
*ay = 0; *ay = 0;
else else
*ay = area_h - 1; *ay = area_h - 1;
@ -125,8 +125,8 @@ SetAreaSize(int aw, int ah)
aw = 1; aw = 1;
if (ah < 1) if (ah < 1)
ah = 1; ah = 1;
Conf.areas.nx = area_w = aw; Conf.desks.areas_nx = area_w = aw;
Conf.areas.ny = area_h = ah; Conf.desks.areas_ny = area_h = ah;
HintsSetViewportConfig(); HintsSetViewportConfig();
ModulesSignal(ESIGNAL_AREA_CONFIGURED, NULL); ModulesSignal(ESIGNAL_AREA_CONFIGURED, NULL);
EDBUG_RETURN_; EDBUG_RETURN_;

View File

@ -728,7 +728,7 @@ GotoDesktop(int desk)
static int pdesk = -1; static int pdesk = -1;
int x, y; int x, y;
if (Conf.desks.wraparound) if (Conf.desks.desks_wraparound)
{ {
if (desk >= Conf.desks.num) if (desk >= Conf.desks.num)
desk = 0; desk = 0;
@ -1438,7 +1438,7 @@ DesktopsSighan(int sig, void *prm __UNUSED__)
break; break;
case ESIGNAL_CONFIGURE: case ESIGNAL_CONFIGURE:
SetAreaSize(Conf.areas.nx, Conf.areas.ny); SetAreaSize(Conf.desks.areas_nx, Conf.desks.areas_ny);
DeskSetViewable(0, 1); DeskSetViewable(0, 1);
RefreshDesktop(0); RefreshDesktop(0);
@ -1468,7 +1468,7 @@ CB_ConfigureDesktops(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
if (val < 2) if (val < 2)
{ {
ChangeNumberOfDesktops(tmp_desktops); ChangeNumberOfDesktops(tmp_desktops);
Conf.desks.wraparound = tmp_desktop_wraparound; Conf.desks.desks_wraparound = tmp_desktop_wraparound;
} }
autosave(); autosave();
} }
@ -1560,7 +1560,7 @@ SettingsDesktops(void)
SoundPlay("SOUND_SETTINGS_DESKTOPS"); SoundPlay("SOUND_SETTINGS_DESKTOPS");
tmp_desktops = Conf.desks.num; tmp_desktops = Conf.desks.num;
tmp_desktop_wraparound = Conf.desks.wraparound; tmp_desktop_wraparound = Conf.desks.desks_wraparound;
d = tmp_desk_dialog = DialogCreate("CONFIGURE_DESKTOPS"); d = tmp_desk_dialog = DialogCreate("CONFIGURE_DESKTOPS");
DialogSetTitle(d, _("Multiple Desktop Settings")); DialogSetTitle(d, _("Multiple Desktop Settings"));
@ -1666,7 +1666,7 @@ CB_ConfigureAreas(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
if (val < 2) if (val < 2)
{ {
SetNewAreaSize(tmp_area_x, 9 - tmp_area_y); SetNewAreaSize(tmp_area_x, 9 - tmp_area_y);
Conf.areas.wraparound = tmp_area_wraparound; Conf.desks.areas_wraparound = tmp_area_wraparound;
if (tmp_edge_flip) if (tmp_edge_flip)
{ {
if (tmp_edge_resist < 1) if (tmp_edge_resist < 1)
@ -1749,7 +1749,7 @@ SettingsArea(void)
} }
SoundPlay("SOUND_SETTINGS_AREA"); SoundPlay("SOUND_SETTINGS_AREA");
tmp_area_wraparound = Conf.areas.wraparound; tmp_area_wraparound = Conf.desks.areas_wraparound;
tmp_edge_resist = Conf.edge_flip_resistance; tmp_edge_resist = Conf.edge_flip_resistance;
if (tmp_edge_resist == 0) if (tmp_edge_resist == 0)
tmp_edge_flip = 0; tmp_edge_flip = 0;
@ -2062,17 +2062,17 @@ IpcItem DesktopsIpcArray[] = {
static const CfgItem DesktopsCfgItems[] = { static const CfgItem DesktopsCfgItems[] = {
CFG_ITEM_INT(Conf.desks, num, 2), CFG_ITEM_INT(Conf.desks, num, 2),
CFG_ITEM_BOOL(Conf.desks, wraparound, 0),
CFG_ITEM_INT(Conf.desks, dragdir, 2), CFG_ITEM_INT(Conf.desks, dragdir, 2),
CFG_ITEM_INT(Conf.desks, dragbar_width, 16), CFG_ITEM_INT(Conf.desks, dragbar_width, 16),
CFG_ITEM_INT(Conf.desks, dragbar_ordering, 1), CFG_ITEM_INT(Conf.desks, dragbar_ordering, 1),
CFG_ITEM_INT(Conf.desks, dragbar_length, 0), CFG_ITEM_INT(Conf.desks, dragbar_length, 0),
CFG_ITEM_BOOL(Conf.desks, desks_wraparound, 0),
CFG_ITEM_BOOL(Conf.desks, slidein, 1), CFG_ITEM_BOOL(Conf.desks, slidein, 1),
CFG_ITEM_INT(Conf.desks, slidespeed, 6000), CFG_ITEM_INT(Conf.desks, slidespeed, 6000),
CFG_ITEM_INT(Conf.areas, nx, 2), CFG_ITEM_INT(Conf.desks, areas_nx, 2),
CFG_ITEM_INT(Conf.areas, ny, 1), CFG_ITEM_INT(Conf.desks, areas_ny, 1),
CFG_ITEM_BOOL(Conf.areas, wraparound, 0), CFG_ITEM_BOOL(Conf.desks, areas_wraparound, 0),
}; };
#define N_CFG_ITEMS (sizeof(DesktopsCfgItems)/sizeof(CfgItem)) #define N_CFG_ITEMS (sizeof(DesktopsCfgItems)/sizeof(CfgItem))

View File

@ -27,7 +27,7 @@ extern char throw_move_events_away;
static Window w1 = 0, w2 = 0, w3 = 0, w4 = 0; static Window w1 = 0, w2 = 0, w3 = 0, w4 = 0;
static void static void
EdgeTimeout(int val, void *data) EdgeTimeout(int val, void *data __UNUSED__)
{ {
int ax, ay, aw, ah, dx, dy, dax, day; int ax, ay, aw, ah, dx, dy, dax, day;
EWin *ewin; EWin *ewin;
@ -37,6 +37,11 @@ EdgeTimeout(int val, void *data)
if (!Conf.edge_flip_resistance) if (!Conf.edge_flip_resistance)
return; return;
/* Quit if pointer has left screen */
if (!PointerAt(NULL, NULL))
return;
/* Quit if in fullscreen window */
ewin = GetEwinPointerInClient(); ewin = GetEwinPointerInClient();
if (ewin && ewin->st.fullscreen) if (ewin && ewin->st.fullscreen)
return; return;
@ -51,25 +56,25 @@ EdgeTimeout(int val, void *data)
switch (val) switch (val)
{ {
case 0: case 0:
if (ax == 0 && !Conf.areas.wraparound) if (ax == 0 && !Conf.desks.areas_wraparound)
return; return;
dx = VRoot.w - 2; dx = VRoot.w - 2;
dax = -1; dax = -1;
break; break;
case 1: case 1:
if (ax == (aw - 1) && !Conf.areas.wraparound) if (ax == (aw - 1) && !Conf.desks.areas_wraparound)
return; return;
dx = -(VRoot.w - 2); dx = -(VRoot.w - 2);
dax = 1; dax = 1;
break; break;
case 2: case 2:
if (ay == 0 && !Conf.areas.wraparound) if (ay == 0 && !Conf.desks.areas_wraparound)
return; return;
dy = VRoot.h - 2; dy = VRoot.h - 2;
day = -1; day = -1;
break; break;
case 3: case 3:
if (ay == (ah - 1) && !Conf.areas.wraparound) if (ay == (ah - 1) && !Conf.desks.areas_wraparound)
return; return;
dy = -(VRoot.h - 2); dy = -(VRoot.h - 2);
day = 1; day = 1;
@ -85,54 +90,88 @@ EdgeTimeout(int val, void *data)
Mode.py = Mode.y; Mode.py = Mode.y;
Mode.x += dx; Mode.x += dx;
Mode.y += dy; Mode.y += dy;
XWarpPointer(disp, None, None, 0, 0, 0, 0, dx, dy); XWarpPointer(disp, None, VRoot.win, 0, 0, 0, 0, Mode.x, Mode.y);
Mode.flipp = 1; Mode.flipp = 1;
MoveCurrentAreaBy(dax, day); MoveCurrentAreaBy(dax, day);
Mode.flipp = 0; Mode.flipp = 0;
Mode.px = Mode.x; Mode.px = Mode.x;
Mode.py = Mode.y; Mode.py = Mode.y;
data = NULL; }
static void
EdgeEvent(int dir)
{
static int lastdir = -1;
#if 0
Eprintf("EdgeEvent %d -> %d\n", lastdir, dir);
#endif
if (lastdir == dir || !Conf.edge_flip_resistance)
return;
RemoveTimerEvent("EDGE_TIMEOUT");
if (dir >= 0)
{
DoIn("EDGE_TIMEOUT",
((double)Conf.edge_flip_resistance) / 100.0, EdgeTimeout,
dir, NULL);
}
lastdir = dir;
} }
static void static void
EdgeHandleEvents(XEvent * ev, void *prm) EdgeHandleEvents(XEvent * ev, void *prm)
{ {
static int lastdir = -1; static Time last_time;
int dir; int dir;
unsigned long dt;
dir = (int)prm; dir = (int)prm;
if (dir < 0 || dir > 3) /* Should not be possible */
return;
switch (ev->type) switch (ev->type)
{ {
case EnterNotify: case EnterNotify:
DoIn("EDGE_TIMEOUT", ((double)Conf.edge_flip_resistance) / 100.0, /* Avoid excessive flipping */
EdgeTimeout, dir, NULL); dt = ev->xcrossing.time - last_time;
if (dt < 500)
return;
last_time = ev->xcrossing.time;
EdgeEvent(dir);
break; break;
case LeaveNotify: case LeaveNotify:
RemoveTimerEvent("EDGE_TIMEOUT"); EdgeEvent(-1);
break; break;
#if 0
case MotionNotify: case MotionNotify:
if (Mode.mode != MODE_MOVE_PENDING && Mode.mode != MODE_MOVE) if (Mode.mode != MODE_MOVE_PENDING && Mode.mode != MODE_MOVE)
break; break;
if ((lastdir != dir) && (Conf.edge_flip_resistance)) EdgeEvent(dir);
{
if (dir < 0)
RemoveTimerEvent("EDGE_TIMEOUT");
else
DoIn("EDGE_TIMEOUT",
((double)Conf.edge_flip_resistance) / 100.0, EdgeTimeout,
dir, NULL);
lastdir = dir;
}
break; break;
#endif
} }
} }
void
EdgeCheckMotion(int x, int y)
{
int dir;
if (x == 0)
dir = 0;
else if (x == VRoot.w - 1)
dir = 1;
else if (y == 0)
dir = 2;
else if (y == VRoot.h - 1)
dir = 3;
else
dir = -1;
EdgeEvent(dir);
}
void void
EdgeWindowsShow(void) EdgeWindowsShow(void)
{ {
@ -150,18 +189,10 @@ EdgeWindowsShow(void)
w2 = ECreateEventWindow(VRoot.win, VRoot.w - 1, 0, 1, VRoot.h); w2 = ECreateEventWindow(VRoot.win, VRoot.w - 1, 0, 1, VRoot.h);
w3 = ECreateEventWindow(VRoot.win, 0, 0, VRoot.w, 1); w3 = ECreateEventWindow(VRoot.win, 0, 0, VRoot.w, 1);
w4 = ECreateEventWindow(VRoot.win, 0, VRoot.h - 1, VRoot.w, 1); w4 = ECreateEventWindow(VRoot.win, 0, VRoot.h - 1, VRoot.w, 1);
XSelectInput(disp, w1, XSelectInput(disp, w1, EnterWindowMask | LeaveWindowMask);
EnterWindowMask | LeaveWindowMask | PointerMotionMask | XSelectInput(disp, w2, EnterWindowMask | LeaveWindowMask);
ButtonPressMask | ButtonReleaseMask); XSelectInput(disp, w3, EnterWindowMask | LeaveWindowMask);
XSelectInput(disp, w2, XSelectInput(disp, w4, EnterWindowMask | LeaveWindowMask);
EnterWindowMask | LeaveWindowMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask);
XSelectInput(disp, w3,
EnterWindowMask | LeaveWindowMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask);
XSelectInput(disp, w4,
EnterWindowMask | LeaveWindowMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask);
EventCallbackRegister(w1, 0, EdgeHandleEvents, (void *)0); EventCallbackRegister(w1, 0, EdgeHandleEvents, (void *)0);
EventCallbackRegister(w2, 0, EdgeHandleEvents, (void *)1); EventCallbackRegister(w2, 0, EdgeHandleEvents, (void *)1);
EventCallbackRegister(w3, 0, EdgeHandleEvents, (void *)2); EventCallbackRegister(w3, 0, EdgeHandleEvents, (void *)2);
@ -170,19 +201,19 @@ EdgeWindowsShow(void)
DeskGetCurrentArea(&cx, &cy); DeskGetCurrentArea(&cx, &cy);
GetAreaSize(&ax, &ay); GetAreaSize(&ax, &ay);
if (cx == 0 && !Conf.areas.wraparound) if (cx == 0 && !Conf.desks.areas_wraparound)
EUnmapWindow(disp, w1); EUnmapWindow(disp, w1);
else else
EMapRaised(disp, w1); EMapRaised(disp, w1);
if (cx == (ax - 1) && !Conf.areas.wraparound) if (cx == (ax - 1) && !Conf.desks.areas_wraparound)
EUnmapWindow(disp, w2); EUnmapWindow(disp, w2);
else else
EMapRaised(disp, w2); EMapRaised(disp, w2);
if (cy == 0 && !Conf.areas.wraparound) if (cy == 0 && !Conf.desks.areas_wraparound)
EUnmapWindow(disp, w3); EUnmapWindow(disp, w3);
else else
EMapRaised(disp, w3); EMapRaised(disp, w3);
if (cy == (ay - 1) && !Conf.areas.wraparound) if (cy == (ay - 1) && !Conf.desks.areas_wraparound)
EUnmapWindow(disp, w4); EUnmapWindow(disp, w4);
else else
EMapRaised(disp, w4); EMapRaised(disp, w4);

View File

@ -202,8 +202,8 @@ doMoveResizeEwin(EWin * ewin, int x, int y, int w, int h, int flags)
DeskGetArea(EoGetDesk(ewin), &ax, &ay); DeskGetArea(EoGetDesk(ewin), &ax, &ay);
x0 = -ax * sw; x0 = -ax * sw;
y0 = -ay * sh; y0 = -ay * sh;
sw *= Conf.areas.nx; sw *= Conf.desks.areas_nx;
sh *= Conf.areas.ny; sh *= Conf.desks.areas_ny;
} }
dx = EoGetW(ewin) / 4; dx = EoGetW(ewin) / 4;
if (dx > 8) if (dx > 8)

View File

@ -827,7 +827,7 @@ IPC_WinOps(const char *params, Client * c __UNUSED__)
{ {
if (!strcmp(param1, "ptr")) if (!strcmp(param1, "ptr"))
{ {
ActionMoveStart(ewin, 0, 0, 0); ActionMoveStart(ewin, 1, 0, 0);
} }
else if (!strcmp(param1, "?")) else if (!strcmp(param1, "?"))
{ {

View File

@ -409,6 +409,8 @@ ActionMoveHandleMotion(void)
if (!ewin) if (!ewin)
return; return;
EdgeCheckMotion(Mode.x, Mode.y);
gwins = ListWinGroupMembersForEwin(ewin, GROUP_ACTION_MOVE, gwins = ListWinGroupMembersForEwin(ewin, GROUP_ACTION_MOVE,
Mode.nogroup || Mode.move.swap, &num); Mode.nogroup || Mode.move.swap, &num);

View File

@ -1086,14 +1086,18 @@ WindowAtXY(int x, int y)
EDBUG_RETURN(VRoot.win); EDBUG_RETURN(VRoot.win);
} }
void Bool
PointerAt(int *x, int *y) PointerAt(int *x, int *y)
{ {
Window dw; Window dw;
int dd; int dd;
unsigned int mm; unsigned int mm;
XQueryPointer(disp, VRoot.win, &dw, &dw, &dd, &dd, x, y, &mm); if (!x || !y)
x = y = &dd;
/* Return True if pointer is on "our" screen */
return XQueryPointer(disp, VRoot.win, &dw, &dw, &dd, &dd, x, y, &mm);
} }
Display * Display *