Desktop and stacking fixes.

SVN revision: 13519
This commit is contained in:
Kim Woelders 2005-02-27 01:11:51 +00:00
parent bbee671e2f
commit 90001a2bfa
8 changed files with 133 additions and 71 deletions

17
src/E.h
View File

@ -523,7 +523,7 @@ struct _eobj
#define EoGetH(eo) ((eo)->o.h)
#define EoIsSticky(eo) ((eo)->o.sticky)
#define EoIsFloating(eo) ((eo)->o.floating)
#define EoGetDesk(eo) EobjGetDesk(&((eo)->o))
#define EoGetDesk(eo) ((eo)->o.desk)
#define EoGetLayer(eo) ((eo)->o.layer)
#define EoGetPixmap(eo) EobjGetPixmap(&((eo)->o))
@ -674,11 +674,12 @@ WinClient;
struct _ewin
{
EObj o;
int shape_x, shape_y;
int req_x, req_y;
int lx, ly, lw, lh, ll;
char type;
char state;
int ld; /* Last desk */
int lx, ly; /* Last pos */
int lw, lh; /* Last size */
int ll; /* Last layer */
char toggle;
Window win_container;
WinClient client;
@ -686,9 +687,8 @@ struct _ewin
const Border *normal_border;
const Border *previous_border;
EWinBit *bits;
int flags;
Group **groups;
int num_groups;
Group **groups;
char visibility;
char docked;
char shown;
@ -752,6 +752,8 @@ struct _ewin
char *wm_name;
char *wm_icon_name;
} ewmh;
int shape_x, shape_y;
int req_x, req_y;
void (*MoveResize) (EWin * ewin, int resize);
void (*Refresh) (EWin * ewin);
void (*Close) (EWin * ewin);
@ -1354,6 +1356,7 @@ void DeskGetArea(int desk, int *ax, int *ay);
void DeskSetArea(int desk, int ax, int ay);
int DeskIsViewable(int desk);
void DeskSetViewable(int desk, int on);
void DeskSetDirtyStack(int desk);
void DeskGetCurrentArea(int *ax, int *ay);
Window DeskGetCurrentRoot(void);
void DeskSetCurrentArea(int ax, int ay);
@ -1369,8 +1372,6 @@ void DesksRefresh(void);
void DeskSetBg(int desk, Background * bg, int refresh);
int DesktopAt(int x, int y);
void DeskGoto(int num);
void DeskRaise(int num);
void DeskLower(int num);
void DeskMove(int num, int x, int y);
void DeskHide(int num);
void DeskShow(int num);

View File

