From: Julian Smart Date: Sun, 1 Jun 2003 16:03:24 +0000 (+0000) Subject: Applied patch [ 649157 ] wxDisplay for Unix X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b1b3ddd840a507f3ca85379bfa832f2b0c9105d6 Applied patch [ 649157 ] wxDisplay for Unix git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20823 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/display.h b/include/wx/display.h index 69835ce6aa..ddcea733dd 100644 --- a/include/wx/display.h +++ b/include/wx/display.h @@ -152,7 +152,7 @@ protected: #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__) diff --git a/include/wx/unix/displayx11.h b/include/wx/unix/displayx11.h new file mode 100644 index 0000000000..2edc3d1fca --- /dev/null +++ b/include/wx/unix/displayx11.h @@ -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 index 0000000000..78a1656812 --- /dev/null +++ b/src/unix/displayx11.cpp @@ -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 + #include + #include +} + +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 */ +