patches/xscreensaver-24-bug-xrandr.diff
author yippi
Mon, 27 Sep 2010 21:07:51 +0000
changeset 20108 51df67ca9307
parent 18121 53d749f3f6e6
permissions -rw-r--r--
I had these modules listed as being owned by me, but they are really owned by wangke, correcting.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18061
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
     1
/*
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
     2
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
     3
 *
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
     4
 * Permission is hereby granted, free of charge, to any person obtaining a
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
     5
 * copy of this software and associated documentation files (the "Software"),
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
     6
 * to deal in the Software without restriction, including without limitation
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
     7
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
     8
 * and/or sell copies of the Software, and to permit persons to whom the
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
     9
 * Software is furnished to do so, subject to the following conditions:
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    10
 *
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    11
 * The above copyright notice and this permission notice (including the next
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    12
 * paragraph) shall be included in all copies or substantial portions of the
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    13
 * Software.
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    14
 *
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    18
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    20
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    21
 * DEALINGS IN THE SOFTWARE.
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    22
 */
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    23
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    24
/* 
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    25
 * It fixes bug 6757448 and 6924996
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    26
 * 6757448 xscreensaver doesn't notice XRandR resize events
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    27
 * 6924996 High volume of error message display in SPARC:
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    28
	"Xlib: extension "RANDR" missing on display from screensaver" 
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    29
 */
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    30
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    31
diff --git xscreensaver-5.11/driver/lock.c xscreensaver-5.11/driver/lock.c
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    32
--- xscreensaver-5.11/driver/lock.c
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    33
+++ xscreensaver-5.11/driver/lock.c
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    34
@@ -50,6 +50,9 @@
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    35
   static void xfree_lock_grab_smasher (saver_info *si, Bool lock_p);
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    36
 #endif /* HAVE_XF86MISCSETGRABKEYSSTATE */
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    37
 
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    38
+#ifdef HAVE_RANDR
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    39
+#include <X11/extensions/Xrandr.h>
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    40
+#endif /* HAVE_RANDR */
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    41
 
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    42
 #ifdef _VROOT_H_
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    43
 ERROR!  You must not include vroot.h in this file.
18121
53d749f3f6e6 2010-06-10 Alan Coopersmith <[email protected]>
alanc
parents: 18077
diff changeset
    44
