removed bexec and fixed indent
This commit is contained in:
parent
d019be5bf5
commit
a4d46a4cac
1 changed files with 271 additions and 283 deletions
|
@ -22,7 +22,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: BaseDisplay.cc,v 1.25 2002/12/02 20:02:56 fluxgen Exp $
|
||||
// $Id: BaseDisplay.cc,v 1.26 2003/01/09 21:55:58 fluxgen Exp $
|
||||
|
||||
|
||||
|
||||
|
@ -91,8 +91,9 @@ using namespace std;
|
|||
static Bool internal_error = False;
|
||||
static Window last_bad_window = None;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
static int handleXErrors(Display *d, XErrorEvent *e) {
|
||||
#ifdef DEBUG
|
||||
char errtxt[128];
|
||||
|
||||
XGetErrorText(d, e->error_code, errtxt, 128);
|
||||
|
@ -104,9 +105,7 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
|
|||
BaseDisplay::instance()->getApplicationName(), errtxt, e->error_code,
|
||||
e->request_code, e->minor_code, e->resourceid);
|
||||
|
||||
#else // !DEBUG
|
||||
static int handleXErrors(Display *, XErrorEvent *e) {
|
||||
#endif // DEBUG
|
||||
#endif // !DEBUG
|
||||
|
||||
if (e->error_code == BadWindow)
|
||||
last_bad_window = e->resourceid;
|
||||
|
@ -115,28 +114,17 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
|
|||
abort();
|
||||
|
||||
return(False);
|
||||
}
|
||||
|
||||
// convenience functions
|
||||
#ifndef __EMX__
|
||||
void bexec(const char *command, char *displaystring) {
|
||||
if (! fork()) {
|
||||
setsid();
|
||||
putenv(displaystring);
|
||||
execl("/bin/sh", "/bin/sh", "-c", command, 0);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
#endif // !__EMX__
|
||||
}
|
||||
|
||||
|
||||
BaseDisplay *BaseDisplay::s_singleton = 0;
|
||||
|
||||
BaseDisplay::BaseDisplay(const char *app_name, const char *dpy_name):FbTk::App(dpy_name),
|
||||
BaseDisplay *BaseDisplay::s_singleton = 0;
|
||||
|
||||
BaseDisplay::BaseDisplay(const char *app_name, const char *dpy_name):FbTk::App(dpy_name),
|
||||
m_startup(true), m_shutdown(false),
|
||||
m_display_name(XDisplayName(dpy_name)), m_app_name(app_name),
|
||||
m_server_grabs(0)
|
||||
{
|
||||
{
|
||||
if (s_singleton != 0)
|
||||
throw string("Can't create more than one instance of BaseDisplay!");
|
||||
|
||||
|
@ -179,10 +167,10 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
|
|||
ScreenInfo *screeninfo = new ScreenInfo(i);
|
||||
screenInfoList.push_back(screeninfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BaseDisplay::~BaseDisplay() {
|
||||
BaseDisplay::~BaseDisplay() {
|
||||
|
||||
ScreenInfoList::iterator it = screenInfoList.begin();
|
||||
ScreenInfoList::iterator it_end = screenInfoList.end();
|
||||
|
@ -191,16 +179,16 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
|
|||
}
|
||||
|
||||
s_singleton = 0;
|
||||
}
|
||||
}
|
||||
|
||||
BaseDisplay *BaseDisplay::instance() {
|
||||
BaseDisplay *BaseDisplay::instance() {
|
||||
if (s_singleton == 0)
|
||||
throw string("BaseDisplay not created!");
|
||||
|
||||
return s_singleton;
|
||||
}
|
||||
}
|
||||
|
||||
void BaseDisplay::eventLoop() {
|
||||
void BaseDisplay::eventLoop() {
|
||||
run();
|
||||
|
||||
while ((! m_shutdown) && (! internal_error)) {
|
||||
|
@ -222,13 +210,13 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
|
|||
handleEvent(&e);
|
||||
}
|
||||
} else {
|
||||
BTimer::updateTimers(ConnectionNumber(display())); //handle all timers
|
||||
}
|
||||
FbTk::Timer::updateTimers(ConnectionNumber(display())); //handle all timers
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool BaseDisplay::validateWindow(Window window) {
|
||||
bool BaseDisplay::validateWindow(Window window) {
|
||||
XEvent event;
|
||||
if (XCheckTypedWindowEvent(display(), window, DestroyNotify, &event)) {
|
||||
XPutBackEvent(display(), &event);
|
||||
|
@ -236,23 +224,23 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
|
|||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BaseDisplay::grab() {
|
||||
void BaseDisplay::grab() {
|
||||
if (! m_server_grabs++)
|
||||
XGrabServer(display());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BaseDisplay::ungrab() {
|
||||
void BaseDisplay::ungrab() {
|
||||
if (! --m_server_grabs)
|
||||
XUngrabServer(display());
|
||||
if (m_server_grabs < 0)
|
||||
m_server_grabs = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ScreenInfo::ScreenInfo(int num) {
|
||||
ScreenInfo::ScreenInfo(int num) {
|
||||
basedisplay = BaseDisplay::instance();
|
||||
Display * const disp = basedisplay->getXDisplay();
|
||||
screen_number = num;
|
||||
|
@ -310,30 +298,30 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
|
|||
xineramaInfos = 0; // make sure we don't point anywhere we shouldn't
|
||||
}
|
||||
#endif // XINERAMA
|
||||
}
|
||||
}
|
||||
|
||||
ScreenInfo::~ScreenInfo() {
|
||||
ScreenInfo::~ScreenInfo() {
|
||||
#ifdef XINERAMA
|
||||
if (m_hasXinerama) { // only free if we first had it
|
||||
XFree(xineramaInfos);
|
||||
xineramaInfos = 0;
|
||||
}
|
||||
#endif // XINERAMA
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef XINERAMA
|
||||
|
||||
//---------------- getHead ---------------
|
||||
// Searches for the head at the coordinates
|
||||
// x,y. If it fails or Xinerama isn't
|
||||
// activated it'll return head nr 0
|
||||
//-----------------------------------------
|
||||
unsigned int ScreenInfo::getHead(int x, int y) const {
|
||||
/**
|
||||
Searches for the head at the coordinates
|
||||
x,y. If it fails or Xinerama isn't
|
||||
activated it'll return head nr 0
|
||||
*/
|
||||
unsigned int ScreenInfo::getHead(int x, int y) const {
|
||||
|
||||
// is Xinerama extensions enabled?
|
||||
if (hasXinerama()) {
|
||||
// check if last head is still active
|
||||
/* if ((xineramaInfos[xineramaLastHead].x_org <= x) &&
|
||||
/* if ((xineramaInfos[xineramaLastHead].x_org <= x) &&
|
||||
((xineramaInfos[xineramaLastHead].x_org +
|
||||
xineramaInfos[xineramaLastHead].width) > x) &&
|
||||
(xineramaInfos[xineramaLastHead].y_org <= y) &&
|
||||
|
@ -354,14 +342,14 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
|
|||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//------------- getCurrHead --------------
|
||||
// Searches for the head that the pointer
|
||||
// currently is on, if it isn't found
|
||||
// the first one is returned
|
||||
//----------------------------------------
|
||||
unsigned int ScreenInfo::getCurrHead(void) const {
|
||||
/**
|
||||
Searches for the head that the pointer
|
||||
currently is on, if it isn't found
|
||||
the first one is returned
|
||||
*/
|
||||
unsigned int ScreenInfo::getCurrHead(void) const {
|
||||
|
||||
// is Xinerama extensions enabled?
|
||||
if (hasXinerama()) {
|
||||
|
@ -376,12 +364,12 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
|
|||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//----------- getHeadWidth ------------
|
||||
// Returns the width of head
|
||||
//-------------------------------------
|
||||
unsigned int ScreenInfo::getHeadWidth(unsigned int head) const {
|
||||
unsigned int ScreenInfo::getHeadWidth(unsigned int head) const {
|
||||
|
||||
if (hasXinerama()) {
|
||||
if ((signed) head >= xineramaNumHeads) {
|
||||
|
@ -396,12 +384,12 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
|
|||
|
||||
return getWidth();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//----------- getHeadHeight ------------
|
||||
// Returns the heigt of head
|
||||
//--------------------------------------
|
||||
unsigned int ScreenInfo::getHeadHeight(unsigned int head) const {
|
||||
unsigned int ScreenInfo::getHeadHeight(unsigned int head) const {
|
||||
|
||||
if (hasXinerama()) {
|
||||
if ((signed) head >= xineramaNumHeads) {
|
||||
|
@ -415,13 +403,13 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
|
|||
}
|
||||
|
||||
return getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//----------- getHeadX -----------------
|
||||
// Returns the X start of head nr head
|
||||
//--------------------------------------
|
||||
int ScreenInfo::getHeadX(unsigned int head) const {
|
||||
int ScreenInfo::getHeadX(unsigned int head) const {
|
||||
if (hasXinerama()) {
|
||||
if ((signed) head >= xineramaNumHeads) {
|
||||
#ifdef DEBUG
|
||||
|
@ -434,12 +422,12 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
|
|||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//----------- getHeadY -----------------
|
||||
// Returns the Y start of head
|
||||
//--------------------------------------
|
||||
int ScreenInfo::getHeadY(unsigned int head) const {
|
||||
int ScreenInfo::getHeadY(unsigned int head) const {
|
||||
if (hasXinerama()) {
|
||||
if ((signed) head >= xineramaNumHeads) {
|
||||
#ifdef DEBUG
|
||||
|
@ -452,6 +440,6 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
|
|||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // XINERAMA
|
||||
|
|
Loading…
Reference in a new issue