This patch adds Xinerama awareness to VNC 4.0b4 when running in
fullscreen. By adding an additional command line option
(-Xineramascreen=NUM) to vncviewer. If this option is set the viewer
window will be maximized (fullscreen, with no wm decorations) to a
specific Xinerama screen only, leaving other screens uncluttered. If
unset the old behavior is intact. (window maximized across all screens
ignoring physical monitor boundries.) With this patch it's now possible
for me to run a VNC session on one screen and local X on the other,
moving the mouse between the monitors switches input focus automatic.
Please consider inclusion into VNC 4.0.
Regards,
Jakob Kemi <[EMAIL PROTECTED]>
diff -urN vnc-4.0b4-unixsrc.orig/configure.in vnc-4.0b4-unixsrc/configure.in
--- vnc-4.0b4-unixsrc.orig/configure.in 2003-07-31 17:57:20.000000000 +0200
+++ vnc-4.0b4-unixsrc/configure.in 2004-05-19 15:10:43.000000000 +0200
@@ -78,6 +78,11 @@
SOCKLEN_T_DEFINE='-DVNC_SOCKLEN_T=int')
AC_SUBST(SOCKLEN_T_DEFINE)
+AC_CHECK_LIB(Xinerama, XineramaIsActive,
+ [ AC_DEFINE(HAVE_XINERAMA, 1, [Define if you have Xinerama support])
+ X_PRE_LIBS="$X_PRE_LIBS -lXinerama"
+ ],, $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS)
+
BOILERPLATE=boilerplate.mk
if (sh -c "make --version" 2>/dev/null | grep GNU 2>&1 >/dev/null); then
diff -urN vnc-4.0b4-unixsrc.orig/vncviewer/CConn.cxx
vnc-4.0b4-unixsrc/vncviewer/CConn.cxx
--- vnc-4.0b4-unixsrc.orig/vncviewer/CConn.cxx 2003-09-04 15:04:40.000000000 +0200
+++ vnc-4.0b4-unixsrc/vncviewer/CConn.cxx 2004-05-19 16:33:33.000000000 +0200
@@ -37,6 +37,10 @@
#include "PasswdDialog.h"
#include "parameters.h"
+#ifdef HAVE_XINERAMA
+# include <X11/extensions/Xinerama.h>
+#endif
+
using namespace rfb;
static rfb::LogWriter vlog("CConn");
@@ -49,7 +53,7 @@
"F8");
CConn::CConn(Display* dpy_, int argc_, char** argv_, network::Socket* sock_,
- char* vncServerName)
+ char* vncServerName, int xineramascreen)
: dpy(dpy_), argc(argc_),
argv(argv_), serverHost(0), serverPort(0), sock(sock_), viewport(0),
desktop(0), desktopEventHandler(0),
@@ -61,7 +65,7 @@
{
CharArray menuKeyStr(menuKey.getData());
menuKeysym = XStringToKeysym(menuKeyStr.buf);
-
+ xineramaScreen = xineramascreen;
setShared(shared);
addSecType(secTypeNone);
addSecType(secTypeVncAuth);
@@ -533,7 +537,9 @@
if (fullScreen) {
XGrabKeyboard(dpy, desktop->win(), True, GrabModeAsync, GrabModeAsync,
CurrentTime);
+ desktop->setGrabKeyboard(true);
} else {
+ desktop->setGrabKeyboard(false);
XUngrabKeyboard(dpy, CurrentTime);
}
if (oldViewport) delete oldViewport;
@@ -543,6 +549,22 @@
{
viewport->setMaxSize(cp.width, cp.height);
if (fullScreen) {
+#ifdef HAVE_XINERAMA
+ int number;
+ XineramaScreenInfo* info = XineramaQueryScreens (dpy, &number);
+ // Find requested Xinerama screen
+ for (int i = 0; (info != NULL) && (i < number); i++) {
+ // Setup window to match found Xinerama screen
+ if (info[i].screen_number == xineramaScreen) {
+ viewport->setUSPosition(info[i].x_org, info[i].y_org);
+ viewport->resize(info[i].width, info[i].height);
+ XFree(info);
+ return;
+ }
+ }
+ XFree(info);
+#endif
+ // No Xinerama screen found, or none requested, fill default display
viewport->resize(DisplayWidth(dpy,DefaultScreen(dpy)),
DisplayHeight(dpy,DefaultScreen(dpy)));
} else {
diff -urN vnc-4.0b4-unixsrc.orig/vncviewer/CConn.h vnc-4.0b4-unixsrc/vncviewer/CConn.h
--- vnc-4.0b4-unixsrc.orig/vncviewer/CConn.h 2003-08-11 20:45:45.000000000 +0200
+++ vnc-4.0b4-unixsrc/vncviewer/CConn.h 2004-05-19 15:10:43.000000000 +0200
@@ -47,7 +47,7 @@
public:
CConn(Display* dpy_, int argc_, char** argv_, network::Socket* sock_,
- char* vncServerName);
+ char* vncServerName, int xineramascreen=-1);
~CConn();
// TXDeleteWindowCallback methods
@@ -115,6 +115,7 @@
bool encodingChange;
bool sameMachine;
bool fullScreen;
+ int xineramaScreen;
KeySym menuKeysym;
TXMenu menu;
TXEventHandler* menuEventHandler;
diff -urN vnc-4.0b4-unixsrc.orig/vncviewer/DesktopWindow.cxx
vnc-4.0b4-unixsrc/vncviewer/DesktopWindow.cxx
--- vnc-4.0b4-unixsrc.orig/vncviewer/DesktopWindow.cxx 2003-09-04 15:04:40.000000000
+0200
+++ vnc-4.0b4-unixsrc/vncviewer/DesktopWindow.cxx 2004-05-19 16:27:32.000000000
+0200
@@ -72,6 +72,7 @@
setColourMapEntriesTimer(this), viewport(0)
{
setEventHandler(this);
+ grabkeys = false;
gc = XCreateGC(dpy, win(), 0, 0);
addEventMask(ExposureMask | LeaveWindowMask | ButtonPressMask |
ButtonReleaseMask | PointerMotionMask | KeyPressMask |
@@ -379,6 +380,11 @@
XConvertSelection(dpy, xaCLIPBOARD, xaTIMESTAMP, xaSELECTION_TIME,
win(), ev->xcrossing.time);
}
+ // Grab keyboard
+ if (grabkeys) {
+ XGrabKeyboard(dpy, win(), True, GrabModeAsync, GrabModeAsync,
+ CurrentTime);
+ }
break;
case LeaveNotify:
@@ -390,6 +396,7 @@
ownSelection(xaCLIPBOARD, ev->xcrossing.time);
currentSelectionTime = ev->xcrossing.time;
}
+
// Release all keys - this should probably done on a FocusOut event, but
// LeaveNotify is near enough...
for (int i = 8; i < 256; i++) {
@@ -398,6 +405,10 @@
downKeysym[i] = 0;
}
}
+ // Release keyboard
+ if (grabkeys) {
+ XUngrabKeyboard (dpy, CurrentTime);
+ }
break;
}
}
diff -urN vnc-4.0b4-unixsrc.orig/vncviewer/DesktopWindow.h
vnc-4.0b4-unixsrc/vncviewer/DesktopWindow.h
--- vnc-4.0b4-unixsrc.orig/vncviewer/DesktopWindow.h 2003-07-31 15:57:38.000000000
+0200
+++ vnc-4.0b4-unixsrc/vncviewer/DesktopWindow.h 2004-05-19 16:36:13.000000000 +0200
@@ -52,6 +52,11 @@
// resetLocalCursor() stops the rendering of the local cursor
void resetLocalCursor();
+
+ // If set, the keyboard focus will be grabbed/released when the pointer
+ // enters/leaves the window. The window manager will take car of the
+ // keyboard focus is unset.
+ void setGrabKeyboard(bool grab) {grabkeys = grab;}
// Methods forwarded from CConn
void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);
@@ -115,6 +120,7 @@
bool gettingInitialSelectionTime;
bool newServerCutText;
char* serverCutText_;
+ bool grabkeys;
Timer setColourMapEntriesTimer;
TXViewport* viewport;
diff -urN vnc-4.0b4-unixsrc.orig/vncviewer/vncviewer.cxx
vnc-4.0b4-unixsrc/vncviewer/vncviewer.cxx
--- vnc-4.0b4-unixsrc.orig/vncviewer/vncviewer.cxx 2003-09-04 15:04:40.000000000
+0200
+++ vnc-4.0b4-unixsrc/vncviewer/vncviewer.cxx 2004-05-19 15:10:43.000000000 +0200
@@ -90,6 +90,12 @@
StringParameter geometry("geometry", "X geometry specification", 0);
StringParameter displayname("display", "The X display", 0);
+#ifdef HAVE_XINERAMA
+IntParameter xineramaScreen("XineramaScreen", "Xineramascreen used in fullscreen",
-1);
+#else
+static int xineramaScreen=-1;
+#endif
+
char aboutText[256];
char* programName;
extern char buildtime[];
@@ -236,7 +242,7 @@
TXWindow::init(dpy);
xloginIconifier.iconify(dpy);
- CConn cc(dpy, argc, argv, sock, vncServerName);
+ CConn cc(dpy, argc, argv, sock, vncServerName, xineramaScreen);
// X events are processed whenever reading from the socket would block.
_______________________________________________
VNC-List mailing list
[EMAIL PROTECTED]
To remove yourself from the list visit:
http://www.realvnc.com/mailman/listinfo/vnc-list