From df1228f3877948d0bbf31fa8d91faf8b604a246d Mon Sep 17 00:00:00 2001 From: kojima Date: Sat, 23 Oct 2004 21:07:13 +0000 Subject: [PATCH] added some netwm support in WINGs --- ChangeLog | 5 ++ WINGs/WINGs/WINGs.h | 2 + WINGs/WINGs/WINGsP.h | 6 +++ WINGs/widgets.c | 12 ++++- WINGs/wwindow.c | 133 ++++++++++++++++++++++++++++++++++++++++----------- WPrefs.app/WPrefs.c | 12 ++--- src/cycling.c | 6 ++- src/switchpanel.c | 2 +- util/Makefile.am | 2 +- 9 files changed, 137 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4dcc2c3f..978e8076 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Changes since version 0.90.0: +............................. + +- added _NET_WM_NAME, _ICON_NAME and _ICON to WINGs + Changes since version 0.80.2: ............................. diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h index 476f04c4..20556a87 100644 --- a/WINGs/WINGs/WINGs.h +++ b/WINGs/WINGs/WINGs.h @@ -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); diff --git a/WINGs/WINGs/WINGsP.h b/WINGs/WINGs/WINGsP.h index c442c2c8..5dbab47a 100644 --- a/WINGs/WINGs/WINGsP.h +++ b/WINGs/WINGs/WINGsP.h @@ -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 */ diff --git a/WINGs/widgets.c b/WINGs/widgets.c index ac89ce08..be571ab5 100644 --- a/WINGs/widgets.c +++ b/WINGs/widgets.c @@ -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; diff --git a/WINGs/wwindow.c b/WINGs/wwindow.c index 01a78562..74de385e 100644 --- a/WINGs/wwindow.c +++ b/WINGs/wwindow.c @@ -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); } @@ -564,6 +646,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) { if ((win->miniImage && !pixmap) || (!win->miniImage && 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); } } } diff --git a/WPrefs.app/WPrefs.c b/WPrefs.app/WPrefs.c index e466fe9a..aabe1d93 100644 --- a/WPrefs.app/WPrefs.c +++ b/WPrefs.app/WPrefs.c @@ -262,7 +262,6 @@ createMainWindow(WMScreen *scr) WMSetWindowMaxSize(WPrefs.win, 520, 390); WMSetWindowMinSize(WPrefs.win, 520, 390); WMSetWindowMiniwindowTitle(WPrefs.win, "Preferences"); - WMSetWindowMiniwindowPixmap(WPrefs.win, WMGetApplicationIconPixmap(scr)); WPrefs.scrollV = WMCreateScrollView(WPrefs.win); WMResizeWidget(WPrefs.scrollV, 500, 87); @@ -636,8 +635,6 @@ Initialize(WMScreen *scr) char **list; int i; char *path; - WMPixmap *icon; - list = RSupportedFileFormats(); for (i=0; list[i]!=NULL; i++) { @@ -659,12 +656,8 @@ Initialize(WMScreen *scr) wwarning(_("could not load image file %s:%s"), path, RMessageForError(RErrorCode)); } else { - icon = WMCreatePixmapFromRImage(scr, tmp, 0); + WMSetApplicationIconImage(scr, tmp); RReleaseImage(tmp); - if (icon) { - WMSetApplicationIconPixmap(scr, icon); - WMReleasePixmap(icon); - } } wfree(path); } @@ -673,6 +666,9 @@ Initialize(WMScreen *scr) createMainWindow(scr); WMRealizeWidget(WPrefs.win); + + WMSetWindowMiniwindowImage(WPrefs.win, WMGetApplicationIconImage(scr)); + WMMapWidget(WPrefs.win); XFlush(WMScreenDisplay(scr)); WMSetLabelText(WPrefs.statusL, _("Loading Window Maker configuration files...")); diff --git a/src/cycling.c b/src/cycling.c index 07289580..401a1082 100644 --- a/src/cycling.c +++ b/src/cycling.c @@ -72,7 +72,7 @@ StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next) Bool somethingElse = False; XEvent ev; WSwitchPanel *swpanel = NULL; - KeyCode leftKey, rightKey, homeKey, endKey; + KeyCode leftKey, rightKey, homeKey, endKey, shiftLKey, shiftRKey; if (!wwin) return; @@ -81,6 +81,8 @@ StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next) rightKey = XKeysymToKeycode(dpy, XK_Right); homeKey = XKeysymToKeycode(dpy, XK_Home); endKey = XKeysymToKeycode(dpy, XK_End); + shiftLKey = XKeysymToKeycode(dpy, XK_Shift_L); + shiftRKey = XKeysymToKeycode(dpy, XK_Shift_R); if (next) hasModifier = (wKeyBindings[WKBD_FOCUSNEXT].modifier != 0); @@ -179,7 +181,7 @@ StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next) } } } - } else { + } else if (ev.xkey.keycode != shiftLKey && ev.xkey.keycode != shiftRKey) { #ifdef DEBUG printf("Got something else\n"); #endif diff --git a/src/switchpanel.c b/src/switchpanel.c index bcf9bc18..531227ad 100644 --- a/src/switchpanel.c +++ b/src/switchpanel.c @@ -317,7 +317,7 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, int workspace) WMColor *color; WMFont *boldFont= WMBoldSystemFontOfSize(scr->wmscreen, 12); - WMSetLabelRelief(panel->label, WRSunken); + WMSetLabelRelief(panel->label, WRSimple); WMSetLabelFont(panel->label, boldFont); color = WMDarkGrayColor(scr->wmscreen); WMSetWidgetBackgroundColor(panel->label, color); diff --git a/util/Makefile.am b/util/Makefile.am index 13f56616..008f89e5 100644 --- a/util/Makefile.am +++ b/util/Makefile.am @@ -55,7 +55,7 @@ wmsetup_LDADD = \ wmsetbg_LDADD = \ $(top_builddir)/WINGs/libWINGs.a \ $(top_builddir)/wrlib/libwraster.la \ - @XFTLIBS@ @INTLIBS@ @DLLIBS@ + @XLIBS@ @XFTLIBS@ @INTLIBS@ @DLLIBS@ CLEANFILES = wmaker.inst -- 2.11.4.GIT