From 1f3ee12a9a3fc09f69f45201c857a02b7abb127c Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 8 Aug 2013 14:33:33 -0500 Subject: Change mount API to allow for mount backends other than pmount Add static convenience method for determining X11 VT mapping to TDEApplication --- tdecore/tdeapplication.cpp | 81 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'tdecore/tdeapplication.cpp') diff --git a/tdecore/tdeapplication.cpp b/tdecore/tdeapplication.cpp index 857c157e8..9a5bd7a0b 100644 --- a/tdecore/tdeapplication.cpp +++ b/tdecore/tdeapplication.cpp @@ -175,6 +175,14 @@ typedef void* IceIOErrorHandler; #include #endif +#if defined Q_WS_X11 +#include +#include +extern "C" { +extern int getfd(const char *fnam); +} +#endif + #include "kappdcopiface.h" // exported for tdm kfrontend @@ -242,6 +250,67 @@ void TDEApplication_init_windows(bool GUIenabled); class QAssistantClient; #endif +#ifdef Q_WS_X11 +// -------------------------------------------------------------------------------------- +// Get the VT number X is running on +// (code taken from GDM, daemon/getvt.c, GPLv2+) +// -------------------------------------------------------------------------------------- +int get_x_vtnum(Display *dpy) +{ + Atom prop; + Atom actualtype; + int actualformat; + unsigned long nitems; + unsigned long bytes_after; + unsigned char *buf; + int num; + + prop = XInternAtom (dpy, "XFree86_VT", False); + if (prop == None) + return -1; + + if (XGetWindowProperty (dpy, DefaultRootWindow (dpy), prop, 0, 1, + False, AnyPropertyType, &actualtype, &actualformat, + &nitems, &bytes_after, &buf)) { + return -1; + } + + if (nitems != 1) { + XFree (buf); + return -1; + } + + switch (actualtype) { + case XA_CARDINAL: + case XA_INTEGER: + case XA_WINDOW: + switch (actualformat) { + case 8: + num = (*(uint8_t *)(void *)buf); + break; + case 16: + num = (*(uint16_t *)(void *)buf); + break; + case 32: + num = (*(uint32_t *)(void *)buf); + break; + default: + XFree (buf); + return -1; + } + break; + default: + XFree (buf); + return -1; + } + + XFree (buf); + + return num; +} +// -------------------------------------------------------------------------------------- +#endif // Q_WS_X11 + /* Private data to make keeping binary compatibility easier */ @@ -3632,6 +3701,18 @@ TQ_ButtonState TDEApplication::keyboardMouseState() return static_cast< ButtonState >( ret ); } +#if defined Q_WS_X11 +int TDEApplication::currentX11VT() +{ + return get_x_vtnum(TQPaintDevice::x11AppDisplay()); +} +#else // Q_WS_X11 +int TDEApplication::currentX11VT() +{ + return -1; +} +#endif // Q_WS_X11 + void TDEApplication::installSigpipeHandler() { #ifdef Q_OS_UNIX -- cgit v1.2.1