Get the window placement right, I hope.

SVN revision: 10596
This commit is contained in:
Kim Woelders 2004-06-27 15:59:32 +00:00
parent fe129f815e
commit a2ac120094
6 changed files with 100 additions and 63 deletions

View File

@ -1737,6 +1737,7 @@ void BackgroundsInit(void);
#define EWIN_CHANGE_DESKTOP (1<<3)
#define EWIN_CHANGE_LAYER (1<<4)
void EwinGetPosition(EWin * ewin, int *px, int *py);
void EwinRefresh(EWin * ewin);
void EwinUpdateAfterMoveResize(EWin * ewin, int resize);
void EwinFixPosition(EWin * ewin);

View File

@ -485,8 +485,8 @@ AddToFamily(Window win)
}
/* if it hasn't been placed yet.... find a spot for it */
x = 0;
y = 0;
x = ewin->x;
y = ewin->y;
if ((!ewin->client.already_placed) && (!manplace))
{
@ -536,53 +536,6 @@ AddToFamily(Window win)
ArrangeEwinXY(ewin, &x, &y);
} /* (Conf.manual_placement_mouse_pointer) */
} /* ((!ewin->client.already_placed) && (!manplace)) */
else
{
x = ewin->x;
y = ewin->y;
switch (ewin->client.grav)
{
case NorthWestGravity:
x += (ewin->client.bw * 2);
y += (ewin->client.bw * 2);
break;
case NorthGravity:
y += (ewin->client.bw * 2);
break;
case NorthEastGravity:
y += (ewin->client.bw * 2);
if (ewin->border)
x -= ewin->border->border.left + (ewin->client.bw * 2);
break;
case EastGravity:
if (ewin->border)
x -= ewin->border->border.left + (ewin->client.bw * 2);
break;
case SouthEastGravity:
if (ewin->border)
{
x -= ewin->border->border.left + (ewin->client.bw * 2);
y -= ewin->border->border.top + (ewin->client.bw * 2);
}
break;
case SouthGravity:
if (ewin->border)
y -= ewin->border->border.top + (ewin->client.bw * 2);
break;
case SouthWestGravity:
x += (ewin->client.bw * 2);
if (ewin->border)
y -= ewin->border->border.top + (ewin->client.bw * 2);
break;
case WestGravity:
x += (ewin->client.bw * 2);
break;
case CenterGravity:
break;
default:
break;
}
}
/* if the window asked to be iconified at the start */
if (ewin->client.start_iconified)
@ -1149,11 +1102,82 @@ HonorIclass(char *s, int id)
EDBUG_RETURN_;
}
/*
* Derive frame window position from client window and border properties
*/
void
EwinGetPosition(EWin * ewin, int *px, int *py)
{
int x, y, bw, frame_lr, frame_tb;
x = ewin->client.x;
y = ewin->client.y;
bw = ewin->client.bw;
frame_lr = ewin->border->border.left + ewin->border->border.right;
frame_tb = ewin->border->border.top + ewin->border->border.bottom;
switch (ewin->client.grav)
{
case NorthWestGravity:
case SouthWestGravity:
case WestGravity:
x -= bw;
break;
case NorthEastGravity:
case EastGravity:
case SouthEastGravity:
x -= frame_lr / 2;
break;
case NorthGravity:
case CenterGravity:
case SouthGravity:
x -= frame_lr - bw;
break;
default:
break;
}
switch (ewin->client.grav)
{
case NorthWestGravity:
case NorthGravity:
case NorthEastGravity:
y -= bw;
break;
case WestGravity:
case CenterGravity:
case EastGravity:
y -= frame_tb / 2;
break;
case SouthWestGravity:
case SouthGravity:
case SouthEastGravity:
y -= frame_tb - bw;
break;
default:
break;
}
*px = x;
*py = y;
}
/*
* Derive frame window geometry from client window properties
*/
static void
EwinGetGeometry(EWin * ewin)
{
ewin->shape_x = ewin->x = ewin->client.x - ewin->border->border.left;
ewin->shape_y = ewin->y = ewin->client.y - ewin->border->border.top;
int x, y;
EwinGetPosition(ewin, &x, &y);
ewin->client.x = x + ewin->border->border.left;
ewin->client.y = y + ewin->border->border.top;
ewin->shape_x = ewin->x = x;
ewin->shape_y = ewin->y = y;
ewin->w = ewin->client.w +
ewin->border->border.left + ewin->border->border.right;
ewin->h = ewin->client.h +
@ -3432,8 +3456,7 @@ EwinsSetFree(void)
/* This makes E determine the client window stacking at exit */
EReparentWindow(disp, ewin->client.win, VRoot.win,
ewin->x + ewin->border->border.left,
ewin->y + ewin->border->border.top);
ewin->client.x, ewin->client.y);
}
}

