Clean up setting internal window name/class hints.

SVN revision: 10320
This commit is contained in:
Kim Woelders 2004-05-22 19:31:13 +00:00
parent 7b5aad2708
commit a917263310
8 changed files with 68 additions and 63 deletions

View File

@ -2068,8 +2068,9 @@ void EWMH_SetDesktopViewport(void);
void EWMH_SetWorkArea(void);
void EWMH_SetClientList(void);
void EWMH_SetClientStacking(void);
void EWMH_SetActiveWindow(const EWin * ewin);
void EWMH_SetActiveWindow(Window win);
void EWMH_SetShowingDesktop(int on);
void EWMH_SetWindowName(Window win, const char *name);
void EWMH_SetWindowDesktop(const EWin * ewin);
void EWMH_SetWindowState(const EWin * ewin);
void EWMH_GetWindowName(EWin * ewin);
@ -2247,7 +2248,10 @@ void HintsSetCurrentDesktop(void);
void HintsSetDesktopViewport(void);
void HintsSetClientList(void);
void HintsSetClientStacking(void);
void HintsSetActiveWindow(EWin * ewin);
void HintsSetActiveWindow(Window win);
void HintsSetWindowName(Window win, const char *name);
void HintsSetWindowClass(Window win, const char *name,
const char *clss);
void HintsSetWindowDesktop(EWin * ewin);
void HintsSetWindowArea(EWin * ewin);
void HintsSetWindowState(EWin * ewin);

View File

@ -607,22 +607,12 @@ ShowDialog(Dialog * d)
char pq;
int i, w, h, mw, mh;
EWin *ewin;
XTextProperty xtp;
XClassHint *xch;
Snapshot *sn;
if (d->title)
{
xtp.encoding = XA_STRING;
xtp.format = 8;
xtp.value = (unsigned char *)(d->title);
xtp.nitems = strlen((char *)(xtp.value));
XSetWMName(disp, d->win, &xtp);
xch = XAllocClassHint();
xch->res_name = d->name;
xch->res_class = (char *)"Enlightenment_Dialog";
XSetClassHint(disp, d->win, xch);
XFree(xch);
HintsSetWindowName(d->win, d->title);
HintsSetWindowClass(d->win, d->name, "Enlightenment_Dialog");
}
ewin = FindEwinByDialog(d);

View File

