1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

dtwm: optimize EWMH processing.

This commit is contained in:
hyousatsu 2022-12-05 05:27:46 +00:00 committed by Jon Trulson
parent a90666402c
commit 0011ed2f70
4 changed files with 58 additions and 79 deletions

View file

@ -748,18 +748,6 @@ void HandleCPropertyNotify (ClientData *pCD, XPropertyEvent *propertyEvent)
break; break;
} }
case XA_WM_NAME:
{
ProcessWmWindowTitle (pCD, FALSE /*not first time*/);
break;
}
case XA_WM_ICON_NAME:
{
ProcessWmIconTitle (pCD, FALSE /*not first time*/);
break;
}
case XA_WM_CLASS: case XA_WM_CLASS:
{ {
@ -868,13 +856,15 @@ void HandleCPropertyNotify (ClientData *pCD, XPropertyEvent *propertyEvent)
ProcessMwmHints (pCD); ProcessMwmHints (pCD);
SetClientOffset (pCD); SetClientOffset (pCD);
} }
else if (propertyEvent->atom == wmGD.xa__NET_WM_NAME) else if (propertyEvent->atom == XA_WM_NAME ||
propertyEvent->atom == wmGD.xa__NET_WM_NAME)
{ {
ProcessNetWmName (pCD); ProcessWmWindowTitle (pCD, FALSE /*not first time*/);
} }
else if (propertyEvent->atom == wmGD.xa__NET_WM_ICON_NAME) else if (propertyEvent->atom == XA_WM_ICON_NAME ||
propertyEvent->atom == wmGD.xa__NET_WM_ICON_NAME)
{ {
ProcessNetWmIconName (pCD); ProcessWmIconTitle (pCD, FALSE /*not first time*/);
} }
break; break;
} }

View file

