@@ -595,7 +595,12 @@ public static long getDefaultRootWindow() {
595
595
}
596
596
}
597
597
598
- private static final boolean checkDesktopGeometry = !"false" .equals (System .getProperty ("watch.desktop.geometry" , "true" ));
598
+ private static boolean checkDesktopGeometry = !"false" .equals (System .getProperty ("watch.desktop.geometry" , "true" ));
599
+ // In case we are for some reason being spammed with display reconfiguration events (KDE?),
600
+ // we can stop reacting to those events. The current threshold is 20 events/sec.
601
+ private static final long DISABLE_WATCH_DESKTOP_GEOMETRY_TIME = 1000 ;
602
+ private static final long DISABLE_WATCH_DESKTOP_GEOMETRY_EVENT_COUNT = 20 ;
603
+ private static long lastDesktopGeometrySequenceTimestamp , lastDesktopGeometrySequenceEventCount ;
599
604
600
605
void init () {
601
606
awtLock ();
@@ -842,11 +847,23 @@ private void dispatchEvent(XEvent ev) {
842
847
final XAnyEvent xany = ev .get_xany ();
843
848
844
849
if (xany .get_window () == getDefaultRootWindow ()) {
845
- if (ev .get_type () == XConstants .ConfigureNotify ||
846
- ( checkDesktopGeometry && ev . get_type () == XConstants . PropertyNotify &&
847
- ev .get_xproperty (). get_atom () == XWM . XA_NET_DESKTOP_GEOMETRY . getAtom ())) // possible DPI change
848
- {
850
+ if (ev .get_type () == XConstants .ConfigureNotify ) {
851
+ dirtyDevices = true ;
852
+ } else if ( checkDesktopGeometry && ev .get_type () == XConstants . PropertyNotify &&
853
+ ev . get_xproperty (). get_atom () == XWM . XA_NET_DESKTOP_GEOMETRY . getAtom ()) { // possible DPI change
849
854
dirtyDevices = true ;
855
+ // Count the number of such events and disable geometry check if we are getting spammed.
856
+ long time = System .currentTimeMillis ();
857
+ if (time <= lastDesktopGeometrySequenceTimestamp + DISABLE_WATCH_DESKTOP_GEOMETRY_TIME ) {
858
+ lastDesktopGeometrySequenceEventCount ++;
859
+ if (lastDesktopGeometrySequenceEventCount >= DISABLE_WATCH_DESKTOP_GEOMETRY_EVENT_COUNT ) {
860
+ checkDesktopGeometry = false ;
861
+ System .err .println ("XToolkit: too many _NET_DESKTOP_GEOMETRY events, disabling watch.desktop.geometry" );
862
+ }
863
+ } else {
864
+ lastDesktopGeometrySequenceTimestamp = time ;
865
+ lastDesktopGeometrySequenceEventCount = 1 ;
866
+ }
850
867
} else {
851
868
final XAtom XA_NET_WORKAREA = XAtom .get ("_NET_WORKAREA" );
852
869
final boolean rootWindowWorkareaResized = (ev .get_type () == XConstants .PropertyNotify
0 commit comments