@ -150,7 +150,6 @@ ButtonCreate(const char *name, int id, ImageClass * iclass,
EoSetShadow(b, 0);
EobjListStackAdd(&b->o, 0);
EwinListStackRaise(b);
AddItem(b, b->name, id, LIST_TYPE_BUTTON);

View File

@ -34,6 +34,7 @@ typedef struct
EObj o;
int num;
char viewable;
char dirty_stack;
Background *bg;
Button *tag;
int current_area_x;
@ -46,11 +47,14 @@ typedef struct
typedef struct _desktops
{
int current;
int previous;
Desk *desk[ENLIGHTENMENT_CONF_NUM_DESKTOPS];
int order[ENLIGHTENMENT_CONF_NUM_DESKTOPS];
}
Desktops;
static void DeskRaise(int num);
static void DeskLower(int num);
static void DesktopHandleEvents(XEvent * ev, void *prm);
/* The desktops */
@ -308,6 +312,9 @@ DeskControlsCreate(Desk * d)
}
#endif
/* Restack buttons - Hmmm. */
StackDesktop(d->num);
d->tag = b;
}
@ -550,6 +557,17 @@ DeskSetViewable(int desk, int on)
_DeskGet(desk)->viewable = on;
}
void
DeskSetDirtyStack(int desk)
{
Desk *d = _DeskGet(desk);
if (!d)
return;
d->dirty_stack++;
}
Window
DeskGetCurrentRoot(void)
{
@ -591,6 +609,8 @@ DesksInit(void)
{
int i;
desks.previous = -1;
for (i = 0; i < Conf.desks.num; i++)
DeskCreate(i, 0);
}
@ -603,9 +623,6 @@ DesksResize(int w, int h)
for (i = 0; i < Conf.desks.num; i++)
DeskResize(i, w, h);
/* Restack buttons - Hmmm. */
StackDesktops();
ModulesSignal(ESIGNAL_DESK_RESIZE, NULL);
}
@ -631,8 +648,10 @@ ChangeNumberOfDesktops(int quantity)
return;
pnum = Conf.desks.num;
for (i = quantity; i < Conf.desks.num; i++)
DeskLower(i);
Conf.desks.num = quantity;
if (Conf.desks.num > pnum)
@ -708,9 +727,6 @@ DesksControlsRefresh(void)
DesksControlsCreate();
DesksControlsShow();
/* Restack buttons - Hmmm. */
StackDesktops();
autosave();
}
@ -972,7 +988,6 @@ MoveStickyButtonsToCurrentDesk(void)
void
DeskGoto(int desk)
{
static int pdesk = -1;
Desk *d;
int x, y;
@ -983,7 +998,7 @@ DeskGoto(int desk)
else if (desk < 0)
desk = Conf.desks.num - 1;
}
if (desk < 0 || desk >= Conf.desks.num || desk == pdesk)
if (desk < 0 || desk >= Conf.desks.num || desk == desks.previous)
return;
if (EventDebug(EDBUG_TYPE_DESKS))
@ -1066,7 +1081,6 @@ DeskGoto(int desk)
ModulesSignal(ESIGNAL_DESK_SWITCH_DONE, NULL);
HandleDrawQueue();
pdesk = DesksGetCurrent();
}
void
@ -1182,7 +1196,7 @@ UncoverDesktop(int desk)
EMapWindow(EoGetWin(d));
}
void
static void
DeskRaise(int desk)
{
Desk *d;
@ -1193,38 +1207,41 @@ DeskRaise(int desk)
d = _DeskGet(desk);
if (EventDebug(EDBUG_TYPE_DESKS))
Eprintf("DeskRaise %d\n", desk);
FocusNewDeskBegin();
d->viewable = 1;
DeskRefresh(desk);
MoveToDeskTop(desk);
if (EventDebug(EDBUG_TYPE_DESKS))
Eprintf("DeskRaise(%d) current=%d\n", desk, desks.current);
desks.previous = desks.current = desk;
if (desk == 0)
{
for (i = Conf.desks.num - 1; i > 0; i--)
{
DeskHide(desks.order[i]);
}
DeskHide(desks.order[i]);
}
else
{
EMapWindow(EoGetWin(d));
}
StackDesktops();
desks.current = desk;
MoveStickyWindowsToCurrentDesk();
MoveStickyButtonsToCurrentDesk();
StackDesktop(DesksGetCurrent());
FocusNewDesk();
#if 0 /* FIXME - TBD */
ModulesSignal(ESIGNAL_DESK_SWITCH_DONE, NULL);
#endif
if (Mode.mode == MODE_NONE)
HandleDrawQueue();
{
ModulesSignal(ESIGNAL_DESK_SWITCH_DONE, NULL);
HandleDrawQueue();
}
HintsSetCurrentDesktop();
EMapWindow(EoGetWin(d));
ecore_x_sync();
}
void
static void
DeskLower(int desk)
{
if ((desk <= 0) || (desk >= Conf.desks.num))
@ -1232,19 +1249,25 @@ DeskLower(int desk)
FocusNewDeskBegin();
MoveToDeskBottom(desk);
if (EventDebug(EDBUG_TYPE_DESKS))
Eprintf("DeskLower(%d) %d -> %d\n", desk, desks.current, desks.order[0]);
desks.previous = desks.current = desks.order[0];
UncoverDesktop(desks.order[0]);
DeskHide(desk);
StackDesktops();
desks.current = desks.order[0];
MoveStickyWindowsToCurrentDesk();
MoveStickyButtonsToCurrentDesk();
StackDesktop(DesksGetCurrent());
FocusNewDesk();
#if 0 /* FIXME - TBD */
ModulesSignal(ESIGNAL_DESK_SWITCH_DONE, NULL);
#endif
if (Mode.mode == MODE_NONE)
HandleDrawQueue();
{
ModulesSignal(ESIGNAL_DESK_SWITCH_DONE, NULL);
HandleDrawQueue();
}
HintsSetCurrentDesktop();
ecore_x_sync();
}
@ -1388,11 +1411,11 @@ StackDesktop(int desk)
void
DeskGotoByEwin(EWin * ewin)
{
if (!EoIsSticky(ewin))
{
DeskGoto(EoGetDesk(ewin));
SetCurrentArea(ewin->area_x, ewin->area_y);
}
if (EoIsSticky(ewin) || EoIsFloating(ewin))
return;
DeskGoto(EoGetDesk(ewin));
SetCurrentArea(ewin->area_x, ewin->area_y);
}
static char sentpress = 0;

View File

