1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-26 08:22:37 +01:00

- Added support for NET_WM_NAME/NET_WM_ICON_NAME

- moved out font name conversion code from getstyle/setstyle/convertfonts and made it support fontsets
This commit is contained in:
kojima
2004-10-16 22:05:04 +00:00
parent 9402724e40
commit 7055530895
17 changed files with 305 additions and 549 deletions

View File

@@ -325,25 +325,31 @@ wClientCheckProperty(WWindow *wwin, XPropertyEvent *event)
switch (event->atom) {
case XA_WM_NAME:
/* window title was changed */
if (!wFetchName(dpy, wwin->client_win, &tmp)) {
wWindowUpdateName(wwin, NULL);
} else {
wWindowUpdateName(wwin, tmp);
if (!wwin->flags.net_has_title)
{
/* window title was changed */
if (!wFetchName(dpy, wwin->client_win, &tmp)) {
wWindowUpdateName(wwin, NULL);
} else {
wWindowUpdateName(wwin, tmp);
}
if (tmp)
XFree(tmp);
}
if (tmp)
XFree(tmp);
break;
case XA_WM_ICON_NAME:
if (!wwin->icon)
break;
else {
char *new_title;
/* icon title was changed */
wGetIconName(dpy, wwin->client_win, &new_title);
wIconChangeTitle(wwin->icon, new_title);
if (!wwin->flags.net_has_icon_title)
{
if (!wwin->icon)
break;
else {
char *new_title;
/* icon title was changed */
wGetIconName(dpy, wwin->client_win, &new_title);
wIconChangeTitle(wwin->icon, new_title);
}
}
break;

View File

@@ -43,8 +43,9 @@
#include "application.h"
#include "defaults.h"
#include "appicon.h"
#include "wmspec.h"
/**** Global variables ****/
/**** Global varianebles ****/
extern WPreferences wPreferences;
#define MOD_MASK wPreferences.modifier_mask
@@ -179,7 +180,11 @@ wIconCreate(WWindow *wwin)
icon->file = wstrdup(file);
}
wGetIconName(dpy, wwin->client_win, &icon->icon_name);
icon->icon_name = wNETWMGetIconName(wwin->client_win);
if (icon->icon_name)
wwin->flags.net_has_icon_title= 1;
else
wGetIconName(dpy, wwin->client_win, &icon->icon_name);
icon->tile_type = TILE_NORMAL;

View File

@@ -1084,8 +1084,6 @@ wScreenSaveState(WScreen *scr)
WWindow *wwin;
char *str;
WMPropList *old_state, *foo;
CARD32 data[2];
make_keys();

View File

@@ -36,6 +36,7 @@
#include "properties.h"
#include "session.h"
#include "winspector.h"
#include "wmspec.h"
extern Atom _XA_WM_DELETE_WINDOW;
extern Time LastTimestamp;
@@ -197,6 +198,7 @@ RestoreDesktop(WScreen *scr)
XSetInputFocus(dpy, PointerRoot, RevertToParent, CurrentTime);
wColormapInstallForWindow(scr, NULL);
PropCleanUp(scr->root_win);
wNETWMCleanup(scr);
XSync(dpy, 0);
}

View File

@@ -722,12 +722,14 @@ wManageWindow(WScreen *scr, Window window)
return NULL;
}
if (!wFetchName(dpy, window, &title)) {
title = NULL;
}
wwin = wWindowCreate();
title= wNETWMGetWindowName(window);
if (title)
wwin->flags.net_has_title= 1;
if (!title && !wFetchName(dpy, window, &title))
title = NULL;
XSaveContext(dpy, window, wWinContext, (XPointer)&wwin->client_descriptor);
#ifdef DEBUG

View File

@@ -304,6 +304,8 @@ typedef struct WWindow {
unsigned int net_skip_pager:1;
unsigned int net_handle_icon:1;
unsigned int net_show_desktop:1;
unsigned int net_has_title:1; /* use netwm version of WM_NAME */
unsigned int net_has_icon_title:1;
#endif
} flags; /* state of the window */

View File

