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 */
typedef struct
{
struct
{
int nx;
int ny;
char wraparound;
} areas;
struct
{
char enable;
@ -869,13 +863,16 @@ typedef struct
struct
{
int num;
char wraparound;
int dragdir;
int dragbar_width;
int dragbar_ordering;
int dragbar_length;
char desks_wraparound;
char slidein;
int slidespeed;
int areas_nx;
int areas_ny;
char areas_wraparound;
} desks;
struct
{
@ -1581,6 +1578,7 @@ void ConfigurationSet(const char *params);
void ConfigurationShow(const char *params);
/* edge.c */
void EdgeCheckMotion(int x, int y);
void EdgeWindowsShow(void);
void EdgeWindowsHide(void);
@ -2335,7 +2333,7 @@ Window GetWinParent(Window win);
int WinExists(Window win);
Window WindowAtXY_0(Window base, int bx, int by, 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);
/* zoom.c */

View File

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

View File

@ -728,7 +728,7 @@ GotoDesktop(int desk)
static int pdesk = -1;
int x, y;
if (Conf.desks.wraparound)
if (Conf.desks.desks_wraparound)
{
if (desk >= Conf.desks.num)
desk = 0;
@ -1438,7 +1438,7 @@ DesktopsSighan(int sig, void *prm __UNUSED__)
break;
case ESIGNAL_CONFIGURE:
SetAreaSize(Conf.areas.nx, Conf.areas.ny);
SetAreaSize(Conf.desks.areas_nx, Conf.desks.areas_ny);
DeskSetViewable(0, 1);
RefreshDesktop(0);
@ -1468,7 +1468,7 @@ CB_ConfigureDesktops(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
if (val < 2)
{
ChangeNumberOfDesktops(tmp_desktops);
Conf.desks.wraparound = tmp_desktop_wraparound;
Conf.desks.desks_wraparound = tmp_desktop_wraparound;
}
autosave();
}
@ -1560,7 +1560,7 @@ SettingsDesktops(void)
SoundPlay("SOUND_SETTINGS_DESKTOPS");
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");
DialogSetTitle(d, _("Multiple Desktop Settings"));
@ -1666,7 +1666,7 @@ CB_ConfigureAreas(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
if (val < 2)
{
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_resist < 1)
@ -1749,7 +1749,7 @@ SettingsArea(void)
}
SoundPlay("SOUND_SETTINGS_AREA");
tmp_area_wraparound = Conf.areas.wraparound;
tmp_area_wraparound = Conf.desks.areas_wraparound;
tmp_edge_resist = Conf.edge_flip_resistance;
if (tmp_edge_resist == 0)
tmp_edge_flip = 0;
@ -2062,17 +2062,17 @@ IpcItem DesktopsIpcArray[] = {
static const CfgItem DesktopsCfgItems[] = {
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, dragbar_width, 16),
CFG_ITEM_INT(Conf.desks, dragbar_ordering, 1),
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_INT(Conf.desks, slidespeed, 6000),
CFG_ITEM_INT(Conf.areas, nx, 2),
CFG_ITEM_INT(Conf.areas, ny, 1),
CFG_ITEM_BOOL(Conf.areas, wraparound, 0),
CFG_ITEM_INT(Conf.desks, areas_nx, 2),
CFG_ITEM_INT(Conf.desks, areas_ny, 1),
CFG_ITEM_BOOL(Conf.desks, areas_wraparound, 0),
};
#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 void
EdgeTimeout(int val, void *data)
EdgeTimeout(int val, void *data __UNUSED__)
{
int ax, ay, aw, ah, dx, dy, dax, day;
EWin *ewin;
@ -37,6 +37,11 @@ EdgeTimeout(int val, void *data)
if (!Conf.edge_flip_resistance)
return;
/* Quit if pointer has left screen */
if (!PointerAt(NULL, NULL))
return;
/* Quit if in fullscreen window */
ewin = GetEwinPointerInClient();
if (ewin && ewin->st.fullscreen)
return;
@ -51,25 +56,25 @@ EdgeTimeout(int val, void *data)
switch (val)
{
case 0:
if (ax == 0 && !Conf.areas.wraparound)
if (ax == 0 && !Conf.desks.areas_wraparound)
return;
dx = VRoot.w - 2;
dax = -1;
break;
case 1:
if (ax == (aw - 1) && !Conf.areas.wraparound)
if (ax == (aw - 1) && !Conf.desks.areas_wraparound)
return;
dx = -(VRoot.w - 2);
dax = 1;
break;
case 2:
if (ay == 0 && !Conf.areas.wraparound)
if (ay == 0 && !Conf.desks.areas_wraparound)
return;
dy = VRoot.h - 2;
day = -1;
break;
case 3:
if (ay == (ah - 1) && !Conf.areas.wraparound)
if (ay == (ah - 1) && !Conf.desks.areas_wraparound)
return;
dy = -(VRoot.h - 2);
day = 1;
@ -85,54 +90,88 @@ EdgeTimeout(int val, void *data)
Mode.py = Mode.y;
Mode.x += dx;
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;
MoveCurrentAreaBy(dax, day);
Mode.flipp = 0;
Mode.px = Mode.x;
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
EdgeHandleEvents(XEvent * ev, void *prm)
{
static int lastdir = -1;
static Time last_time;
int dir;
unsigned long dt;
dir = (int)prm;
if (dir < 0 || dir > 3) /* Should not be possible */
return;
switch (ev->type)
{
case EnterNotify:
DoIn("EDGE_TIMEOUT", ((double)Conf.edge_flip_resistance) / 100.0,
EdgeTimeout, dir, NULL);
/* Avoid excessive flipping */
dt = ev->xcrossing.time - last_time;
if (dt < 500)
return;
last_time = ev->xcrossing.time;
EdgeEvent(dir);
break;
case LeaveNotify:
RemoveTimerEvent("EDGE_TIMEOUT");
EdgeEvent(-1);
break;
#if 0
case MotionNotify:
if (Mode.mode != MODE_MOVE_PENDING && Mode.mode != MODE_MOVE)
break;
if ((lastdir != dir) && (Conf.edge_flip_resistance))
{
if (dir < 0)
RemoveTimerEvent("EDGE_TIMEOUT");
else
DoIn("EDGE_TIMEOUT",
((double)Conf.edge_flip_resistance) / 100.0, EdgeTimeout,
dir, NULL);
lastdir = dir;
}
EdgeEvent(dir);
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
EdgeWindowsShow(void)
{
@ -150,18 +189,10 @@ EdgeWindowsShow(void)
w2 = ECreateEventWindow(VRoot.win, VRoot.w - 1, 0, 1, VRoot.h);
w3 = ECreateEventWindow(VRoot.win, 0, 0, VRoot.w, 1);
w4 = ECreateEventWindow(VRoot.win, 0, VRoot.h - 1, VRoot.w, 1);
XSelectInput(disp, w1,
EnterWindowMask | LeaveWindowMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask);
XSelectInput(disp, w2,
EnterWindowMask | LeaveWindowMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask);
XSelectInput(disp, w3,
EnterWindowMask | LeaveWindowMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask);
XSelectInput(disp, w4,
EnterWindowMask | LeaveWindowMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask);
XSelectInput(disp, w1, EnterWindowMask | LeaveWindowMask);
XSelectInput(disp, w2, EnterWindowMask | LeaveWindowMask);
XSelectInput(disp, w3, EnterWindowMask | LeaveWindowMask);
XSelectInput(disp, w4, EnterWindowMask | LeaveWindowMask);
EventCallbackRegister(w1, 0, EdgeHandleEvents, (void *)0);
EventCallbackRegister(w2, 0, EdgeHandleEvents, (void *)1);
EventCallbackRegister(w3, 0, EdgeHandleEvents, (void *)2);
@ -170,19 +201,19 @@ EdgeWindowsShow(void)
DeskGetCurrentArea(&cx, &cy);
GetAreaSize(&ax, &ay);
if (cx == 0 && !Conf.areas.wraparound)
if (cx == 0 && !Conf.desks.areas_wraparound)
EUnmapWindow(disp, w1);
else
EMapRaised(disp, w1);
if (cx == (ax - 1) && !Conf.areas.wraparound)
if (cx == (ax - 1) && !Conf.desks.areas_wraparound)
EUnmapWindow(disp, w2);
else
EMapRaised(disp, w2);
if (cy == 0 && !Conf.areas.wraparound)
if (cy == 0 && !Conf.desks.areas_wraparound)
EUnmapWindow(disp, w3);
else
EMapRaised(disp, w3);
if (cy == (ay - 1) && !Conf.areas.wraparound)
if (cy == (ay - 1) && !Conf.desks.areas_wraparound)
EUnmapWindow(disp, w4);
else
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);
x0 = -ax * sw;
y0 = -ay * sh;
sw *= Conf.areas.nx;
sh *= Conf.areas.ny;
sw *= Conf.desks.areas_nx;
sh *= Conf.desks.areas_ny;
}
dx = EoGetW(ewin) / 4;
if (dx > 8)

View File

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

View File

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

View File

@ -1086,14 +1086,18 @@ WindowAtXY(int x, int y)
EDBUG_RETURN(VRoot.win);
}
void
Bool
PointerAt(int *x, int *y)
{
Window dw;
int dd;
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 *