Center unplaced dialogs on "parent"(if transient) or root.

SVN revision: 26802
This commit is contained in:
Kim Woelders 2006-10-26 20:25:30 +00:00
parent 7a6a93ccd5
commit 61d37a137e
3 changed files with 45 additions and 5 deletions

View File

@ -835,7 +835,6 @@ AddToFamily(EWin * ewin, Window xwin)
EQueryPointer(NULL, &rx, &ry, NULL, NULL);
Mode.events.x = rx;
Mode.events.y = ry;
ewin->state.placed = 1;
/* try to center the window on the mouse pointer */
newWinX = rx;
@ -855,11 +854,23 @@ AddToFamily(EWin * ewin, Window xwin)
x = newWinX;
y = newWinY;
}
else if (ewin->ewmh.type.b.dialog)
{
/* Center unplaced dialogs on parent(if transient) or root */
Win parent;
ewin2 = NULL;
if (EwinGetTransientFor(ewin) != None)
ewin2 = EwinFindByClient(EwinGetTransientFor(ewin));
parent = (ewin2) ? EoGetWin(ewin) : VRoot.win;
x = (WinGetW(parent) - EoGetW(ewin)) / 2;
y = (WinGetH(parent) - EoGetH(ewin)) / 2;
}
else
{
ewin->state.placed = 1;
ArrangeEwinXY(ewin, &x, &y);
}
ewin->state.placed = 1;
}
/* if the window asked to be iconified at the start */

View File

@ -205,6 +205,21 @@ struct _ewin
XID sync_request_counter;
long long sync_request_count;
#endif
union
{
unsigned char all;
struct
{
unsigned desktop:1;
unsigned dock:1;
unsigned toolbar:1;
unsigned menu:1;
unsigned utility:1;
unsigned splash:1;
unsigned dialog:1;
unsigned normal:1;
} b;
} type;
} ewmh;
struct
{

View File

@ -564,11 +564,19 @@ EWMH_GetWindowType(EWin * ewin)
Ecore_X_Atom *p_atoms, atom;
int n_atoms;
ewin->ewmh.type.all = 0;
n_atoms = ecore_x_window_prop_atom_list_get(EwinGetClientXwin(ewin),
ECORE_X_ATOM_NET_WM_WINDOW_TYPE,
&p_atoms);
if (n_atoms <= 0)
return;
{
if (EwinIsTransient(ewin))
ewin->ewmh.type.b.dialog = 1;
else
ewin->ewmh.type.b.normal = 1;
return;
}
atom = p_atoms[0];
if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DESKTOP)
@ -581,6 +589,7 @@ EWMH_GetWindowType(EWin * ewin)
EwinInhSetUser(ewin, size, 1);
ewin->props.donthide = 1;
ewin->props.no_border = 1;
ewin->ewmh.type.b.desktop = 1;
}
else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DOCK)
{
@ -589,6 +598,7 @@ EWMH_GetWindowType(EWin * ewin)
ewin->props.skip_focuslist = 1;
EoSetSticky(ewin, 1);
ewin->props.donthide = 1;
ewin->ewmh.type.b.dock = 1;
}
else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_UTILITY)
{
@ -598,24 +608,28 @@ EWMH_GetWindowType(EWin * ewin)
ewin->props.skip_focuslist = 1;
ewin->props.never_use_area = 1;
ewin->props.donthide = 1;
ewin->ewmh.type.b.utility = 1;
}
#if 0 /* Not used by E (yet?) */
else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLBAR)
{
ewin->ewmh.type.b.toolbar = 1;
}
else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_MENU)
{
ewin->ewmh.type.b.menu = 1;
}
else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_SPLASH)
{
ewin->ewmh.type.b.splash = 1;
}
else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DIALOG)
{
ewin->ewmh.type.b.dialog = 1;
}
else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NORMAL)
{
ewin->ewmh.type.b.normal = 1;
}
#endif
Efree(p_atoms);
}