@ -54,7 +54,9 @@ EobjSetDesk(EObj * eo, int desk)
eo->desk = desk;
break;
case EOBJ_TYPE_EWIN:
if (eo->sticky || eo->floating || eo->desk < 0)
if (eo->floating)
eo->desk = 0;
else if (eo->sticky || eo->desk < 0)
eo->desk = DesksGetCurrent();
else
eo->desk = desk % Conf.desks.num;
@ -128,6 +130,7 @@ EobjSetFloating(EObj * eo, int floating)
return;
eo->floating = floating;
eo->desk = 0;
EobjSetLayer(eo, eo->layer);
}

View File

@ -1285,18 +1285,15 @@ MoveEwinToDesktopAt(EWin * ewin, int desk, int x, int y)
EoGetDesk(ewin), desk);
#endif
pdesk = EoGetDesk(ewin);
pdesk = ewin->ld;
desk = desk % Conf.desks.num;
EoSetDesk(ewin, desk);
if (desk != pdesk && !EoIsSticky(ewin))
{
#if 0 /* Not necessary when the the _XROOT... atoms are initially set on each desk */
/* Refresh bg before apps are planted so they can pick it up */
DeskSetViewable(desk, 1);
DeskRefresh(desk);
#endif
EoSetDesk(ewin, desk);
SnapshotEwinUpdate(ewin, SNAP_USE_DESK);
ModulesSignal(ESIGNAL_DESK_CHANGE, (void *)pdesk);
if (pdesk >= 0)
ModulesSignal(ESIGNAL_DESK_CHANGE, (void *)pdesk);
}
dx = x - EoGetX(ewin);

View File

@ -67,6 +67,7 @@ EwinCreate(Window win, int type)
ewin->type = type;
ewin->state = (Mode.wm.startup) ? EWIN_STATE_STARTUP : EWIN_STATE_NEW;
ewin->ld = -1;
ewin->lx = -1;
ewin->ly = -1;
ewin->lw = -1;
@ -837,10 +838,12 @@ AddToFamily(EWin * ewin, Window win)
unsigned int mask;
Window junk, root_return;
#if 0 /* FIXME: Disable for now */
/* if the loser has manual placement on and the app asks to be on */
/* a desktop, then send E to that desktop so the user can place */
/* the window there */
DeskGoto(desk);
#endif
XQueryPointer(disp, VRoot.win, &root_return, &junk, &rx, &ry, &wx, &wy,
&mask);
@ -1410,9 +1413,14 @@ FloatEwinAt(EWin * ewin, int x, int y)
return;
if (EoIsFloating(ewin))
EoSetFloating(ewin, 2);
{
EoSetFloating(ewin, 2);
}
else
EoSetFloating(ewin, 1);
{
ewin->ld = EoGetDesk(ewin);
EoSetFloating(ewin, 1);
}
dx = x - EoGetX(ewin);
dy = y - EoGetY(ewin);

View File

