From 8fa32b3db5f40109489fe7455935b8887c0df89f Mon Sep 17 00:00:00 2001 From: Liang Chang Date: Thu, 19 Aug 2021 07:17:51 +0800 Subject: [PATCH] dtwm: Trigger fullscreen in an "edge trigger" manner to avoid wrong behaviors caused by some unusual operations. E.g., after entered fullscreen, applications change windows to other states instead of leaving fullscreen. --- cde/programs/dtwm/WmCEvent.c | 4 +++- cde/programs/dtwm/WmEwmh.c | 8 +------- cde/programs/dtwm/WmGlobal.h | 2 +- cde/programs/dtwm/WmManage.c | 1 + cde/programs/dtwm/WmWinInfo.c | 2 +- cde/programs/dtwm/WmWinState.c | 14 ++++++++++++-- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/cde/programs/dtwm/WmCEvent.c b/cde/programs/dtwm/WmCEvent.c index 9ce30f7ac..1245c9f65 100644 --- a/cde/programs/dtwm/WmCEvent.c +++ b/cde/programs/dtwm/WmCEvent.c @@ -2575,9 +2575,11 @@ void HandleClientMessage (ClientData *pCD, XClientMessageEvent *clientEvent) } else if (clientEvent->data.l[0] == NormalState) { - if (pCD->isFullscreen) + if (pCD->enterFullscreen) { + Boolean enterFullscreen = pCD->enterFullscreen; SetClientState (pCD, NORMAL_STATE, GetTimestamp ()); + pCD->enterFullscreen = enterFullscreen; newState = MAXIMIZED_STATE; } else diff --git a/cde/programs/dtwm/WmEwmh.c b/cde/programs/dtwm/WmEwmh.c index fbafdf9bb..0a1714fbf 100644 --- a/cde/programs/dtwm/WmEwmh.c +++ b/cde/programs/dtwm/WmEwmh.c @@ -149,16 +149,10 @@ static void ProcessNetWmStateFullscreen (ClientData *pCD, Boolean en) if (pHints != &hints) XFree (pHints); - pCD->isFullscreen = en; + pCD->enterFullscreen = en; XSendEvent (DISPLAY, ROOT_FOR_CLIENT (pCD), False, SubstructureRedirectMask, (XEvent *) &clientMsgEvent); - - if (en) XChangeProperty (DISPLAY, pCD->client, wmGD.xa_NET_WM_STATE, - XA_ATOM, 32, PropModeReplace, - (unsigned char *) &wmGD.xa_NET_WM_STATE_FULLSCREEN, - 1); - else XDeleteProperty (DISPLAY, pCD->client, wmGD.xa_NET_WM_STATE); } /* END OF FUNCTION ProcessNetWmStateFullscreen */ diff --git a/cde/programs/dtwm/WmGlobal.h b/cde/programs/dtwm/WmGlobal.h index 891c4fb2e..e56e186fa 100644 --- a/cde/programs/dtwm/WmGlobal.h +++ b/cde/programs/dtwm/WmGlobal.h @@ -1629,7 +1629,7 @@ typedef struct _ClientData int xBorderWidth; /* original X border width */ FrameInfo frameInfo; /* frame geometry data */ Boolean decorUpdated; /* True => decoration updated */ - Boolean isFullscreen; /* True => fullscreen */ + Boolean enterFullscreen; /* True => enter fullscreen */ Boolean monitorSizeIsSet; /* True => X, Y, W, H is set */ int monitorX; /* monitor X loc */ int monitorY; /* monitor Y loc */ diff --git a/cde/programs/dtwm/WmManage.c b/cde/programs/dtwm/WmManage.c index a2347f5c3..0f23e002d 100644 --- a/cde/programs/dtwm/WmManage.c +++ b/cde/programs/dtwm/WmManage.c @@ -1008,6 +1008,7 @@ void WithdrawWindow (ClientData *pCD) } } + XDeleteProperty (DISPLAY, pCD->client, wmGD.xa_NET_WM_STATE); XUnmapWindow (DISPLAY, pCD->client); XReparentWindow (DISPLAY, pCD->client, ROOT_FOR_CLIENT(pCD), x, y); diff --git a/cde/programs/dtwm/WmWinInfo.c b/cde/programs/dtwm/WmWinInfo.c index f1dc6d185..b6a816bb7 100644 --- a/cde/programs/dtwm/WmWinInfo.c +++ b/cde/programs/dtwm/WmWinInfo.c @@ -218,7 +218,7 @@ InitClientData (Window clientWindow) pCD->smClientID = (String)NULL; pCD->decorUpdated = False; - pCD->isFullscreen = False; + pCD->enterFullscreen = False; pCD->monitorSizeIsSet = False; return (pCD); diff --git a/cde/programs/dtwm/WmWinState.c b/cde/programs/dtwm/WmWinState.c index 22ab205c0..8ea2fab84 100644 --- a/cde/programs/dtwm/WmWinState.c +++ b/cde/programs/dtwm/WmWinState.c @@ -181,7 +181,6 @@ void SetClientStateWithEventMask (ClientData *pCD, int newState, Time setTime, u * WM_STATE property is set in WithdrawWindow. */ - XDeleteProperty (DISPLAY, pCD->client, wmGD.xa_NET_WM_STATE); UnManageWindow (pCD); break; } @@ -614,10 +613,12 @@ void ConfigureNewState (ClientData *pcd) XResizeWindow (DISPLAY, pcd->client, (unsigned int) pcd->clientWidth, (unsigned int) pcd->clientHeight); + + XDeleteProperty (DISPLAY, pcd->client, wmGD.xa_NET_WM_STATE); } else { - if (pcd->isFullscreen && pcd->monitorSizeIsSet) + if (pcd->enterFullscreen && pcd->monitorSizeIsSet) { pcd->maxX = pcd->monitorX; pcd->maxY = pcd->monitorY; @@ -646,7 +647,16 @@ void ConfigureNewState (ClientData *pcd) (unsigned int) pcd->maxHeight); pcd->maxConfig = TRUE; RegenerateClientFrame(pcd); + + if (pcd->enterFullscreen) + XChangeProperty (DISPLAY, pcd->client, wmGD.xa_NET_WM_STATE, + XA_ATOM, 32, PropModeReplace, + (unsigned char *) &wmGD.xa_NET_WM_STATE_FULLSCREEN, + 1); } + + pcd->enterFullscreen = False; + SendConfigureNotify (pcd); /*