Applied patch [ 649157 ] wxDisplay for Unix

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20823 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 2003-06-01 16:03:24 +00:00
parent a89abd7f0c
commit b1b3ddd840
3 changed files with 189 additions and 1 deletions

View File

@ -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__)

View File

@ -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_

142
src/unix/displayx11.cpp Normal file
View File

@ -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 */