View File

@ -779,8 +779,8 @@ HandleConfigureRequest(XEvent * ev)
ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN);
if (ewin)
{
x = ewin->x + ewin->border->border.left;
y = ewin->y + ewin->border->border.top;
x = ewin->x;
y = ewin->y;
w = ewin->client.w;
h = ewin->client.h;
winrel = 0;
@ -831,9 +831,16 @@ HandleConfigureRequest(XEvent * ev)
if (h > ewin->client.height.max)
ewin->client.height.max = h;
if (ev->xconfigurerequest.value_mask & (CWX | CWY))
{
/* Correct position taking gravity into account */
ewin->client.x = x;
ewin->client.y = y;
EwinGetPosition(ewin, &x, &y);
}
Mode.move.check = 0; /* Don't restrict client requests */
MoveResizeEwin(ewin, x - ewin->border->border.left,
y - ewin->border->border.top, w, h);
MoveResizeEwin(ewin, x, y, w, h);
Mode.move.check = 1;
if (Mode.mode == MODE_MOVE_PENDING || Mode.mode == MODE_MOVE)
ICCCM_Configure(ewin);

View File

@ -390,7 +390,10 @@ ICCCM_Adopt(EWin * ewin)
EDBUG(6, "ICCCM_Adopt");
if (!ewin->internal)
XSetWindowBorderWidth(disp, win, 0);
{
XSetWindowBorderWidth(disp, win, 0);
ewin->client.bw = 0;
}
EReparentWindow(disp, win, ewin->win_container, 0, 0);
c[0] = (ewin->client.start_iconified) ? IconicState : NormalState;
XChangeProperty(disp, win, E_XA_WM_STATE, E_XA_WM_STATE, 32, PropModeReplace,
@ -1067,8 +1070,8 @@ ICCCM_SetEInfo(EWin * ewin)
aa = XInternAtom(disp, "ENL_INTERNAL_DATA_BORDER", False);
c[0] = ewin->desktop;
c[1] = ewin->sticky;
c[2] = ewin->client.x;
c[3] = ewin->client.y;
c[2] = ewin->x;
c[3] = ewin->y;
c[4] = ewin->iconified;
if (ewin->iconified)
ICCCM_DeIconify(ewin);
@ -1179,6 +1182,7 @@ ICCCM_GetEInfo(EWin * ewin)
ewin->sticky = c[1];
ewin->client.x = c[2];
ewin->client.y = c[3];
ewin->client.grav = NorthWestGravity;
ewin->iconified = c[4];
ewin->shaded = c[5];
if (ewin->sticky)

View File

@ -236,7 +236,7 @@ SaveWindowStates(void)
y = desks.desk[ewin->desktop].current_area_y * VRoot.h;
}
fprintf(f, "[CLIENT] %i %i %i %i %i %i %i %i %i\n",
ewin->client.x + x, ewin->client.y + y, ewin->client.w,
ewin->x + x, ewin->y + y, ewin->client.w,
ewin->client.h, ewin->desktop, ewin->iconified,
ewin->shaded, ewin->sticky, ewin->layer);
if (ewin->session_id)
@ -412,6 +412,7 @@ MatchEwinToSM(EWin * ewin)
(desks.desk[ewin->desktop].current_area_x * VRoot.w);
ewin->client.y = matches[i].y -
(desks.desk[ewin->desktop].current_area_y * VRoot.h);
ewin->client.grav = NorthWestGravity;
ewin->client.w = matches[i].w;
ewin->client.h = matches[i].h;
EMoveResizeWindow(disp, ewin->client.win, ewin->client.x,

View File

@ -629,8 +629,8 @@ SnapshotEwinLocation(EWin * ewin)
if (!sn)
return;
sn->use_xy = 1;
sn->x = ewin->client.x;
sn->y = ewin->client.y;
sn->x = ewin->x;
sn->y = ewin->y;
sn->area_x = ewin->area_x;
sn->area_y = ewin->area_y;
if (!ewin->sticky)
@ -1173,6 +1173,7 @@ MatchEwinToSnapInfo(EWin * ewin)
ewin->client.already_placed = 1;
ewin->client.x = sn->x;
ewin->client.y = sn->y;
ewin->client.grav = NorthWestGravity;
ewin->area_x = sn->area_x;
ewin->area_y = sn->area_y;
if (!ewin->sticky)