]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied patch [ 649157 ] wxDisplay for Unix
authorJulian Smart <julian@anthemion.co.uk>
Sun, 1 Jun 2003 16:03:24 +0000 (16:03 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Sun, 1 Jun 2003 16:03:24 +0000 (16:03 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20823 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/display.h
include/wx/unix/displayx11.h [new file with mode: 0644]
src/unix/displayx11.cpp [new file with mode: 0644]

index 69835ce6aa370424bdb20c9039fd20b0e67b38f3..ddcea733dd1badaa90acd3487e5dc462051255bd 100644 (file)
@@ -152,7 +152,7 @@ protected:
 #elif defined(__WXMOTIF__)
     #include "wx/motif/display.h"
 #elif defined(__WXGTK__)
 #elif defined(__WXMOTIF__)
     #include "wx/motif/display.h"
 #elif defined(__WXGTK__)
-    #include "wx/gtk/display.h"
+    #include "wx/unix/displayx11.h"
 #elif defined(__WXMAC__)
     #include "wx/mac/display.h"
 #elif defined(__WXPM__)
 #elif defined(__WXMAC__)
     #include "wx/mac/display.h"
 #elif defined(__WXPM__)
diff --git a/include/wx/unix/displayx11.h b/include/wx/unix/displayx11.h
new file mode 100644 (file)
index 0000000..2edc3d1
--- /dev/null
@@ -0,0 +1,46 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        displayx11.h
+// Purpose:     wxDisplay class for Unix/X11
+// Author:      Brian Victor
+// Modified by: 
+// Created:     12/05/02
+// RCS-ID:      $Id$
+// Copyright:   (c) wxWindows team
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_DISPLAYX11_H_
+#define _WX_DISPLAYX11_H_
+
+#if wxUSE_DISPLAY
+
+#if defined(__GNUG__) && !defined(__APPLE__)
+    #pragma interface "display.h"
+#endif
+
+class wxRect;
+class wxString;
+class wxDisplayUnixPriv;
+
+class WXDLLEXPORT wxDisplay : public wxDisplayBase
+{
+
+  public:
+    wxDisplay ( size_t index = 0 );
+
+    virtual wxRect GetGeometry() const;
+    virtual int GetDepth() const;
+    virtual wxString GetName() const;
+
+    ~wxDisplay();
+
+  private:
+    wxDisplayUnixPriv *m_priv;
+
+    DECLARE_NO_COPY_CLASS(wxDisplay);
+};
+
+#endif // wxUSE_DISPLAY
+
+#endif // _WX_GTK_DISPLAY_H_
+
diff --git a/src/unix/displayx11.cpp b/src/unix/displayx11.cpp
new file mode 100644 (file)
index 0000000..78a1656
--- /dev/null
@@ -0,0 +1,142 @@
+///////////////////////////////////////////////////////////////////////////
+// Name:        displayx11.cpp
+// Purpose:     Unix/X11 implementation of wxDisplay class
+// Author:      Brian Victor
+// Modified by:
+// Created:     12/05/02
+// RCS-ID:      $Id$
+// Copyright:   (c) wxWindows team
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+    #pragma implementation "display.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+  #pragma hdrstop
+#endif
+
+#include "wx/display.h"
+
+#ifndef WX_PRECOMP
+  #include "wx/dynarray.h"
+  #include "wx/gdicmn.h"
+  #include "wx/string.h"
+  #include "wx/utils.h"
+#endif /* WX_PRECOMP */
+
+#if wxUSE_DISPLAY
+
+/* These must be included after the wx files.  Otherwise the Data macro in
+ * Xlibint.h conflicts with a function declaration in wx/list.h.  */
+extern "C" {
+  #include <X11/Xlib.h>
+  #include <X11/Xlibint.h>
+  #include <X11/extensions/Xinerama.h>
+}
+
+class wxDisplayUnixPriv
+{
+  public:
+    wxRect m_rect;
+    int m_depth;
+};
+
+size_t wxDisplayBase::GetCount()
+{
+  Display *disp = (Display*)wxGetDisplay();
+
+  if ( XineramaIsActive(disp) )
+  {
+    XineramaScreenInfo *screenarr;
+    int numscreens;
+    screenarr = XineramaQueryScreens(disp, &numscreens);
+    XFree(screenarr);
+    return numscreens;
+  }
+  else
+  {
+    return 1;
+  }
+}
+
+int wxDisplayBase::GetFromPoint(const wxPoint &p)
+{
+  Display *disp = (Display*)wxGetDisplay();
+
+  if ( XineramaIsActive(disp) )
+  {
+    int which_screen = -1;
+    XineramaScreenInfo *screenarr;
+    int numscreens;
+    screenarr = XineramaQueryScreens(disp, &numscreens);
+
+    int i;
+    for (i = 0; i < numscreens; ++i)
+    {
+      if (p.x >= screenarr[i].x_org &&
+          p.x <= screenarr[i].x_org + screenarr[i].width &&
+          p.y >= screenarr[i].y_org &&
+          p.y <= screenarr[i].y_org + screenarr[i].height)
+      {
+        which_screen = i;
+      }
+    }
+
+    XFree(screenarr);
+    return which_screen;
+  }
+  else
+  {
+    return 0;
+  }
+}
+
+wxDisplay::wxDisplay(size_t index) : wxDisplayBase ( index ), m_priv( new wxDisplayUnixPriv )
+{
+  Display *disp = (Display*)wxGetDisplay();
+
+  if ( XineramaIsActive(disp) )
+  {
+    XineramaScreenInfo *screenarr;
+    int numscreens;
+    screenarr = XineramaQueryScreens(disp, &numscreens);
+    m_priv->m_rect = wxRect(screenarr[index].x_org, screenarr[index].y_org,
+                            screenarr[index].width, screenarr[index].height);
+    m_priv->m_depth = DefaultDepth(disp, DefaultScreen(disp));
+    XFree(screenarr);
+  }
+  else
+  {
+    wxSize size = wxGetDisplaySize();
+    m_priv->m_rect = wxRect(0, 0, size.GetWidth(), size.GetHeight());
+    m_priv->m_depth = wxDisplayDepth();
+  }
+}
+
+wxDisplay::~wxDisplay()
+{
+  delete m_priv;
+}
+
+wxRect wxDisplay::GetGeometry() const
+{
+  return m_priv->m_rect;
+}
+
+int wxDisplay::GetDepth() const
+{
+  return m_priv->m_depth;
+}
+
+wxString wxDisplay::GetName() const
+{
+  return "";
+}
+
+#endif /* wxUSE_DISPLAY */
+