@@ -2536,6 +2539,57 @@ passwd_event_loop (saver_info *si)
18061
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    45
     {
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    46
       XtAppNextEvent (si->app, &event);
18077
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    47
 
18061
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    48
+#ifdef HAVE_RANDR
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    49
+    /*
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    50
+     * 6757448 xscreensaver doesn't notice XRandR resize events.
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    51
+     */
18077
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    52
+      if (si->using_randr_extension &&
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    53
+          (event.type == (si->randr_event_number + RRScreenChangeNotify)))
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    54
+        {
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    55
+          /* The Resize and Rotate extension sends an event when the
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    56
+             size, rotation, or refresh rate of the screen has changed. */
18061
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    57
+
18077
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    58
+          XRRScreenChangeNotifyEvent *xrr_event =
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    59
+            (XRRScreenChangeNotifyEvent *) & event;
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    60
+
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    61
+          /* XRRRootToScreen is in Xrandr.h 1.4, 2001/06/07 */
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    62
+          int screen = XRRRootToScreen(si->dpy, xrr_event->window);
18061
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    63
+
18077
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    64
+          if (p->verbose_p)
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    65
+            {
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    66
+              if ((si->screens[screen].width == xrr_event->width) &&
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    67
+                  (si->screens[screen].height == xrr_event->height))
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    68
+                fprintf(stderr,
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    69
+                        "%s: %d: no-op screen size change event (%dx%d)\n",
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    70
+                        blurb(), screen,
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    71
+                        xrr_event->width, xrr_event->height);
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    72
+              else
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    73
+                fprintf(stderr,
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    74
+                        "%s: %d: screen size changed from %dx%d to %dx%d\n",
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    75
+                        blurb(), screen,
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    76
+                        si->screens[screen].width,
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    77
+                        si->screens[screen].height,
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    78
+                        xrr_event->width, xrr_event->height);
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    79
+            }
18061
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    80
+
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    81
+#ifdef RRScreenChangeNotifyMask
18077
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    82
+          /* Inform Xlib that it's ok to update its data structures. */
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    83
+          XRRUpdateConfiguration(&event); /* Xrandr.h 1.9, 2002/09/29 */
18061
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    84
+#endif /* RRScreenChangeNotifyMask */
18077
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    85
+
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    86
+          /* Resize the existing xscreensaver windows and cached ssi data. */
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    87
+          if (update_screen_layout (si))
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    88
+            {
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    89
+              if (p->verbose_p)
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    90
+                {
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    91
+                  fprintf (stderr, "%s: new layout:\n", blurb());
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    92
+                  describe_monitor_layout (si);
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    93
+                }
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    94
+              resize_screensaver_window (si);
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    95
+            }
18061
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    96
+        }
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    97
+#endif /* HAVE_RANDR */
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
    98
+
18077
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
    99
 #ifndef HAVE_XSCREENSAVER_LOCK
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
   100
       if (event.xany.window == si->passwd_dialog && event.xany.type == Expose)
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
   101
 	draw_passwd_window (si);
18061
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   102
diff --git xscreensaver-5.11/driver/timers.c xscreensaver-5.11/driver/timers.c
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   103
--- xscreensaver-5.11/driver/timers.c
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   104
+++ xscreensaver-5.11/driver/timers.c
18121
53d749f3f6e6 2010-06-10 Alan Coopersmith <[email protected]>
alanc
parents: 18077
diff changeset
   105
@@ -1130,7 +1130,8 @@ sleep_until_idle (saver_info *si, Bool until_idle_p)
18061
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   106
 	else
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   107
 
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   108
 #ifdef HAVE_RANDR
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   109
-        if (event.x_event.type == (si->randr_event_number + RRScreenChangeNotify))
18077
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
   110
+        if (si->using_randr_extension &&
cf2df829a4db 2010-06-04 Alan Coopersmith <[email protected]>
alanc
parents: 18061
diff changeset
   111
+            (event.x_event.type == (si->randr_event_number + RRScreenChangeNotify)))
18061
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   112
           {
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   113
             /* The Resize and Rotate extension sends an event when the
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   114
                size, rotation, or refresh rate of any screen has changed.
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   115
diff --git xscreensaver-5.11/driver/types.h xscreensaver-5.11/driver/types.h
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   116
--- xscreensaver-5.11/driver/types.h
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   117
+++ xscreensaver-5.11/driver/types.h
18121
53d749f3f6e6 2010-06-10 Alan Coopersmith <[email protected]>
alanc
parents: 18077
diff changeset
   118
@@ -193,6 +193,7 @@ struct saver_info {
18061
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   119
 # ifdef HAVE_RANDR
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   120
   int randr_event_number;
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   121
   int randr_error_number;
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   122
+  Bool using_randr_extension;
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   123
 # endif
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   124
 
18121
53d749f3f6e6 2010-06-10 Alan Coopersmith <[email protected]>
alanc
parents: 18077
diff changeset
   125
   Bool using_xinput_extension;     /* Note that `p->use_*' is the *request*, */
18061
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   126
diff --git xscreensaver-5.11/driver/xscreensaver.c xscreensaver-5.11/driver/xscreensaver.c
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   127
--- xscreensaver-5.11/driver/xscreensaver.c
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   128
+++ xscreensaver-5.11/driver/xscreensaver.c
18121
53d749f3f6e6 2010-06-10 Alan Coopersmith <[email protected]>
alanc
parents: 18077
diff changeset
   129
@@ -959,6 +959,8 @@ initialize_server_extensions (saver_info *si)
18061
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   130
       int nscreens = ScreenCount (si->dpy);  /* number of *real* screens */
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   131
       int i;
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   132
 
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   133
+      si->using_randr_extension = TRUE;
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   134
+
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   135
       if (p->verbose_p)
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   136
 	fprintf (stderr, "%s: selecting RANDR events\n", blurb());
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   137
       for (i = 0; i < nscreens; i++)
1ad14cf3c086 2010-06-01 Alan Coopersmith <[email protected]>
alanc
parents:
diff changeset
   138