@@ -74,10 +74,10 @@ static Atom net_moveresize_window; /* TODO */
static Atom net_wm_moveresize; /* TODO */
/* Application Window Properties */
static Atom net_wm_name; /* TODO */
static Atom net_wm_visible_name; /* TODO */
static Atom net_wm_icon_name; /* TODO */
static Atom net_wm_visible_icon_name; /* TODO */
static Atom net_wm_name;
static Atom net_wm_visible_name; /* TODO (unnecessary?) */
static Atom net_wm_icon_name;
static Atom net_wm_visible_icon_name; /* TODO (unnecessary?) */
static Atom net_wm_desktop;
static Atom net_wm_window_type;
static Atom net_wm_window_type_desktop;
@@ -295,6 +295,9 @@ setSupportedHints(WScreen *scr)
atom[i++] = net_wm_icon_geometry;
atom[i++] = net_wm_icon;
atom[i++] = net_wm_handled_icons;
atom[i++] = net_wm_name;
atom[i++] = net_wm_icon_name;
XChangeProperty(dpy, scr->root_win, net_supported, XA_ATOM, 32,
PropModeReplace, (unsigned char*)atom, i);
@@ -535,6 +538,16 @@ wNETWMInitStuff(WScreen *scr)
}
void
wNETWMCleanup(WScreen *scr)
{
int i;
for (i= 0; i < atomNr; i++)
XDeleteProperty(dpy, scr->root_win, *atomNames[i].atom);
}
void
wNETWMUpdateActions(WWindow *wwin, Bool del)
{
@@ -1018,6 +1031,7 @@ doStateAtom(WWindow *wwin, Atom state, int set, Bool init)
}
}
} else if (state == net_wm_state_fullscreen) {
puts("GoT FS ST");
if (set == _NET_WM_STATE_TOGGLE) {
set = !(wwin->flags.fullscreen);
}
@@ -1502,6 +1516,15 @@ wNETWMCheckClientHintChange(WWindow *wwin, XPropertyEvent *event)
updateNetIconInfo(wwin);
} else if (event->atom == net_wm_window_type) {
updateWindowType(wwin);
} else if (event->atom == net_wm_name) {
char *name= wNETWMGetWindowName(wwin->client_win);
wWindowUpdateName(wwin, name);
if (name) wfree(name);
} else if (event->atom == net_wm_icon_name) {
if (wwin->icon) {
char *name= wNETWMGetIconName(wwin->client_win);
wIconChangeTitle(wwin->icon, name);
}
} else {
ret = False;
}
@@ -1535,6 +1558,46 @@ wNETWMGetPidForWindow(Window window)
}
char*
wNETWMGetWindowName(Window window)
{
char *name;
char *ret;
int size;
name= (char*)PropGetCheckProperty(window,
net_wm_name, utf8_string, 0,
0, &size);
if (name) {
ret= wstrndup(name, size);
XFree(name);
}
else
ret= NULL;
return ret;
}
char*
wNETWMGetIconName(Window window)
{
char *name;
char *ret;
int size;
name= (char*)PropGetCheckProperty(window,
net_wm_icon_name, utf8_string, 0,
0, &size);
if (name) {
ret= wstrndup(name, size);
XFree(name);
}
else
ret= NULL;
return ret;
}
static void
observer(void *self, WMNotification *notif)
{

View File

@@ -30,6 +30,7 @@
#include <X11/Xlib.h>
void wNETWMInitStuff(WScreen *scr);
void wNETWMCleanup(WScreen *scr);
void wNETWMUpdateWorkarea(WScreen *scr, WArea usableArea);
Bool wNETWMGetUsableArea(WScreen *scr, int head, WArea *area);
Bool wNETWMCheckInitialClientState(WWindow *wwin);
@@ -42,4 +43,6 @@ void wNETWMUpdateDesktop(WScreen *scr);
void wNETWMPositionSplash(WWindow *wwin, int *x, int *y, int width, int height);
int wNETWMGetPidForWindow(Window window);
int wNETWMGetCurrentDesktopFromHint(WScreen *scr);
char *wNETWMGetIconName(Window window);
char *wNETWMGetWindowName(Window window);
#endif