@ -104,8 +104,6 @@ ActionMoveEnd(EWin * ewin)
return 0;
}
d = DesktopAt(Mode.x, Mode.y);
gwins = ListWinGroupMembersForEwin(ewin, GROUP_ACTION_MOVE, Mode.nogroup
|| Mode.move.swap, &num);
@ -124,6 +122,8 @@ ActionMoveEnd(EWin * ewin)
}
Mode.mode = MODE_NONE;
d = DesktopAt(Mode.x, Mode.y);
for (i = 0; i < num; i++)
{
if ((EoIsFloating(gwins[i])) || (Conf.movres.mode_move > 0))

View File

@ -35,8 +35,12 @@ struct _eobjlist
int nalloc;
int nwins;
EObj **list;
char layered;
};
static int EobjListRaise(EobjList * ewl, EObj * eo);
static int EobjListLower(EobjList * ewl, EObj * eo);
#if ENABLE_DEBUG_STACKING
static void
EobjListShow(const char *txt, EobjList * ewl)
@ -52,8 +56,7 @@ EobjListShow(const char *txt, EobjList * ewl)
{
eo = ewl->list[i];
Eprintf(" %2d: %#10lx %#10lx %d %d %s\n", i, eo->win,
EobjGetCwin(eo), eo->desk,
(eo->floating) ? 999 : eo->ilayer, EobjGetName(eo));
EobjGetCwin(eo), eo->desk, eo->ilayer, EobjGetName(eo));
}
}
#else
@ -88,14 +91,34 @@ EobjListAdd(EobjList * ewl, EObj * eo, int ontop)
ewl->list = (EObj **) Erealloc(ewl->list, ewl->nalloc * sizeof(EObj *));
}
if (ontop)
if (ewl->layered)
{
memmove(ewl->list + 1, ewl->list, ewl->nwins * sizeof(EObj *));
ewl->list[0] = eo;
/* The simple way for now (add, raise/lower) */
if (ontop)
{
ewl->list[ewl->nwins] = eo;
EobjListRaise(ewl, eo);
}
else
{
memmove(ewl->list + 1, ewl->list, ewl->nwins * sizeof(EObj *));
ewl->list[0] = eo;
EobjListLower(ewl, eo);
}
DeskSetDirtyStack(eo->desk);
}
else
{
ewl->list[ewl->nwins] = eo;
if (ontop)
{
memmove(ewl->list + 1, ewl->list, ewl->nwins * sizeof(EObj *));
ewl->list[0] = eo;
}
else
{
ewl->list[ewl->nwins] = eo;
}
}
ewl->nwins++;
@ -130,7 +153,7 @@ EobjListDel(EobjList * ewl, EObj * eo)
}
static int
EobjListLower(EobjList * ewl, EObj * eo, int mode)
EobjListLower(EobjList * ewl, EObj * eo)
{
int i, j, n;
@ -140,7 +163,7 @@ EobjListLower(EobjList * ewl, EObj * eo, int mode)
return 0;
j = ewl->nwins - 1;
if (mode)
if (ewl->layered)
{
/* Take the layer into account */
for (; j >= 0; j--)
@ -155,11 +178,15 @@ EobjListLower(EobjList * ewl, EObj * eo, int mode)
{
memmove(ewl->list + i, ewl->list + i + 1, n * sizeof(EObj *));
ewl->list[j] = eo;
if (ewl->layered)
DeskSetDirtyStack(eo->desk);
}
else if (n < 0)
{
memmove(ewl->list + j + 1, ewl->list + j, -n * sizeof(EObj *));
ewl->list[j] = eo;
if (ewl->layered)
DeskSetDirtyStack(eo->desk);
}
EobjListShow("EobjListLower", ewl);
@ -167,7 +194,7 @@ EobjListLower(EobjList * ewl, EObj * eo, int mode)
}
static int
EobjListRaise(EobjList * ewl, EObj * eo, int mode)
EobjListRaise(EobjList * ewl, EObj * eo)
{
int i, j, n;
@ -177,7 +204,7 @@ EobjListRaise(EobjList * ewl, EObj * eo, int mode)
return 0;
j = 0;
if (mode)
if (ewl->layered)
{
/* Take the layer into account */
for (; j < ewl->nwins; j++)
@ -192,11 +219,15 @@ EobjListRaise(EobjList * ewl, EObj * eo, int mode)
{
memmove(ewl->list + i, ewl->list + i + 1, n * sizeof(EObj *));
ewl->list[j] = eo;
if (ewl->layered)
DeskSetDirtyStack(eo->desk);
}
else if (n < 0)
{
memmove(ewl->list + j + 1, ewl->list + j, -n * sizeof(EObj *));
ewl->list[j] = eo;
if (ewl->layered)
DeskSetDirtyStack(eo->desk);
}
EobjListShow("EobjListRaise", ewl);
@ -230,8 +261,8 @@ EobjListTypeCount(const EobjList * ewl, int type)
/*
* The global stacking and focus lists
*/
EobjList EwinListStack = { "Stack", 0, 0, NULL };
EobjList EwinListFocus = { "Focus", 0, 0, NULL };
EobjList EwinListStack = { "Stack", 0, 0, NULL, 1 };
EobjList EwinListFocus = { "Focus", 0, 0, NULL, 0 };
static EObj *const *
EobjListGet(EobjList * ewl, int *num)
@ -279,19 +310,19 @@ EobjListFocusDel(EObj * eo)
int
EobjListStackRaise(EObj * eo)
{
return EobjListRaise(&EwinListStack, eo, 1);
return EobjListRaise(&EwinListStack, eo);
}
int
EobjListStackLower(EObj * eo)
{
return EobjListLower(&EwinListStack, eo, 1);
return EobjListLower(&EwinListStack, eo);
}
int
EobjListFocusRaise(EObj * eo)
{
return EobjListRaise(&EwinListFocus, eo, 0);
return EobjListRaise(&EwinListFocus, eo);
}
EWin *const *
@ -382,7 +413,7 @@ EobjListStackGetForDesk(int *num, int desk)
for (i = j = 0; i < ewl->nwins; i++)
{
eo = ewl->list[i];
if (eo->desk != desk && !eo->sticky && !eo->floating)
if (eo->desk != desk)
continue;
lst[j++] = eo;