diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2019-07-16 20:40:50 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2019-07-16 20:40:50 -0400 |
commit | 98ff71aff13d9e35bb2436a15ea3fd38ea2fffa4 (patch) | |
tree | 31fac64d563b0c07d9b38b6ea116fde5c2db6fd6 | |
parent | 9f3f818068ba54ab2b46142e73100ef10a0bda0b (diff) |
issue 2: twm doesn't handle RandR screen size changes
patch submitted by Preston Crow
modified to check if xrandr development header/library is available
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/events.c | 40 | ||||
-rw-r--r-- | src/events.h | 1 | ||||
-rw-r--r-- | src/twm.c | 14 | ||||
-rw-r--r-- | src/twm.h | 9 |
6 files changed, 71 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac index 7b6643b..2cb0a6e 100644 --- a/configure.ac +++ b/configure.ac @@ -49,7 +49,11 @@ AC_PROG_LEX AC_CHECK_FUNCS([mkstemp]) # Checks for pkg-config packages -PKG_CHECK_MODULES(TWM, x11 xext xt xmu ice sm xproto >= 7.0.17) +PKG_CHECK_MODULES([TWM], [x11 xext xt xmu ice sm xproto >= 7.0.17]) +PKG_CHECK_MODULES([XRANDR], [xrandr], [have_xrandr=yes], [have_xrandr=no]) +if test "$have_xrandr" = yes; then + AC_DEFINE([HAVE_XRANDR], [1], [Define to 1 if you have the xrandr headers/libraries]) +fi AC_CONFIG_FILES([Makefile src/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index 1f46e09..4bafe55 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -32,8 +32,8 @@ AM_CPPFLAGS = \ -DXORG_RELEASE=\"Release\ $(VERSION)\" \ -DSYSTEM_INIT_FILE=\"${rcdir}/system.twmrc\" -AM_CFLAGS = $(TWM_CFLAGS) -twm_LDADD = $(TWM_LIBS) +AM_CFLAGS = $(TWM_CFLAGS) $(XRANDR_CFLAGS) +twm_LDADD = $(TWM_LIBS) $(XRANDR_LIBS) twm_SOURCES = \ add_window.c \ diff --git a/src/events.c b/src/events.c index f92014f..ce66446 100644 --- a/src/events.c +++ b/src/events.c @@ -73,6 +73,9 @@ in this Software without prior written authorization from The Open Group. #include "icons.h" #include "version.h" +#ifdef HAVE_XRANDR +#include <X11/extensions/Xrandr.h> +#endif #define MAX_X_EVENT 256 event_proc EventHandler[MAX_X_EVENT]; /* event handler jump table */ @@ -170,6 +173,18 @@ InitEvents(void) EventHandler[VisibilityNotify] = HandleVisibilityNotify; if (HasShape) EventHandler[ShapeEventBase+ShapeNotify] = HandleShapeNotify; +#ifdef HAVE_XRANDR + if (HasXrandr) + { + int scrnum; + + EventHandler[XrandrEventBase+RRScreenChangeNotify] = HandleScreenChangeNotify; + for (scrnum = 0; scrnum < NumScreens; scrnum++) + { + XRRSelectInput(dpy,ScreenList[scrnum]->Root,RRScreenChangeNotifyMask); + } + } +#endif } @@ -2399,6 +2414,31 @@ HandleShapeNotify (void) +#ifdef HAVE_XRANDR +/** + * xrandr screen configuration change-notification handler + */ +void +HandleScreenChangeNotify (void) +{ + XRRScreenChangeNotifyEvent *xev = (XRRScreenChangeNotifyEvent *) &Event; + int scrnum; + + for (scrnum = 0; scrnum < NumScreens; scrnum++) + { + if ( ScreenList[scrnum]->Root == xev->root ) + { + ScreenList[scrnum]->MyDisplayWidth = xev->width; + ScreenList[scrnum]->MyDisplayHeight = xev->height; + } + } + + XRRUpdateConfiguration(&Event); +} +#endif + + + /** * unknown event handler */ diff --git a/src/events.h b/src/events.h index e6bcfc9..f554642 100644 --- a/src/events.h +++ b/src/events.h @@ -97,6 +97,7 @@ extern void HandleEnterNotify ( void ); extern void HandleLeaveNotify ( void ); extern void HandleConfigureRequest ( void ); extern void HandleShapeNotify ( void ); +extern void HandleScreenChangeNotify ( void ); extern void HandleUnknown ( void ); extern int Transient ( Window w, Window *propw ); extern ScreenInfo * FindScreenInfo ( Window w ); @@ -82,10 +82,15 @@ in this Software without prior written authorization from The Open Group. #include <X11/Xmu/Error.h> #include <X11/extensions/sync.h> #include <X11/Xlocale.h> + #ifdef XPRINT #include <X11/extensions/Print.h> #endif /* XPRINT */ +#ifdef HAVE_XRANDR +#include <X11/extensions/Xrandr.h> +#endif + static void InitVariables ( void ); XtAppContext appContext; /* Xt application context */ @@ -98,6 +103,12 @@ int MultiScreen = TRUE; /* try for more than one screen? */ int NoPrintscreens = False; /* ignore special handling of print screens? */ int NumScreens; /* number of screens in ScreenList */ int HasShape; /* server supports shape extension? */ + +#ifdef HAVE_XRANDR +int HasXrandr; /* server supports Xrandr extension? */ +int XrandrEventBase, XrandrErrorBase; +#endif + int ShapeEventBase, ShapeErrorBase; int HasSync; /* server supports SYNC extension? */ int SyncEventBase, SyncErrorBase; @@ -349,6 +360,9 @@ main(int argc, char *argv[]) HasShape = XShapeQueryExtension (dpy, &ShapeEventBase, &ShapeErrorBase); HasSync = XSyncQueryExtension(dpy, &SyncEventBase, &SyncErrorBase); +#ifdef HAVE_XRANDR + HasXrandr = XRRQueryExtension(dpy, &XrandrEventBase, &XrandrErrorBase); +#endif TwmContext = XUniqueContext(); MenuContext = XUniqueContext(); IconManagerContext = XUniqueContext(); @@ -355,6 +355,10 @@ extern Window ResizeWindow; /* the window we are resizing */ extern int HasShape; /* this server supports Shape extension */ extern int HasSync; /* this server supports SYNC extension */ +#ifdef HAVE_XRANDR +extern int HasXrandr; /* this server supports Xrandr extension */ +#endif + extern int PreviousScreen; extern Cursor UpperLeftCursor; @@ -410,6 +414,11 @@ extern Bool use_fontset; extern int ShapeEventBase; extern int ShapeErrorBase; +#ifdef HAVE_XRANDR +extern int XrandrEventBase; +extern int XrandrErrorBase; +#endif + #define _XA_MIT_PRIORITY_COLORS TwmAtoms[0] #define _XA_WM_CHANGE_STATE TwmAtoms[1] #define _XA_WM_STATE TwmAtoms[2] |