we don't like to modify the arguments, const-correctness and other strange code in Xinerama
This commit is contained in:
parent
95aeda2627
commit
ccf9f5749e
2 changed files with 54 additions and 98 deletions
|
@ -22,7 +22,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// $Id: BaseDisplay.cc,v 1.9 2002/03/19 14:30:42 fluxgen Exp $
|
// $Id: BaseDisplay.cc,v 1.10 2002/03/19 21:19:55 fluxgen Exp $
|
||||||
|
|
||||||
// use GNU extensions
|
// use GNU extensions
|
||||||
#ifndef _GNU_SOURCE
|
#ifndef _GNU_SOURCE
|
||||||
|
@ -428,7 +428,7 @@ ScreenInfo::ScreenInfo(BaseDisplay *d, int num) {
|
||||||
// check if we have Xinerama extension enabled
|
// check if we have Xinerama extension enabled
|
||||||
if (XineramaIsActive(basedisplay->getXDisplay())) {
|
if (XineramaIsActive(basedisplay->getXDisplay())) {
|
||||||
m_hasXinerama = true;
|
m_hasXinerama = true;
|
||||||
xineramaLastHead = 0; // initialize this
|
xineramaLastHead = 0;
|
||||||
xineramaInfos =
|
xineramaInfos =
|
||||||
XineramaQueryScreens(basedisplay->getXDisplay(), &xineramaNumHeads);
|
XineramaQueryScreens(basedisplay->getXDisplay(), &xineramaNumHeads);
|
||||||
} else {
|
} else {
|
||||||
|
@ -455,7 +455,6 @@ ScreenInfo::~ScreenInfo(void) {
|
||||||
// activated it'll return head nr 0
|
// activated it'll return head nr 0
|
||||||
//-----------------------------------------
|
//-----------------------------------------
|
||||||
unsigned int ScreenInfo::getHead(int x, int y) {
|
unsigned int ScreenInfo::getHead(int x, int y) {
|
||||||
unsigned int head = 0;
|
|
||||||
|
|
||||||
// is Xinerama extensions enabled?
|
// is Xinerama extensions enabled?
|
||||||
if (hasXinerama()) {
|
if (hasXinerama()) {
|
||||||
|
@ -466,25 +465,20 @@ unsigned int ScreenInfo::getHead(int x, int y) {
|
||||||
(xineramaInfos[xineramaLastHead].y_org <= y) &&
|
(xineramaInfos[xineramaLastHead].y_org <= y) &&
|
||||||
((xineramaInfos[xineramaLastHead].y_org +
|
((xineramaInfos[xineramaLastHead].y_org +
|
||||||
xineramaInfos[xineramaLastHead].height) > y)) {
|
xineramaInfos[xineramaLastHead].height) > y)) {
|
||||||
head = xineramaLastHead;
|
return xineramaLastHead;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// go trough all the heads, and search
|
// go trough all the heads, and search
|
||||||
for (int i = 0; (signed) head < xineramaNumHeads; i++) {
|
for (int i = 0; (signed) i < xineramaNumHeads; i++) {
|
||||||
if ((xineramaInfos[i].x_org <= x) &&
|
if (xineramaInfos[i].x_org <= x &&
|
||||||
((xineramaInfos[i].x_org + xineramaInfos[i].width) > x) &&
|
xineramaInfos[i].x_org + xineramaInfos[i].width) > x &&
|
||||||
(xineramaInfos[i].y_org <= y) &&
|
xineramaInfos[i].y_org <= y &&
|
||||||
((xineramaInfos[i].y_org + xineramaInfos[i].height) > y)) {
|
xineramaInfos[i].y_org + xineramaInfos[i].height) > y)
|
||||||
// TODO: actually set this to last head?
|
return (xineramaLastHead = i);
|
||||||
head = xineramaLastHead = i;
|
|
||||||
|
|
||||||
break; // we don't wanna spend CPU searching what we
|
|
||||||
} // allready have found, do we?
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return head;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------- getCurrHead --------------
|
//------------- getCurrHead --------------
|
||||||
|
@ -492,52 +486,27 @@ unsigned int ScreenInfo::getHead(int x, int y) {
|
||||||
// currently is on, if it isn't found
|
// currently is on, if it isn't found
|
||||||
// the first one is returned
|
// the first one is returned
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
unsigned int ScreenInfo::getCurrHead(void) {
|
unsigned int ScreenInfo::getCurrHead(void) const {
|
||||||
unsigned int head = 0;
|
|
||||||
|
|
||||||
// is Xinerama extensions enabled?
|
// is Xinerama extensions enabled?
|
||||||
if (hasXinerama()) {
|
if (hasXinerama()) {
|
||||||
int pX, pY, wX, wY;
|
int x, y, wX, wY;
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
Window rRoot, rChild;
|
Window rRoot, rChild;
|
||||||
|
// get pointer cordinates
|
||||||
// check if last head is still active
|
if ( (XQueryPointer(basedisplay->getXDisplay(), root_window,
|
||||||
if ((xineramaInfos[xineramaLastHead].x_org <= pX) &&
|
&rRoot, &rChild, &x, &y, &wX, &wY, &mask)) != 0 ) {
|
||||||
((xineramaInfos[xineramaLastHead].x_org +
|
return getHead(x, y);
|
||||||
xineramaInfos[xineramaLastHead].width) > pX) &&
|
|
||||||
(xineramaInfos[xineramaLastHead].y_org <= pY) &&
|
|
||||||
((xineramaInfos[xineramaLastHead].y_org +
|
|
||||||
xineramaInfos[xineramaLastHead].height) > pY)) {
|
|
||||||
head = xineramaLastHead;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// get pointer cordinates , we need to know were we are!
|
|
||||||
if ( (XQueryPointer(basedisplay->getXDisplay(), root_window,
|
|
||||||
&rRoot, &rChild, &pX, &pY, &wX, &wY, &mask)) != 0 ) {
|
|
||||||
|
|
||||||
// go trough all the heads, and search
|
|
||||||
for (int i = 0; i < xineramaNumHeads; i++) {
|
|
||||||
if ((xineramaInfos[i].x_org <= pX) &&
|
|
||||||
((xineramaInfos[i].x_org + xineramaInfos[i].width) > pX) &&
|
|
||||||
(xineramaInfos[i].y_org <= pY) &&
|
|
||||||
((xineramaInfos[i].y_org + xineramaInfos[i].height) > pY)) {
|
|
||||||
|
|
||||||
head = xineramaLastHead = i;
|
|
||||||
break; // we don't wanna spend CPU searching what we
|
|
||||||
} // allready have found, do we?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return head;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------- getHeadWidth ------------
|
//----------- getHeadWidth ------------
|
||||||
// Returns the width of head nr head
|
// Returns the width of head
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
unsigned int ScreenInfo::getHeadWidth(unsigned int head) {
|
unsigned int ScreenInfo::getHeadWidth(unsigned int head) {
|
||||||
unsigned int width;
|
|
||||||
|
|
||||||
if (hasXinerama()) {
|
if (hasXinerama()) {
|
||||||
if ((signed) head >= xineramaNumHeads) {
|
if ((signed) head >= xineramaNumHeads) {
|
||||||
|
@ -545,23 +514,19 @@ unsigned int ScreenInfo::getHeadWidth(unsigned int head) {
|
||||||
cerr << __FILE__ << ":" <<__LINE__ << ": " <<
|
cerr << __FILE__ << ":" <<__LINE__ << ": " <<
|
||||||
"Head: " << head << " doesn't exist!" << endl;
|
"Head: " << head << " doesn't exist!" << endl;
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
return xineramaInfos[xineramaNumHeads - 1].width;
|
||||||
head = xineramaNumHeads - 1;
|
} else
|
||||||
}
|
return xineramaInfos[head].width;
|
||||||
|
|
||||||
width = xineramaInfos[head].width;
|
|
||||||
} else {
|
|
||||||
width = getWidth();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return getWidth();
|
||||||
|
|
||||||
return width;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------- getHeadHeight ------------
|
//----------- getHeadHeight ------------
|
||||||
// Returns the heigt of head nr head
|
// Returns the heigt of head
|
||||||
//--------------------------------------
|
//--------------------------------------
|
||||||
unsigned int ScreenInfo::getHeadHeight(unsigned int head) {
|
unsigned int ScreenInfo::getHeadHeight(unsigned int head) const {
|
||||||
unsigned int height;
|
|
||||||
|
|
||||||
if (hasXinerama()) {
|
if (hasXinerama()) {
|
||||||
if ((signed) head >= xineramaNumHeads) {
|
if ((signed) head >= xineramaNumHeads) {
|
||||||
|
@ -569,59 +534,49 @@ unsigned int ScreenInfo::getHeadHeight(unsigned int head) {
|
||||||
cerr << __FILE__ << ":" <<__LINE__ << ": " <<
|
cerr << __FILE__ << ":" <<__LINE__ << ": " <<
|
||||||
"Head: " << head << " doesn't exist!" << endl;
|
"Head: " << head << " doesn't exist!" << endl;
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
return xineramaInfos[xineramaNumHeads - 1].height;
|
||||||
head = xineramaNumHeads - 1;
|
} else
|
||||||
}
|
return xineramaInfos[head].height;
|
||||||
|
|
||||||
height = xineramaInfos[head].height;
|
|
||||||
} else {
|
|
||||||
height = getHeight();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return height;
|
return getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----------- getHeadX -----------------
|
//----------- getHeadX -----------------
|
||||||
// Returns the X start of head nr head
|
// Returns the X start of head nr head
|
||||||
//--------------------------------------
|
//--------------------------------------
|
||||||
int ScreenInfo::getHeadX(unsigned int head) {
|
int ScreenInfo::getHeadX(unsigned int head) const {
|
||||||
int x = 0;
|
|
||||||
|
|
||||||
if (hasXinerama()) {
|
if (hasXinerama()) {
|
||||||
if ((signed) head >= xineramaNumHeads) {
|
if ((signed) head >= xineramaNumHeads) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
cerr << __FILE__ << ":" <<__LINE__ << ": " <<
|
cerr << __FILE__ << ":" <<__LINE__ << ": " <<
|
||||||
"Head: " << head << " doesn't exist!" << endl;
|
"Head: " << head << " doesn't exist!" << endl;
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
return xineramaInfos[head = xineramaNumHeads - 1].x_org;
|
||||||
head = xineramaNumHeads - 1;
|
} else
|
||||||
}
|
return xineramaInfos[head].x_org;
|
||||||
x = xineramaInfos[head].x_org;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return x;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------- getHeadY -----------------
|
//----------- getHeadY -----------------
|
||||||
// Returns the Y start of head nr head
|
// Returns the Y start of head
|
||||||
//--------------------------------------
|
//--------------------------------------
|
||||||
int ScreenInfo::getHeadY(unsigned int head) {
|
int ScreenInfo::getHeadY(unsigned int head) const {
|
||||||
int y = 0;
|
|
||||||
|
|
||||||
if (hasXinerama()) {
|
if (hasXinerama()) {
|
||||||
if ((signed) head >= xineramaNumHeads) {
|
if ((signed) head >= xineramaNumHeads) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
cerr << __FILE__ << ":" <<__LINE__ << ": " <<
|
cerr << __FILE__ << ":" <<__LINE__ << ": " <<
|
||||||
"Head: " << head << " doesn't exist!" << endl;
|
"Head: " << head << " doesn't exist!" << endl;
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
return xineramaInfos[xineramaNumHeads - 1].y_org;
|
||||||
head = xineramaNumHeads - 1;
|
} else
|
||||||
}
|
return xineramaInfos[head].y_org;
|
||||||
y = xineramaInfos[head].y_org;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return y;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // XINERAMA
|
#endif // XINERAMA
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// $Id: BaseDisplay.hh,v 1.16 2002/03/19 14:30:42 fluxgen Exp $
|
// $Id: BaseDisplay.hh,v 1.17 2002/03/19 21:19:55 fluxgen Exp $
|
||||||
|
|
||||||
#ifndef BASEDISPLAY_HH
|
#ifndef BASEDISPLAY_HH
|
||||||
#define BASEDISPLAY_HH
|
#define BASEDISPLAY_HH
|
||||||
|
@ -32,9 +32,9 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <X11/extensions/Xinerama.h>
|
#include <X11/extensions/Xinerama.h>
|
||||||
}
|
}
|
||||||
#endif // XINERAMA
|
#endif // XINERAMA
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
@ -166,12 +166,12 @@ public:
|
||||||
inline const unsigned int getHeight(void) const { return height; }
|
inline const unsigned int getHeight(void) const { return height; }
|
||||||
|
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
inline bool hasXinerama(void) { return m_hasXinerama; }
|
inline bool hasXinerama(void) const { return m_hasXinerama; }
|
||||||
inline int getNumHeads(void) { return xineramaNumHeads; }
|
inline int getNumHeads(void) const { return xineramaNumHeads; }
|
||||||
unsigned int getHead(int x, int y);
|
unsigned int getHead(int x, int y) const;
|
||||||
unsigned int getCurrHead(void);
|
unsigned int getCurrHead(void) const;
|
||||||
unsigned int getHeadWidth(unsigned int head);
|
unsigned int getHeadWidth(unsigned int head) const;
|
||||||
unsigned int getHeadHeight(unsigned int head);
|
unsigned int getHeadHeight(unsigned int head) const;
|
||||||
int getHeadX(unsigned int head);
|
int getHeadX(unsigned int head);
|
||||||
int getHeadY(unsigned int head);
|
int getHeadY(unsigned int head);
|
||||||
#endif // XINERAMA
|
#endif // XINERAMA
|
||||||
|
@ -184,13 +184,14 @@ private:
|
||||||
|
|
||||||
int depth, screen_number;
|
int depth, screen_number;
|
||||||
unsigned int width, height;
|
unsigned int width, height;
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
bool m_hasXinerama;
|
bool m_hasXinerama;
|
||||||
int xineramaMajor, xineramaMinor, xineramaNumHeads, xineramaLastHead;
|
int xineramaMajor, xineramaMinor, xineramaNumHeads, xineramaLastHead;
|
||||||
XineramaScreenInfo *xineramaInfos;
|
XineramaScreenInfo *xineramaInfos;
|
||||||
#endif // XINERAMA
|
#endif // XINERAMA
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // BASEDISPLAY_HH
|
#endif // BASEDISPLAY_HH
|
||||||
|
|
Loading…
Reference in a new issue