display connection from FbTk App
This commit is contained in:
parent
cf287a3fde
commit
3dacf70154
2 changed files with 18 additions and 21 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.22 2002/11/12 14:40:26 fluxgen Exp $
|
// $Id: BaseDisplay.cc,v 1.23 2002/11/26 16:05:34 fluxgen Exp $
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,9 +131,8 @@ void bexec(const char *command, char *displaystring) {
|
||||||
|
|
||||||
|
|
||||||
BaseDisplay *BaseDisplay::s_singleton = 0;
|
BaseDisplay *BaseDisplay::s_singleton = 0;
|
||||||
Display *BaseDisplay::s_display = 0;
|
|
||||||
|
|
||||||
BaseDisplay::BaseDisplay(const char *app_name, const char *dpy_name):
|
BaseDisplay::BaseDisplay(const char *app_name, const char *dpy_name):FbTk::App(dpy_name),
|
||||||
m_startup(true), m_shutdown(false),
|
m_startup(true), m_shutdown(false),
|
||||||
m_display_name(XDisplayName(dpy_name)), m_app_name(app_name),
|
m_display_name(XDisplayName(dpy_name)), m_app_name(app_name),
|
||||||
m_server_grabs(0)
|
m_server_grabs(0)
|
||||||
|
@ -146,7 +145,7 @@ m_server_grabs(0)
|
||||||
last_bad_window = None;
|
last_bad_window = None;
|
||||||
I18n *i18n = I18n::instance();
|
I18n *i18n = I18n::instance();
|
||||||
|
|
||||||
if (! (s_display = XOpenDisplay(dpy_name))) {
|
if (display() == 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
i18n->
|
i18n->
|
||||||
getMessage(
|
getMessage(
|
||||||
|
@ -154,7 +153,7 @@ m_server_grabs(0)
|
||||||
"BaseDisplay::BaseDisplay: connection to X server failed.\n"));
|
"BaseDisplay::BaseDisplay: connection to X server failed.\n"));
|
||||||
|
|
||||||
throw static_cast<int>(2); //throw error 2
|
throw static_cast<int>(2); //throw error 2
|
||||||
} else if (fcntl(ConnectionNumber(s_display), F_SETFD, 1) == -1) {
|
} else if (fcntl(ConnectionNumber(display()), F_SETFD, 1) == -1) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
i18n->
|
i18n->
|
||||||
getMessage(
|
getMessage(
|
||||||
|
@ -165,10 +164,10 @@ m_server_grabs(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
number_of_screens = ScreenCount(s_display);
|
number_of_screens = ScreenCount(display());
|
||||||
|
|
||||||
#ifdef SHAPE
|
#ifdef SHAPE
|
||||||
shape.extensions = XShapeQueryExtension(s_display, &shape.event_basep,
|
shape.extensions = XShapeQueryExtension(display(), &shape.event_basep,
|
||||||
&shape.error_basep);
|
&shape.error_basep);
|
||||||
#else // !SHAPE
|
#else // !SHAPE
|
||||||
shape.extensions = False;
|
shape.extensions = False;
|
||||||
|
@ -192,8 +191,6 @@ BaseDisplay::~BaseDisplay() {
|
||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
XCloseDisplay(s_display);
|
|
||||||
s_display = 0;
|
|
||||||
s_singleton = 0;
|
s_singleton = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,9 +205,9 @@ void BaseDisplay::eventLoop() {
|
||||||
run();
|
run();
|
||||||
|
|
||||||
while ((! m_shutdown) && (! internal_error)) {
|
while ((! m_shutdown) && (! internal_error)) {
|
||||||
if (XPending(s_display)) {
|
if (XPending(display())) {
|
||||||
XEvent e;
|
XEvent e;
|
||||||
XNextEvent(s_display, &e);
|
XNextEvent(display(), &e);
|
||||||
|
|
||||||
if (last_bad_window != None && e.xany.window == last_bad_window) {
|
if (last_bad_window != None && e.xany.window == last_bad_window) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -226,7 +223,7 @@ void BaseDisplay::eventLoop() {
|
||||||
handleEvent(&e);
|
handleEvent(&e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BTimer::updateTimers(ConnectionNumber(s_display)); //handle all timers
|
BTimer::updateTimers(ConnectionNumber(display())); //handle all timers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,8 +231,8 @@ void BaseDisplay::eventLoop() {
|
||||||
|
|
||||||
bool BaseDisplay::validateWindow(Window window) {
|
bool BaseDisplay::validateWindow(Window window) {
|
||||||
XEvent event;
|
XEvent event;
|
||||||
if (XCheckTypedWindowEvent(s_display, window, DestroyNotify, &event)) {
|
if (XCheckTypedWindowEvent(display(), window, DestroyNotify, &event)) {
|
||||||
XPutBackEvent(s_display, &event);
|
XPutBackEvent(display(), &event);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,13 +242,13 @@ bool BaseDisplay::validateWindow(Window window) {
|
||||||
|
|
||||||
void BaseDisplay::grab() {
|
void BaseDisplay::grab() {
|
||||||
if (! m_server_grabs++)
|
if (! m_server_grabs++)
|
||||||
XGrabServer(s_display);
|
XGrabServer(display());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BaseDisplay::ungrab() {
|
void BaseDisplay::ungrab() {
|
||||||
if (! --m_server_grabs)
|
if (! --m_server_grabs)
|
||||||
XUngrabServer(s_display);
|
XUngrabServer(display());
|
||||||
if (m_server_grabs < 0)
|
if (m_server_grabs < 0)
|
||||||
m_server_grabs = 0;
|
m_server_grabs = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,13 @@
|
||||||
// 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.31 2002/11/15 11:57:33 fluxgen Exp $
|
// $Id: BaseDisplay.hh,v 1.32 2002/11/26 16:05:34 fluxgen Exp $
|
||||||
|
|
||||||
#ifndef BASEDISPLAY_HH
|
#ifndef BASEDISPLAY_HH
|
||||||
#define BASEDISPLAY_HH
|
#define BASEDISPLAY_HH
|
||||||
|
|
||||||
#include "NotCopyable.hh"
|
#include "NotCopyable.hh"
|
||||||
|
#include "App.hh"
|
||||||
#include "EventHandler.hh"
|
#include "EventHandler.hh"
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
@ -52,7 +53,7 @@ void bexec(const char *command, char *displaystring);
|
||||||
/**
|
/**
|
||||||
Singleton class to manage display connection
|
Singleton class to manage display connection
|
||||||
*/
|
*/
|
||||||
class BaseDisplay:private NotCopyable, FbTk::EventHandler<XEvent>
|
class BaseDisplay:public FbTk::App, private FbTk::NotCopyable, FbTk::EventHandler<XEvent>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BaseDisplay(const char *app_name, const char *display_name = 0);
|
BaseDisplay(const char *app_name, const char *display_name = 0);
|
||||||
|
@ -92,7 +93,7 @@ public:
|
||||||
inline bool isStartup() const { return m_startup; }
|
inline bool isStartup() const { return m_startup; }
|
||||||
|
|
||||||
|
|
||||||
static Display *getXDisplay() { return s_display; }
|
static Display *getXDisplay() { return App::instance()->display(); }
|
||||||
|
|
||||||
inline const char *getXDisplayName() const { return m_display_name; }
|
inline const char *getXDisplayName() const { return m_display_name; }
|
||||||
inline const char *getApplicationName() const { return m_app_name; }
|
inline const char *getApplicationName() const { return m_app_name; }
|
||||||
|
@ -117,7 +118,6 @@ private:
|
||||||
} shape;
|
} shape;
|
||||||
|
|
||||||
bool m_startup, m_shutdown;
|
bool m_startup, m_shutdown;
|
||||||
static Display *s_display;
|
|
||||||
|
|
||||||
typedef std::vector<ScreenInfo *> ScreenInfoList;
|
typedef std::vector<ScreenInfo *> ScreenInfoList;
|
||||||
ScreenInfoList screenInfoList;
|
ScreenInfoList screenInfoList;
|
||||||
|
|
Loading…
Reference in a new issue