@ -417,13 +417,11 @@ EWMH_SetClientStacking(void)
}
void
EWMH_SetActiveWindow(const EWin * ewin)
EWMH_SetActiveWindow(Window win)
{
static Window win_last_set;
Window win;
EDBUG(6, "EWMH_SetActiveWindow");
win = (ewin) ? ewin->client.win : None;
if (win != win_last_set)
{
_ATOM_SET_WINDOW(_NET_ACTIVE_WINDOW, VRoot.win, &win, 1);
@ -447,6 +445,12 @@ EWMH_SetShowingDesktop(int on)
* Functions that set X11-properties from E-window internals
*/
void
EWMH_SetWindowName(Window win, const char *name)
{
_ATOM_SET_UTF8_STRING(_NET_WM_NAME, win, name);
}
void
EWMH_SetWindowDesktop(const EWin * ewin)
{

View File

@ -134,15 +134,50 @@ HintsSetDesktopViewport(void)
}
void
HintsSetActiveWindow(EWin * ewin)
HintsSetActiveWindow(Window win)
{
EDBUG(6, "HintsSetActiveWindow");
#if ENABLE_EWMH
EWMH_SetActiveWindow(ewin);
EWMH_SetActiveWindow(win);
#endif
EDBUG_RETURN_;
}
void
HintsSetWindowName(Window win, const char *name)
{
XTextProperty xtp;
EDBUG(6, "HintsSetWindowName");
xtp.encoding = XA_STRING;
xtp.format = 8;
xtp.value = (unsigned char *)name;
xtp.nitems = strlen(name);
XSetWMName(disp, win, &xtp);
#if ENABLE_EWMH
EWMH_SetWindowName(win, name);
#endif
EDBUG_RETURN_;
}
void
HintsSetWindowClass(Window win, const char *name, const char *clss)
{
XClassHint *xch;
EDBUG(6, "HintsSetWindowClass");
xch = XAllocClassHint();
xch->res_name = (char *)name;
xch->res_class = (char *)clss;
XSetClassHint(disp, win, xch);
XFree(xch);
EDBUG_RETURN_;
}
void
HintsSetWindowDesktop(EWin * ewin)
{

View File

@ -487,7 +487,7 @@ ICCCM_Focus(EWin * ewin)
if (!ewin)
{
XSetInputFocus(disp, VRoot.win, RevertToPointerRoot, CurrentTime);
HintsSetActiveWindow(ewin);
HintsSetActiveWindow(None);
EDBUG_RETURN_;
}
@ -511,7 +511,7 @@ ICCCM_Focus(EWin * ewin)
}
/* else */
XSetInputFocus(disp, ewin->client.win, RevertToPointerRoot, CurrentTime);
HintsSetActiveWindow(ewin);
HintsSetActiveWindow(ewin->client.win);
EDBUG_RETURN_;
}

View File

@ -585,23 +585,16 @@ void
IconboxShow(Iconbox * ib)
{
EWin *ewin = NULL;
XClassHint *xch;
XTextProperty xtp;
char pq;
pq = Mode.queue_up;
Mode.queue_up = 0;
xtp.encoding = XA_STRING;
xtp.format = 8;
xtp.value = (unsigned char *)("Iconbox");
xtp.nitems = strlen((char *)(xtp.value));
XSetWMName(disp, ib->win, &xtp);
xch = XAllocClassHint();
xch->res_name = ib->name;
xch->res_class = (char *)"Enlightenment_IconBox";
XSetClassHint(disp, ib->win, xch);
XFree(xch);
HintsSetWindowName(ib->win, "Iconbox");
HintsSetWindowClass(ib->win, ib->name, "Enlightenment_IconBox");
MatchToSnapInfoIconbox(ib);
ewin = AddInternalToFamily(ib->win, "ICONBOX", EWIN_TYPE_ICONBOX, ib,
IconboxEwinInit);
if (ewin)

View File

@ -638,12 +638,11 @@ MenuAddStyle(Menu * menu, const char *style)
void
MenuRealize(Menu * m)
{
int i, maxh = 0, maxw =
0, maxx1, maxx2, w, h, x, y, r, mmw, mmh;
int i, maxh = 0, maxw = 0;
int maxx1, maxx2, w, h, x, y, r, mmw, mmh;
unsigned int iw, ih;
Imlib_Image *im;
XSetWindowAttributes att;
XTextProperty xtp;
char pq, has_i, has_s;
EDBUG(5, "MenuRealize");
@ -655,12 +654,9 @@ MenuRealize(Menu * m)
if (m->title)
{
xtp.encoding = XA_STRING;
xtp.format = 8;
xtp.value = (unsigned char *)(m->title);
xtp.nitems = strlen((char *)(xtp.value));
XSetWMName(disp, m->win, &xtp);
HintsSetWindowName(m->win, m->title);
}
maxh = 0;
maxx1 = 0;
maxx2 = 0;

View File

@ -312,7 +312,6 @@ void
PagerShow(Pager * p)
{
EWin *ewin = NULL;
XClassHint *xch;
char s[4096];
char pq;
@ -326,14 +325,13 @@ PagerShow(Pager * p)
}
Esnprintf(s, sizeof(s), "%i", p->desktop);
xch = XAllocClassHint();
xch->res_name = s;
xch->res_class = (char *)"Enlightenment_Pager";
XSetClassHint(disp, p->win, xch);
XFree(xch);
HintsSetWindowClass(p->win, s, "Enlightenment_Pager");
pq = Mode.queue_up;
Mode.queue_up = 0;
MatchToSnapInfoPager(p);
ewin = AddInternalToFamily(p->win, (p->border_name) ? p->border_name :
"PAGER", EWIN_TYPE_PAGER, p, PagerEwinInit);
if (ewin)
@ -1023,21 +1021,6 @@ PagerHide(Pager * p)
HideEwin(p->ewin);
}
static void
PagerTitle(Pager * p, char *title)
{
XTextProperty xtp;
if (!Conf.pagers.enable)
return;
xtp.encoding = XA_STRING;
xtp.format = 8;
xtp.value = (unsigned char *)(title);
xtp.nitems = strlen((char *)(xtp.value));
XSetWMName(disp, p->win, &xtp);
}
void
UpdatePagerSel(void)
{
@ -1427,7 +1410,7 @@ NewPagerForDesktop(int desk)
{
p->desktop = desk;
Esnprintf(s, sizeof(s), "%i", desk);
PagerTitle(p, s);
HintsSetWindowName(p->win, s);
PagerShow(p);
}
}