git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23970 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
152 lines
3.2 KiB
C++
152 lines
3.2 KiB
C++
///////////////////////////////////////////////////////////////////////////
|
|
// 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
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
|
#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
|
|
{
|
|
wxSize size = wxGetDisplaySize();
|
|
if (p.x >= 0 &&
|
|
p.x <= size.GetWidth() &&
|
|
p.y > 0 &&
|
|
p.y <= size.GetHeight())
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
return -1
|
|
}
|
|
}
|
|
|
|
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 wxEmptyString;
|
|
}
|
|
|
|
#endif /* wxUSE_DISPLAY */
|
|
|