From 3886c7d09ce96b70a066d7503fb007e6a21a9b85 Mon Sep 17 00:00:00 2001 From: Liang Chang Date: Sat, 7 Aug 2021 16:19:25 +0800 Subject: [PATCH] dtwm: Respond to the following EWMH: _NET_WM_FULLSCREEN_MONITORS _NET_WM_STATE_FULLSCREEN --- cde/programs/dtwm/WmCEvent.c | 48 ++++++++++++++++++++++++++++++++++-- cde/programs/dtwm/WmGlobal.h | 11 +++++++++ cde/programs/dtwm/WmInitWs.c | 5 ++++ 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/cde/programs/dtwm/WmCEvent.c b/cde/programs/dtwm/WmCEvent.c index 59d224e23..9ce30f7ac 100644 --- a/cde/programs/dtwm/WmCEvent.c +++ b/cde/programs/dtwm/WmCEvent.c @@ -44,8 +44,10 @@ */ #include "WmCEvent.h" #include "WmCDecor.h" +#include "WmCDInfo.h" #include "WmColormap.h" #include "WmEvent.h" +#include "WmEwmh.h" #include "WmFeedback.h" #include "WmFunction.h" #include "WmIDecor.h" @@ -508,6 +510,7 @@ Boolean HandleEventsOnSpecialWindows (XEvent *pEvent) { Boolean dispatchEvent = True; WmScreenData *pSD; + ClientData *pCD; /* @@ -604,6 +607,15 @@ Boolean HandleEventsOnSpecialWindows (XEvent *pEvent) } break; } + + case ClientMessage: + { + if (pCD = InitClientData (pEvent->xclient.window)) { + ProcessEwmh (pCD, (XClientMessageEvent *) pEvent); + dispatchEvent = False; + } + break; + } } } @@ -828,6 +840,22 @@ void HandleCPropertyNotify (ClientData *pCD, XPropertyEvent *propertyEvent) ProcessColormapList (ACTIVE_PSD, pCD); } } + else if (propertyEvent->atom == wmGD.xa_MWM_HINTS) { + long suppliedReturn; + XSizeHints hintsReturn = {0}; + + XGetWMNormalHints (DISPLAY, pCD->client, &hintsReturn, + &suppliedReturn); + + hintsReturn.flags |= P_MAX_SIZE; + hintsReturn.max_width = -1; + hintsReturn.max_height = -1; + + XSetWMNormalHints (DISPLAY, pCD->client, &hintsReturn); + + ProcessMwmHints (pCD); + SetClientOffset (pCD); + } break; } } @@ -2547,7 +2575,20 @@ void HandleClientMessage (ClientData *pCD, XClientMessageEvent *clientEvent) } else if (clientEvent->data.l[0] == NormalState) { - newState = NORMAL_STATE; + if (pCD->isFullscreen) + { + SetClientState (pCD, NORMAL_STATE, GetTimestamp ()); + newState = MAXIMIZED_STATE; + } + else + { + if (pCD->decorUpdated) + { + SetClientState (pCD, MAXIMIZED_STATE, GetTimestamp ()); + } + + newState = NORMAL_STATE; + } } if (!ClientInWorkspace (ACTIVE_WS, pCD)) { @@ -2557,7 +2598,10 @@ void HandleClientMessage (ClientData *pCD, XClientMessageEvent *clientEvent) SetClientState (pCD, newState, GetTimestamp ()); } - + else + { + ProcessEwmh (pCD, clientEvent); + } } /* END OF FUNCTION HandleClientMessage */ diff --git a/cde/programs/dtwm/WmGlobal.h b/cde/programs/dtwm/WmGlobal.h index 10718ebad..891c4fb2e 100644 --- a/cde/programs/dtwm/WmGlobal.h +++ b/cde/programs/dtwm/WmGlobal.h @@ -1628,6 +1628,13 @@ typedef struct _ClientData Window clientBaseWin; /* for matte & reparenting */ int xBorderWidth; /* original X border width */ FrameInfo frameInfo; /* frame geometry data */ + Boolean decorUpdated; /* True => decoration updated */ + Boolean isFullscreen; /* True => fullscreen */ + Boolean monitorSizeIsSet; /* True => X, Y, W, H is set */ + int monitorX; /* monitor X loc */ + int monitorY; /* monitor Y loc */ + int monitorWidth; /* monitor width */ + int monitorHeight; /* monitor height */ /* client window frame graphic data: */ @@ -1826,6 +1833,7 @@ typedef struct _WmGlobalData Widget topLevelW1; /* from which WM components hang */ Boolean confirmDialogMapped; /* confirm dialog is mapped */ XtAppContext mwmAppContext; /* application context for mwm */ + XContext tmpWindowContextType; /* temporary window context */ XContext windowContextType; /* window context for XSaveContext */ XContext screenContextType; /* screen context for XSaveContext */ #ifndef IBM_169380 @@ -1927,6 +1935,9 @@ typedef struct _WmGlobalData Atom xa_SM_CLIENT_ID; Atom xa_WMSAVE_HINT; + Atom xa_NET_WM_FULLSCREEN_MONITORS; + Atom xa_NET_WM_STATE; + Atom xa_NET_WM_STATE_FULLSCREEN; /* atoms used for workspace management: */ diff --git a/cde/programs/dtwm/WmInitWs.c b/cde/programs/dtwm/WmInitWs.c index 4e41ba54d..c70b2c195 100644 --- a/cde/programs/dtwm/WmInitWs.c +++ b/cde/programs/dtwm/WmInitWs.c @@ -87,6 +87,7 @@ typedef struct #include "WmColormap.h" #include "WmError.h" #include "WmEvent.h" +#include "WmEwmh.h" #include "WmFeedback.h" #include "WmFunction.h" #include "WmIDecor.h" @@ -410,6 +411,7 @@ void InitWmGlobal (int argc, char *argv [], char *environ []) * Do (pre-toolkit) initialization: */ + wmGD.tmpWindowContextType = XUniqueContext (); wmGD.windowContextType = XUniqueContext (); wmGD.screenContextType = XUniqueContext (); #ifndef IBM_169380 @@ -1001,6 +1003,9 @@ void InitWmGlobal (int argc, char *argv [], char *environ []) /* setup window manager inter-client communications conventions handling */ SetupWmICCC (); + /* setup EWMH handling */ + SetupWmEwmh (); + /* * Use the WM_SAVE_YOURSELF protocol * for notification of when to save ourself