[rkward-cvs] SF.net SVN: rkward:[2389] trunk/rkward/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Nov 21 15:47:16 UTC 2008


Revision: 2389
          http://rkward.svn.sourceforge.net/rkward/?rev=2389&view=rev
Author:   tfry
Date:     2008-11-21 15:47:16 +0000 (Fri, 21 Nov 2008)

Log Message:
-----------
Fix device window capturing to work with R 2.8.0 and Qt 4.4.3

Modified Paths:
--------------
    trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
    trunk/rkward/rkward/rbackend/rthread.cpp
    trunk/rkward/rkward/rkwardapplication.cpp
    trunk/rkward/rkward/settings/rksettingsmoduler.cpp
    trunk/rkward/rkward/windows/rkwindowcatcher.cpp
    trunk/rkward/rkward/windows/rkwindowcatcher.h

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R	2008-11-17 23:52:08 UTC (rev 2388)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R	2008-11-21 15:47:16 UTC (rev 2389)
@@ -141,18 +141,31 @@
 #}
 
 # overriding x11 to get informed, when a new x11 window is opened
-"x11" <- function (...) {
+"rk.screen.device" <- function (...) {
 	.rk.do.call ("startOpenX11", as.character (dev.cur ()));
 
-	x <- grDevices::X11 (...)
+	if (!exists (".rk.default.device")) {
+		device <- grDevices::x11
+	} else {
+		device <- .rk.default.device
+		if (is.character (.rk.default.device)) {
+			device <- get (.rk.default.device)
+		}
+	}
+	x <- device (...)
 
 	.rk.do.call ("endOpenX11", as.character (dev.cur ()));
 
 	invisible (x)
 }
 
+"x11" <- rk.screen.device
+
 "X11" <- x11
 
+# set from rkward the application:
+# options(device="rk.screen.device")
+
 # these functions can be used to track assignments to R objects. The main interfaces are .rk.watch.symbol (k) and .rk.unwatch.symbol (k). This works by copying the symbol to a backup environment, removing it, and replacing it by an active binding to the backup location
 ".rk.watched.symbols" <- new.env ()
 

Modified: trunk/rkward/rkward/rbackend/rthread.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.cpp	2008-11-17 23:52:08 UTC (rev 2388)
+++ trunk/rkward/rkward/rbackend/rthread.cpp	2008-11-21 15:47:16 UTC (rev 2389)
@@ -531,6 +531,8 @@
 	if (error) status |= SinkFail;
 	runCommandInternal ("options (htmlhelp=TRUE); options (browser=\"qdbus " + QDBusConnection::sessionBus ().baseService () + " /MainApplication net.sf.rkward.openHTMLHelp\")", &error);
 	if (error) status |= OtherFail;
+/*	runCommandInternal (".rk.default.device <- \"x11\"\n", &error);
+	if (error) status |= OtherFail; */
 	// TODO: error-handling?
 
 	MUTEX_LOCK;

Modified: trunk/rkward/rkward/rkwardapplication.cpp
===================================================================
--- trunk/rkward/rkward/rkwardapplication.cpp	2008-11-17 23:52:08 UTC (rev 2388)
+++ trunk/rkward/rkward/rkwardapplication.cpp	2008-11-21 15:47:16 UTC (rev 2389)
@@ -100,8 +100,9 @@
 		if (e->type == CreateNotify) {
 			if (e->xcreatewindow.parent == QX11Info::appRootWindow ()) {
 				KWindowInfo info = KWindowInfo (e->xcreatewindow.window, NET::WMName | NET::WMWindowType);
-				if ((info.windowType (0xFFFF) != 0) && (!info.name ().isEmpty ())) {
-					RK_ASSERT (!created_window);
+				// at this point, we used to check, whether this window has some name or another. This heuristic allowed to sieve out helper windows of the window manager. However, since R 2.8.0, sometimes the window is mapped, before it has been give a name.
+				// Now we rely on the fact (we hope it *is* a fact), that the device window is always the first one created.
+				if ((info.windowType (0xFFFF) != 0) && (!created_window)) {
 					created_window = e->xcreatewindow.window;
 					return true;
 				}

Modified: trunk/rkward/rkward/settings/rksettingsmoduler.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmoduler.cpp	2008-11-17 23:52:08 UTC (rev 2388)
+++ trunk/rkward/rkward/settings/rksettingsmoduler.cpp	2008-11-21 15:47:16 UTC (rev 2389)
@@ -221,6 +221,9 @@
 	list.append ("options (checkbounds=" + tf + ")\n");
 	list.append ("options (printcmd=\"" + options_printcmd + "\")\n");
 
+#warning TODO make configurable
+	list.append ("options (device=rk.screen.device)\n");
+
 	return list;
 }
 

Modified: trunk/rkward/rkward/windows/rkwindowcatcher.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.cpp	2008-11-17 23:52:08 UTC (rev 2388)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.cpp	2008-11-21 15:47:16 UTC (rev 2389)
@@ -68,6 +68,7 @@
 #include <QScrollArea>
 #include <qlabel.h>
 #include <QX11EmbedContainer>
+#include <QTimer>
 
 #include <ktoggleaction.h>
 #include <kdialog.h>
@@ -106,18 +107,27 @@
 	dynamic_size = true;
 	dynamic_size_action->setChecked (true);
 
-	capture = new QX11EmbedContainer (xembed_container);
-	connect (capture, SIGNAL (clientClosed ()), this, SLOT (deleteLater ()));
-
-	KWindowInfo wininfo = KWindowSystem::windowInfo (window_to_embed, NET::WMName | NET::WMFrameExtents);
+	KWindowInfo wininfo = KWindowSystem::windowInfo (embedded, NET::WMName | NET::WMFrameExtents);
 	RK_ASSERT (wininfo.valid ());
 	setGeometry (wininfo.frameGeometry ());
 	setCaption (wininfo.name ());
-	capture->embedClient (window_to_embed);
 
+	// somehow in Qt 4.4.3, when the RKCaughtWindow is reparented the first time, the QX11EmbedContainer may kill its client. Hence we delay the actual embedding until after the window was shown.
+	// In some previous version of Qt, this was not an issue, but I did not track the versions.
+	QTimer::singleShot (0, this, SLOT (doEmbed()));
+
 	RKWardApplication::getApp ()->registerNameWatcher (window_to_embed, this);
 }
 
+void RKCaughtX11Window::doEmbed () {
+	RK_TRACE (MISC);
+
+	capture = new QX11EmbedContainer (xembed_container);
+	capture->embedClient (embedded);
+
+	connect (capture, SIGNAL (clientClosed ()), this, SLOT (deleteLater ()));
+}
+
 RKCaughtX11Window::~RKCaughtX11Window () {
 	RK_TRACE (MISC);
 

Modified: trunk/rkward/rkward/windows/rkwindowcatcher.h
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.h	2008-11-17 23:52:08 UTC (rev 2388)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.h	2008-11-21 15:47:16 UTC (rev 2389)
@@ -119,6 +119,9 @@
 	void printDevice ();
 	void copyDeviceToRObject ();
 	void duplicateDevice ();
+
+private slots:
+	void doEmbed ();
 private:
 	friend class RKCaughtX11WindowPart;	// needs access to the actions
 	int device_number;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list