]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/displayx11.cpp
Fix horizontal mouse wheel scrolling in wxGTK.
[wxWidgets.git] / src / unix / displayx11.cpp
index a6c294d5e2b81ea95aa42795bee98bb9f8a4278d..87dedfc53002cfa49aa3930904da7a8945dfc08e 100644 (file)
@@ -4,7 +4,6 @@
 // Author:      Brian Victor, Vadim Zeitlin
 // Modified by:
 // Created:     12/05/02
 // Author:      Brian Victor, Vadim Zeitlin
 // Modified by:
 // Created:     12/05/02
-// RCS-ID:      $Id$
 // Copyright:   (c) wxWidgets team
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 // Copyright:   (c) wxWidgets team
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -62,9 +61,6 @@
         #include <X11/Xlibint.h>
 
         #include <X11/extensions/Xinerama.h>
         #include <X11/Xlibint.h>
 
         #include <X11/extensions/Xinerama.h>
-        #ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
-            #include <X11/extensions/xf86vmode.h>
-        #endif
     }
 
     typedef XineramaScreenInfo ScreenInfo;
     }
 
     typedef XineramaScreenInfo ScreenInfo;
@@ -222,6 +218,8 @@ wxDisplayImpl *wxDisplayFactoryX11::CreateDisplay(unsigned n)
 
 #ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
 
 
 #ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
 
+#include <X11/extensions/xf86vmode.h>
+
 //
 //  See (http://www.xfree86.org/4.2.0/XF86VidModeDeleteModeLine.3.html) for more
 //  info about xf86 video mode extensions
 //
 //  See (http://www.xfree86.org/4.2.0/XF86VidModeDeleteModeLine.3.html) for more
 //  info about xf86 video mode extensions
@@ -383,7 +381,7 @@ bool wxDisplayImplX11::ChangeMode(const wxVideoMode& WXUNUSED(mode))
 
 #include "wx/utils.h"
 
 
 #include "wx/utils.h"
 
-#if wxUSE_LIBHILDON || wxUSE_LIBHILDON2
+#if wxUSE_LIBHILDON || wxUSE_LIBHILDON2 || !defined(GDK_WINDOWING_X11)
 
 void wxClientDisplayRect(int *x, int *y, int *width, int *height)
 {
 
 void wxClientDisplayRect(int *x, int *y, int *width, int *height)
 {
@@ -425,6 +423,8 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height)
     Display * const dpy = wxGetX11Display();
     wxCHECK_RET( dpy, wxT("can't be called before initializing the GUI") );
 
     Display * const dpy = wxGetX11Display();
     wxCHECK_RET( dpy, wxT("can't be called before initializing the GUI") );
 
+    wxRect rectClient;
+
     const Atom atomWorkArea = XInternAtom(dpy, "_NET_WORKAREA", True);
     if ( atomWorkArea )
     {
     const Atom atomWorkArea = XInternAtom(dpy, "_NET_WORKAREA", True);
     if ( atomWorkArea )
     {
@@ -460,29 +460,46 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height)
                         numItems != 4 )
             {
                 wxLogDebug(wxT("XGetWindowProperty(\"_NET_WORKAREA\") failed"));
                         numItems != 4 )
             {
                 wxLogDebug(wxT("XGetWindowProperty(\"_NET_WORKAREA\") failed"));
-                return;
             }
             }
+            else
+            {
+                rectClient = wxRect(workareas[0], workareas[1],
+                                    workareas[2], workareas[3]);
+            }
+        }
+    }
 
 
-            if ( x )
-                *x = workareas[0];
-            if ( y )
-                *y = workareas[1];
-            if ( width )
-                *width = workareas[2];
-            if ( height )
-                *height = workareas[3];
+    // Although _NET_WORKAREA is supposed to return the client size of the
+    // screen, not all implementations are conforming, apparently, see #14419,
+    // so make sure we return a subset of the primary display.
+    wxRect rectFull;
+#if wxUSE_DISPLAY
+    ScreensInfo screens;
+    const ScreenInfo& info = screens[0];
+    rectFull = wxRect(info.x_org, info.y_org, info.width, info.height);
+#else
+    wxDisplaySize(&rectFull.width, &rectFull.height);
+#endif
 
 
-            return;
-        }
+    if ( !rectClient.width || !rectClient.height )
+    {
+        // _NET_WORKAREA not available or didn't work, fall back to the total
+        // display size.
+        rectClient = rectFull;
+    }
+    else
+    {
+        rectClient = rectClient.Intersect(rectFull);
     }
 
     }
 
-    // if we get here, _NET_WORKAREA is not supported so return the entire
-    // screen size as fall back
-    if (x)
-        *x = 0;
-    if (y)
-        *y = 0;
-    wxDisplaySize(width, height);
+    if ( x )
+        *x = rectClient.x;
+    if ( y )
+        *y = rectClient.y;
+    if ( width )
+        *width = rectClient.width;
+    if ( height )
+        *height = rectClient.height;
 }
 
 #endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
 }
 
 #endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON