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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Nov 7 16:29:30 UTC 2006


Revision: 919
          http://svn.sourceforge.net/rkward/?rev=919&view=rev
Author:   tfry
Date:     2006-11-07 08:29:19 -0800 (Tue, 07 Nov 2006)

Log Message:
-----------
override makeActiveBinding() to work despite rkward's usage of active bindings
some more thoughts on embedding R X11 windows

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/TODO
    trunk/rkward/rkward/rbackend/rkwindowcatcher.cpp
    trunk/rkward/rkward/rbackend/rkwindowcatcher.h
    trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2006-11-07 11:12:32 UTC (rev 918)
+++ trunk/rkward/ChangeLog	2006-11-07 16:29:19 UTC (rev 919)
@@ -1,3 +1,4 @@
+- properly support active bindings in globalenv ()
 - if not started in a tty, spawn a konsole. R will go into non-interactive mode otherwise
 
 --- Version 0.4.1 - Nov-05-2006

Modified: trunk/rkward/TODO
===================================================================
--- trunk/rkward/TODO	2006-11-07 11:12:32 UTC (rev 918)
+++ trunk/rkward/TODO	2006-11-07 16:29:19 UTC (rev 919)
@@ -19,12 +19,6 @@
 			- seems to happen more often with larger data frames
 			- more precisely: seems to happen after scrolling
 			- no idea, why this happens
-	- crash when there are user defined active bindings in .GlobalEnv
-		- does not happen, if symbol update is prevented:
-			- x <- 1
-			- rm (x); makeActiveBinding ("x", something, .GlobalEnv);
-		- why?
-	- deal with user defined active bindings correctly (i.e. copy them "actively" in .rk.watch.symbol, or override makeActiveBinding () (and bindingIsActive ()) to do the right thing)
 
 Compilation / technical
 	- Incorporate FreeBSD patches http://www.freshports.org/math/rkward/files.php?message_id=200609172111.k8HLBiob081349@repoman.freebsd.org
@@ -85,6 +79,7 @@
 		- another nifty feature would be - if F8 would work also in the console/log.
 
 Internal stuff:
+	- should we override bindingIsActive()?
 	RKVariable:
 		- Need to add a conversion script. See .rk.get.meta (). Both should be changed at the same time.
 			- Or was it already broken, before?

Modified: trunk/rkward/rkward/rbackend/rkwindowcatcher.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkwindowcatcher.cpp	2006-11-07 11:12:32 UTC (rev 918)
+++ trunk/rkward/rkward/rbackend/rkwindowcatcher.cpp	2006-11-07 16:29:19 UTC (rev 919)
@@ -66,11 +66,11 @@
 		QXEmbed *capture = new QXEmbed (); // (0, 0, Qt::WDestructiveClose);
 		capture->setProtocol (QXEmbed::XPLAIN);
 // (trying to) work around buggy R X11 event handling (see http://www.ens.gu.edu.au/robertk/R/devel/01a/0077.html)
-		extern Display *Rf_getX11Display (); // now, how to link this?
+/*		extern Display *Rf_getX11Display (); // now, how to link this?
 
-		qDebug ("qt disp: %x r disp: %x", qt_xdisplay (), Rf_getX11Display ());
+		qDebug ("qt disp: %x r disp: %x", qt_xdisplay (), Rf_getX11Display ()); */
 		
-		Atom *old_prots;
+/*		Atom *old_prots;
 		int num_old_prots;
 		if (!XGetWMProtocols (Rf_getX11Display (), w, &old_prots, &num_old_prots)) qDebug ("fail 1");
 		if (!XSetWMProtocols (Rf_getX11Display (), w, 0, 0)) qDebug ("fail2");
@@ -81,6 +81,8 @@
 			qDebug ("event for window: %x", dummy.xany.window);
 		}
 		XSetWMProtocols (Rf_getX11Display (), w, old_prots, num_old_prots);
+		capture->show (); */
+		capture->embed (w);
 		capture->show ();
 	}
 }

Modified: trunk/rkward/rkward/rbackend/rkwindowcatcher.h
===================================================================
--- trunk/rkward/rkward/rbackend/rkwindowcatcher.h	2006-11-07 11:12:32 UTC (rev 918)
+++ trunk/rkward/rkward/rbackend/rkwindowcatcher.h	2006-11-07 16:29:19 UTC (rev 919)
@@ -45,8 +45,11 @@
 	- proceed like in Plan A
 	- less preferable as C-plugins might be able to call do_X11 directly (can they?)
 - Plan C:
-	- modify at R level (override x11 ())
+	- modify at R level (override X11 ())
+		- notify app right before device is created
+		- notify app right after device is created
 	- least preferable solution as we can not be sure we catch every use.
+		- but definitely most. This is dispatched via CurrentDevice ()->options("device"), and then evalued in R_GlobalEnv
 - remaining problem: how to get the window id given the device id?
 	- http://tronche.com/gui/x/xlib/events/window-state-change/create.html#XCreateWindowEvent
 	- we may catch this using KApplication::installlX11EventFilter

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R	2006-11-07 11:12:32 UTC (rev 918)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R	2006-11-07 16:29:19 UTC (rev 919)
@@ -147,9 +147,7 @@
 #"x11" <- function (display = "", width = 7, height = 7, pointsize = 12, gamma = 1, colortype = getOption("X11colortype"), maxcubesize = 256, bg #= "transparent", canvas = "white", fonts = getOption("X11fonts")) {
 #	.rk.do.call ("startOpenX11", as.character (dev.cur ()));
 #
-#	if (display == "" && .Platform$GUI == "AQUA" && Sys.getenv("DISPLAY") == "")
-#		Sys.putenv (DISPLAY = ":0")
-#	.Internal(X11(display, width, height, pointsize, gamma, colortype, maxcubesize, bg, canvas, fonts, NA))
+#	base::X11()
 #
 #	.rk.do.call ("endOpenX11", as.character (dev.cur ()));
 #}
@@ -157,6 +155,17 @@
 # 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 ()
 
+# override makeActiveBinding: If active bindings are created in globalenv (), watch them properly
+"makeActiveBinding" <- function (sym, fun, env, ...) {
+	if (identical (env, globalenv ())) {
+		base::makeActiveBinding (sym, fun, .rk.watched.symbols)
+		f <- .rk.make.watch.f (sym)
+		base::makeActiveBinding (sym, f, globalenv ())
+	} else {
+		base::makeActiveBinding (sym, fun, env, ...)
+	}
+}
+
 ".rk.make.watch.f" <- function (k) {
 	function (value) {
 		if (!missing (value)) {
@@ -174,7 +183,7 @@
 	assign (k, get (k, envir=globalenv ()), envir=.rk.watched.symbols)
 	rm (list=k, envir=globalenv ())
 
-	makeActiveBinding (k, f, globalenv ())
+	base::makeActiveBinding (k, f, globalenv ())
 
 	invisible (TRUE)
 }


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