Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x11-wm/twm: generate synthetic WM hints when needed
This is based on a patch from Reddit -- the patch on Reddit is in context-diff form and contains a bunch of cruft, so it's been re-done (in add_window.c ; the util.c part is used unchanged). Tested by running Chrome in previous twm -- no drop-downs at all -- and in this lightly patched one, where it does behave. PR: 252873 Obtained from: Reddit
- Loading branch information
Adriaan de Groot
authored and
Adriaan de Groot
committed
May 4, 2021
1 parent
b00a1be
commit 1c31059
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
PORTNAME= twm | ||
PORTVERSION= 1.0.11 | ||
PORTREVISION= 1 | ||
CATEGORIES= x11-wm | ||
|
||
MAINTAINER= x11@FreeBSD.org | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- src/add_window.c.orig 2020-06-14 23:58:19 UTC | ||
+++ src/add_window.c | ||
@@ -238,6 +238,9 @@ AddWindow(Window w, int iconm, IconMgr *iconp) | ||
|
||
tmp_win->wmhints = XGetWMHints(dpy, tmp_win->w); | ||
|
||
+ if (!tmp_win->wmhints) { | ||
+ tmp_win->wmhints = gen_synthetic_wmhints(tmp_win); | ||
+ } | ||
if (tmp_win->wmhints) { | ||
if (restore_iconified) { | ||
tmp_win->wmhints->initial_state = IconicState; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- src/util.c.orig 2020-06-14 23:58:19 UTC | ||
+++ src/util.c | ||
@@ -1033,3 +1033,44 @@ Bell(int type _X_UNUSED, int percent, Window win _X_UN | ||
#endif | ||
return; | ||
} | ||
+ | ||
+/* | ||
+ * Create synthetic WM_HINTS info for windows. When a window specifies | ||
+ * stuff, we should probably pay attention to it (though we don't | ||
+ * always; x-ref comments in AddWindow() especially about focus). | ||
+ * However, when it doesn't tell us anything at all, we should assume | ||
+ * something useful. "Window managers are free to assume convenient | ||
+ * values for all fields of the WM_HINTS property if a window is mapped | ||
+ * without one." (ICCCM Ch. 4, | ||
+ * <https://www.x.org/releases/X11R7.7/doc/xorg-docs/icccm/icccm.html#Client_Properties>). | ||
+ * | ||
+ * Specifically, we assume it wants us to give it focus. It's fairly | ||
+ * bogus for a window not to tell us anything, but e.g current versions | ||
+ * of Chrome do (don't do) just that. So we better make up something | ||
+ * useful. | ||
+ * | ||
+ * Should probably be some configurability for this, so make the func | ||
+ * take the window, even though we don't currently do anything useful | ||
+ * with it... | ||
+ */ | ||
+XWMHints * | ||
+gen_synthetic_wmhints(TwmWindow *win) | ||
+{ | ||
+ XWMHints *hints; | ||
+ | ||
+ hints = XAllocWMHints(); | ||
+ if(!hints) { | ||
+ return NULL; | ||
+ } | ||
+ | ||
+ /* | ||
+ * Reasonable defaults. Takes input, in normal state. | ||
+ * | ||
+ * XXX Make configurable? | ||
+ */ | ||
+ hints->flags = InputHint | StateHint; | ||
+ hints->input = True; | ||
+ hints->initial_state = NormalState; | ||
+ | ||
+ return hints; | ||
+} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- src/util.h.orig 2020-06-14 23:58:19 UTC | ||
+++ src/util.h | ||
@@ -88,6 +88,8 @@ extern Status I18N_GetIconName(Display *dpy, Window wi | ||
extern void SetFocus(TwmWindow *tmp_win, Time time); | ||
extern void Bell(int type, int percent, Window win); | ||
|
||
+extern XWMHints *gen_synthetic_wmhints(TwmWindow *win); | ||
+ | ||
extern int HotX, HotY; | ||
|
||
#define WM_BELL 0 |