diff options
Diffstat (limited to 'src')
-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 |
5 files changed, 66 insertions, 2 deletions
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] |