open an X display
This commit is contained in:
parent
c8d584f90e
commit
426b1ea2b6
1 changed files with 14 additions and 1 deletions
|
@ -25,6 +25,8 @@
|
||||||
#endif // HAVE_CONFIG_H
|
#endif // HAVE_CONFIG_H
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
|
@ -50,6 +52,8 @@ using std::endl;
|
||||||
|
|
||||||
bool _shutdown = false;
|
bool _shutdown = false;
|
||||||
char **_argv;
|
char **_argv;
|
||||||
|
char *_display_name = 0;
|
||||||
|
Display *_display = 0;
|
||||||
|
|
||||||
#ifdef HAVE_SIGACTION
|
#ifdef HAVE_SIGACTION
|
||||||
static void signalhandler(int sig)
|
static void signalhandler(int sig)
|
||||||
|
@ -74,6 +78,7 @@ static RETSIGTYPE signalhandler(int sig)
|
||||||
#endif // HAVE_SIGACTION
|
#endif // HAVE_SIGACTION
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int, char **argv) {
|
int main(int, char **argv) {
|
||||||
_argv = argv;
|
_argv = argv;
|
||||||
|
|
||||||
|
@ -98,9 +103,17 @@ int main(int, char **argv) {
|
||||||
signal(SIGINT, (RETSIGTYPE (*)(int)) signalhandler);
|
signal(SIGINT, (RETSIGTYPE (*)(int)) signalhandler);
|
||||||
signal(SIGHUP, (RETSIGTYPE (*)(int)) signalhandler);
|
signal(SIGHUP, (RETSIGTYPE (*)(int)) signalhandler);
|
||||||
#endif // HAVE_SIGACTION
|
#endif // HAVE_SIGACTION
|
||||||
|
|
||||||
|
_display = XOpenDisplay(_display_name);
|
||||||
|
if (! _display) {
|
||||||
|
cout << "Connection to X server '" << _display_name << "' failed.\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
while (! _shutdown) {
|
while (! _shutdown) {
|
||||||
usleep(500);
|
usleep(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XCloseDisplay(_display);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue