1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-03 23:05:46 +01:00

added some netwm support in WINGs

This commit is contained in:
kojima
2004-10-23 21:07:13 +00:00
parent 9ead135f51
commit df1228f387
9 changed files with 137 additions and 43 deletions

View File

@@ -963,6 +963,8 @@ void WMSetWindowTitle(WMWindow *wPtr, char *title);
void WMSetWindowMiniwindowTitle(WMWindow *win, char *title);
void WMSetWindowMiniwindowImage(WMWindow *win, RImage *image);
void WMSetWindowMiniwindowPixmap(WMWindow *win, WMPixmap *pixmap);
void WMSetWindowCloseAction(WMWindow *win, WMAction *action, void *clientData);

View File

@@ -305,6 +305,12 @@ typedef struct W_Screen {
Atom wmIconDragOffsetAtom;
Atom wmStateAtom; /* WM_STATE */
Atom utf8String;
Atom netwmName;
Atom netwmIconName;
Atom netwmIcon;
/* stuff for detecting double-clicks */
Time lastClickTime; /* time of last mousedown event */

View File

@@ -588,7 +588,11 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
"XdndActionAsk",
"XdndActionPrivate",
"_WINGS_DND_MOUSE_OFFSET",
"WM_STATE"
"WM_STATE",
"UTF8_STRING",
"_NET_WM_NAME",
"_NET_WM_ICON_NAME",
"_NET_WM_ICON",
};
Atom atoms[sizeof(atomNames)/sizeof(char*)];
int i;
@@ -901,12 +905,16 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
scrPtr->wmIconDragOffsetAtom = atoms[i++];
scrPtr->wmStateAtom = atoms[i++];
scrPtr->utf8String = atoms[i++];
scrPtr->netwmName = atoms[i++];
scrPtr->netwmIconName = atoms[i++];
scrPtr->netwmIcon = atoms[i++];
scrPtr->rootView = W_CreateRootView(scrPtr);
scrPtr->balloon = W_CreateBalloon(scrPtr);
W_InitApplication(scrPtr);
return scrPtr;

View File

@@ -199,12 +199,101 @@ WMCreateWindowWithStyle(WMScreen *screen, char *name, int style)
}
void
WMSetWindowTitle(WMWindow *win, char *title)
static void
setWindowTitle(WMWindow *win, const char *title)
{
WMScreen *scr= win->view->screen;
XTextProperty property;
int result;
result = XmbTextListToTextProperty(scr->display,
(char**)&title, 1, XStdICCTextStyle,
&property);
if (result == XNoMemory || result == XLocaleNotSupported) {
wwarning("window title conversion error... using STRING encoding");
XStoreName(scr->display, win->view->window, title);
} else {
XSetWMName(scr->display, win->view->window, &property);
if (property.value)
XFree(property.value);
}
XChangeProperty(scr->display, win->view->window,
scr->netwmName, scr->utf8String, 8,
PropModeReplace, (unsigned char *)title, strlen(title));
}
static void
setMiniwindowTitle(WMWindow *win, const char *title)
{
WMScreen *scr= win->view->screen;
XTextProperty property;
int result;
result = XmbTextListToTextProperty(scr->display,
(char**)&title, 1, XStdICCTextStyle,
&property);
if (result == XNoMemory || result == XLocaleNotSupported) {
wwarning("icon title conversion error..using STRING encoding");
XSetIconName(scr->display, win->view->window, title);
} else {
XSetWMIconName(scr->display, win->view->window, &property);
if (property.value)
XFree(property.value);
}
XChangeProperty(scr->display, win->view->window,
scr->netwmIconName, scr->utf8String, 8,
PropModeReplace, (unsigned char *)title, strlen(title));
}
static void
setMiniwindow(WMWindow *win, RImage *image)
{
WMScreen *scr= win->view->screen;
CARD32 *data;
int x, y;
int o;
if (!image)
return;
data= malloc((image->width * image->height + 2) * sizeof(CARD32));
if (!data)
return;
o= 0;
data[o++] = image->width;
data[o++] = image->height;
for (y= 0; y < image->height; y++) {
for (x= 0; x < image->width; x++) {
CARD32 pixel;
int offs= (x+y*image->width);
if (image->format == RRGBFormat)
pixel= image->data[offs*3]<<16 | image->data[offs*3+1]<<8 | image->data[offs*3+2];
else
pixel= image->data[offs*4]<<16 | image->data[offs*4+1]<<8 | image->data[offs*4+2] | image->data[offs*4+3] << 24;
data[o++]= pixel;
}
}
XChangeProperty(scr->display, win->view->window,
scr->netwmIcon, XA_CARDINAL, 32,
PropModeReplace,
(unsigned char *)data,
(image->width * image->height + 2) * sizeof(CARD32));
}
void
WMSetWindowTitle(WMWindow *win, char *title)
{
if (win->title!=NULL)
wfree(win->title);
if (title!=NULL)
@@ -213,17 +302,7 @@ WMSetWindowTitle(WMWindow *win, char *title)
win->title = NULL;
if (win->view->flags.realized) {
result = XmbTextListToTextProperty (win->view->screen->display,
&title, 1, XStdICCTextStyle,
&property);
if (result == XNoMemory || result == XLocaleNotSupported) {
wwarning("window title conversion error... using STRING encoding");
XStoreName(win->view->screen->display, win->view->window, title);
} else {
XSetWMName(win->view->screen->display, win->view->window, &property);
if (property.value)
XFree(property.value);
}
setWindowTitle(win, title);
}
}
@@ -454,6 +533,9 @@ realizeWindow(WMWindow *win)
XSetTransientForHint(scr->display, win->view->window,
win->owner->view->window);
}
if (win->title)
setWindowTitle(win, win->title);
}
@@ -563,6 +645,14 @@ WMSetWindowDocumentEdited(WMWindow *win, Bool flag)
}
void
WMSetWindowMiniwindowImage(WMWindow *win, RImage *image)
{
if (win->view->flags.realized)
setMiniwindow(win, image);
}
void
WMSetWindowMiniwindowPixmap(WMWindow *win, WMPixmap *pixmap)
{
@@ -605,9 +695,6 @@ WMSetWindowMiniwindowPixmap(WMWindow *win, WMPixmap *pixmap)
void
WMSetWindowMiniwindowTitle(WMWindow *win, char *title)
{
XTextProperty property;
int result;
if ((win->miniTitle && !title) || (!win->miniTitle && title)
|| (title && win->miniTitle && strcoll(title, win->miniTitle)!=0)) {
if (win->miniTitle)
@@ -619,19 +706,7 @@ WMSetWindowMiniwindowTitle(WMWindow *win, char *title)
win->miniTitle = NULL;
if (win->view->flags.realized) {
result = XmbTextListToTextProperty (win->view->screen->display,
&title, 1, XStdICCTextStyle,
&property);
if (result == XNoMemory || result == XLocaleNotSupported) {
wwarning("icon title conversion error..using STRING encoding");
XSetIconName(win->view->screen->display, win->view->window,
title);
} else {
XSetWMIconName(win->view->screen->display, win->view->window,
&property);
if (property.value)
XFree(property.value);
}
setMiniwindowTitle(win, title);
}
}
}