@ -145,30 +145,6 @@ static void ProcessNetWmStateMaximized (ClientData *pCD, long action)
SetClientState (pCD, newState, GetTimestamp ()); SetClientState (pCD, newState, GetTimestamp ());
} }
static void ProcessNetWmNameNetWmIconName (ClientData *pCD, Atom name)
{
unsigned long nitems;
unsigned char *netNameProp;
XTextProperty nameProp = {0};
nitems = GetWindowProperty(pCD->client, name, wmGD.xa_UTF8_STRING,
&netNameProp);
if (!nitems) goto done;
if (Xutf8TextListToTextProperty (DISPLAY, (char **) &netNameProp, 1,
XUTF8StringStyle, &nameProp) != Success) goto done;
if (name == wmGD.xa__NET_WM_NAME)
XSetWMName (DISPLAY, pCD->client, &nameProp);
else if (name == wmGD.xa__NET_WM_ICON_NAME)
XSetWMIconName (DISPLAY, pCD->client, &nameProp);
done:
XFree (netNameProp);
XFree ((char*) nameProp.value);
}
/** /**
* @brief Processes the _NET_WM_FULLSCREEN_MONITORS protocol. * @brief Processes the _NET_WM_FULLSCREEN_MONITORS protocol.
* *
@ -246,26 +222,6 @@ void ProcessNetWmState (ClientData *pCD, long action,
UpdateNetWmState (pCD); UpdateNetWmState (pCD);
} }
/**
* @brief Processes the _NET_WM_NAME property.
*
* @param pCD
*/
void ProcessNetWmName (ClientData *pCD)
{
ProcessNetWmNameNetWmIconName (pCD, wmGD.xa__NET_WM_NAME);
}
/**
* @brief Processes the _NET_WM_ICON_NAME property.
*
* @param pCD
*/
void ProcessNetWmIconName (ClientData *pCD)
{
ProcessNetWmNameNetWmIconName (pCD, wmGD.xa__NET_WM_ICON_NAME);
}
/** /**
* @brief Sets up the window manager handling of the EWMH. * @brief Sets up the window manager handling of the EWMH.
*/ */
@ -326,7 +282,7 @@ void SetupWmEwmh (void)
XChangeProperty(DISPLAY, childWindow, atoms[XA__NET_WM_NAME], XChangeProperty(DISPLAY, childWindow, atoms[XA__NET_WM_NAME],
atoms[XA_UTF8_STRING], 8, PropModeReplace, atoms[XA_UTF8_STRING], 8, PropModeReplace,
DT_WM_RESOURCE_NAME, 5); (unsigned char *)DT_WM_RESOURCE_NAME, 5);
XChangeProperty(DISPLAY, childWindow, XChangeProperty(DISPLAY, childWindow,
atoms[XA__NET_SUPPORTING_WM_CHECK], XA_WINDOW, 32, atoms[XA__NET_SUPPORTING_WM_CHECK], XA_WINDOW, 32,

View file

@ -23,8 +23,8 @@
* Floor, Boston, MA 02110-1301 USA * Floor, Boston, MA 02110-1301 USA
*/ */
#ifndef _Dt_WmEwmh_h_ #ifndef WMEWMH_H
#define _Dt_WmEwmh_h_ #define WMEWMH_H
#define _NET_WM_STATE_REMOVE 0 #define _NET_WM_STATE_REMOVE 0
#define _NET_WM_STATE_ADD 1 #define _NET_WM_STATE_ADD 1
@ -46,8 +46,6 @@ void ProcessNetWmFullscreenMonitors (ClientData *pCD,
long top, long bottom, long left, long right); long top, long bottom, long left, long right);
void ProcessNetWmState (ClientData *pCD, long action, void ProcessNetWmState (ClientData *pCD, long action,
long firstProperty, long secondProperty); long firstProperty, long secondProperty);
void ProcessNetWmName (ClientData *pCD);
void ProcessNetWmIconName (ClientData *pCD);
void SetupWmEwmh (void); void SetupWmEwmh (void);
#endif /* _Dt_WmEwmh_h_ */ #endif

View file

@ -56,7 +56,6 @@
#include "WmCDecor.h" #include "WmCDecor.h"
#include "WmCPlace.h" #include "WmCPlace.h"
#include "WmError.h" #include "WmError.h"
#include "WmEwmh.h"
#include "WmIDecor.h" #include "WmIDecor.h"
#include "WmIPlace.h" #include "WmIPlace.h"
#include "WmIconBox.h" #include "WmIconBox.h"
@ -420,7 +419,6 @@ GetClientInfo (WmScreenData *pSD, Window clientWindow, long manageFlags)
*/ */
ProcessWmWindowTitle (pCD, TRUE); ProcessWmWindowTitle (pCD, TRUE);
ProcessNetWmName (pCD);
/* /*
@ -428,7 +426,6 @@ GetClientInfo (WmScreenData *pSD, Window clientWindow, long manageFlags)
*/ */
ProcessWmIconTitle (pCD, TRUE); ProcessWmIconTitle (pCD, TRUE);
ProcessNetWmIconName (pCD);
/* /*
@ -2204,16 +2201,35 @@ WmICCCMToXmString (XTextProperty *wmNameProp)
void void
ProcessWmWindowTitle (ClientData *pCD, Boolean firstTime) ProcessWmWindowTitle (ClientData *pCD, Boolean firstTime)
{ {
Atom actualType;
int actualFormat;
unsigned long nitems;
unsigned long leftover;
char *netWmNameProp;
XTextProperty wmNameProp; XTextProperty wmNameProp;
XmString title_xms = NULL; XmString title_xms = NULL;
Window win = pCD->client;
Boolean hasWmName = HasProperty (pCD, XA_WM_NAME);
Boolean hasNetWmName = HasProperty (pCD, wmGD.xa__NET_WM_NAME);
if ((pCD->clientDecoration & MWM_DECOR_TITLE) && if ((pCD->clientDecoration & MWM_DECOR_TITLE) &&
(!firstTime || HasProperty (pCD, XA_WM_NAME)) && (!firstTime || hasWmName || hasNetWmName))
XGetWMName(DISPLAY, pCD->client, &wmNameProp)) {
if ((!firstTime || hasNetWmName) &&
XGetWindowProperty (DISPLAY, win, wmGD.xa__NET_WM_NAME, 0L,
1000000L, False, wmGD.xa_UTF8_STRING,
&actualType, &actualFormat, &nitems, &leftover,
(unsigned char **) &netWmNameProp) == Success)
{
title_xms = XmStringCreateLocalized (netWmNameProp);
XFree (netWmNameProp);
}
else if ((!firstTime || hasWmName) &&
XGetWMName(DISPLAY, win, &wmNameProp))
{ {
title_xms = WmICCCMToXmString(&wmNameProp); title_xms = WmICCCMToXmString(&wmNameProp);
if (wmNameProp.value) if (wmNameProp.value) XFree ((char*)wmNameProp.value);
XFree ((char*)wmNameProp.value); }
} }
if (title_xms) if (title_xms)
@ -2418,17 +2434,36 @@ FixSubpanelEmbeddedClientGeometry (ClientData *pCD)
void void
ProcessWmIconTitle (ClientData *pCD, Boolean firstTime) ProcessWmIconTitle (ClientData *pCD, Boolean firstTime)
{ {
Atom actualType;
int actualFormat;
unsigned long nitems;
unsigned long leftover;
char *netWmIconNameProp;
XTextProperty wmIconNameProp; XTextProperty wmIconNameProp;
XmString icon_xms = NULL; XmString icon_xms = NULL;
Window win = pCD->client;
Boolean hasWmIconName = HasProperty (pCD, XA_WM_ICON_NAME);
Boolean hasNetWmIconName = HasProperty (pCD, wmGD.xa__NET_WM_ICON_NAME);
if ((pCD->clientFunctions & MWM_FUNC_MINIMIZE) && if ((pCD->clientFunctions & MWM_FUNC_MINIMIZE) &&
(pCD->transientLeader == NULL) && (pCD->transientLeader == NULL) &&
(!firstTime || HasProperty(pCD, XA_WM_ICON_NAME)) && (!firstTime || hasWmIconName || hasNetWmIconName))
XGetWMIconName (DISPLAY, pCD->client, &wmIconNameProp)) {
if ((!firstTime || hasNetWmIconName) &&
XGetWindowProperty (DISPLAY, win, wmGD.xa__NET_WM_ICON_NAME, 0L,
1000000L, False, wmGD.xa_UTF8_STRING, &actualType,
&actualFormat, &nitems, &leftover,
(unsigned char **) &netWmIconNameProp) == Success)
{
icon_xms = XmStringCreateLocalized (netWmIconNameProp);
XFree (netWmIconNameProp);
}
else if ((!firstTime || hasWmIconName) &&
XGetWMIconName (DISPLAY, win, &wmIconNameProp))
{ {
icon_xms = WmICCCMToXmString(&wmIconNameProp); icon_xms = WmICCCMToXmString(&wmIconNameProp);
if (wmIconNameProp.value) if (wmIconNameProp.value) XFree ((char*)wmIconNameProp.value);
XFree ((char*)wmIconNameProp.value); }
} }
if (icon_xms) if (icon_xms)