[rkward-cvs] rkward/rkward/rbackend Makefile.am,1.7,1.8 rembed.cpp,1.17,1.18 rinterface.cpp,1.21,1.22 rinterface.h,1.14,1.15 rkwindowcatcher.cpp,1.1,1.2 rkwindowcatcher.h,1.1,1.2

Thomas Friedrichsmeier tfry at users.sourceforge.net
Wed May 4 15:23:04 UTC 2005


Update of /cvsroot/rkward/rkward/rkward/rbackend
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24775/rkward/rbackend

Modified Files:
	Makefile.am rembed.cpp rinterface.cpp rinterface.h 
	rkwindowcatcher.cpp rkwindowcatcher.h 
Log Message:
Disabling RKWindowCatcher only using defines. Some improvments that did not help and some infos added.

Index: rkwindowcatcher.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rkwindowcatcher.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** rkwindowcatcher.cpp	4 May 2005 14:04:30 -0000	1.1
--- rkwindowcatcher.cpp	4 May 2005 15:23:02 -0000	1.2
***************
*** 18,21 ****
--- 18,23 ----
  #include "rkwindowcatcher.h"
  
+ #ifndef DISABLE_RKWINDOWCATCHER
+ 
  #include <kapplication.h>
  #include <qxembed.h>
***************
*** 27,30 ****
--- 29,33 ----
  
  // function below is a slightly adapted copy from http://lists.trolltech.com/qt-interest/1999-10/msg00224.html
+ // this could be tweaked a little more, since for instance we know we're only looking for toplevel windows
  Window Window_With_Name (Display *dp, Window top, const char *name) {
      Window *children, dummy;
***************
*** 57,60 ****
--- 60,75 ----
  }
  
+ void RKWindowCatcher::catchWindow (const QString &title_start, int corresponding_device_number) {
+ 	Window w = Window_With_Name (qt_xdisplay (), qApp->desktop ()->winId (), title_start.latin1 ());
+ 	qDebug ("Window id is: %x", w);
+ 	if (w) {
+ 		QXEmbed *capture = new QXEmbed (); // (0, 0, Qt::WDestructiveClose);
+ 		capture->setProtocol (QXEmbed::XPLAIN);
+ 		capture->embed (w);
+ 		capture->show ();
+ 	}
+ }
+ 
+ /*
  void RKWindowCatcher::start (int prev_cur_device) {
  	RK_DO (qDebug ("Window Catcher activated"), RBACKEND, DL_DEBUG);
***************
*** 80,84 ****
  	}
  	last_cur_device = new_cur_device;
! }
  
  #include "rkwindowcatcher.moc"
--- 95,101 ----
  	}
  	last_cur_device = new_cur_device;
! } */
  
  #include "rkwindowcatcher.moc"
+ 
+ #endif // DISABLE_RKWINDOWCATCHER

Index: Makefile.am
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Makefile.am	4 May 2005 14:04:29 -0000	1.7
--- Makefile.am	4 May 2005 15:23:02 -0000	1.8
***************
*** 3,9 ****
  
  noinst_LIBRARIES =  librbackend.a
! librbackend_a_SOURCES = rembed.cpp rembedinternal.cpp rinterface.cpp rthread.cpp rcommand.cpp rcommandstack.cpp 
! #rkwindowcatcher.cpp
! noinst_HEADERS = rembed.h rembedinternal.h rinterface.h rthread.h rcommand.h rcommandreceiver.h rcommandstack.h 
! #rkwindowcatcher.h
  SUBDIRS =  rpackages
--- 3,9 ----
  
  noinst_LIBRARIES =  librbackend.a
! librbackend_a_SOURCES = rembed.cpp rembedinternal.cpp rinterface.cpp rthread.cpp rcommand.cpp rcommandstack.cpp \
! rkwindowcatcher.cpp
! noinst_HEADERS = rembed.h rembedinternal.h rinterface.h rthread.h rcommand.h rcommandreceiver.h rcommandstack.h \
! rkwindowcatcher.h
  SUBDIRS =  rpackages

Index: rinterface.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rinterface.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** rinterface.cpp	4 May 2005 14:04:30 -0000	1.21
--- rinterface.cpp	4 May 2005 15:23:02 -0000	1.22
***************
*** 28,32 ****
  #include "../core/rkmodificationtracker.h"
  #include "../dialogs/rkloadlibsdialog.h"
! //#include "rkwindowcatcher.h"
  
  #include "../rkglobals.h"
--- 28,37 ----
  #include "../core/rkmodificationtracker.h"
  #include "../dialogs/rkloadlibsdialog.h"
! 
! #include "rkwindowcatcher.h"
! #ifndef DISABLE_RKWINDOWCATCHER
! // putting this here instead of the class-header so I'm able to mess with it often without long recompiles. Fix when it works!
! RKWindowCatcher *window_catcher;
! #endif // DISABLE_RKWINDOWCATCHER
  
  #include "../rkglobals.h"
***************
*** 55,60 ****
  	RK_TRACE (RBACKEND);
  	
! /*	window_catcher = new RKWindowCatcher (0);
! 	window_catcher->hide (); */
  	
  // note: we can safely mess with RKSettingsModuleR::r_home_dir, since if the setting is bad, the app will exit without anything being saved. If the
--- 60,67 ----
  	RK_TRACE (RBACKEND);
  	
! #ifndef DISABLE_RKWINDOWCATCHER
! 	window_catcher = new RKWindowCatcher (0);
! 	window_catcher->hide ();
! #endif // DISABLE_RKWINDOWCATCHER
  	
  // note: we can safely mess with RKSettingsModuleR::r_home_dir, since if the setting is bad, the app will exit without anything being saved. If the
***************
*** 257,271 ****
  			issueCommand (".rk.rkreply <- \"Too few arguments in call to require.\"", RCommand::App | RCommand::Sync, "", 0, 0, request->in_chain);
  		}
! /* does not work, yet :-(
! 	} else if (call == "startOpenX11") {
  		// TODO: error checking handling (wrong parameter count/type)
! 		if (request->call_length >= 2) {
! 			window_catcher->start (QString (request->call[1]).toInt ());
  		}
! 	} else if (call == "endOpenX11") {
! 		// TODO: error checking handling (wrong parameter count/type)
! 		if (request->call_length >= 2) {
! 			window_catcher->stop (QString (request->call[1]).toInt ());
! 		} */
  	} else {
  		issueCommand (".rk.rkreply <- \"Unrecognized call '" + call + "'. Ignoring\"", RCommand::App | RCommand::Sync, "", 0, 0, request->in_chain);
--- 264,275 ----
  			issueCommand (".rk.rkreply <- \"Too few arguments in call to require.\"", RCommand::App | RCommand::Sync, "", 0, 0, request->in_chain);
  		}
!  #ifndef DISABLE_RKWINDOWCATCHER
!  // does not work, yet :-( R crashes.
! 	} else if (call == "catchWindow") {
  		// TODO: error checking handling (wrong parameter count/type)
! 		if (request->call_length >= 3) {
! 			window_catcher->catchWindow (request->call[1], QString (request->call[2]).toInt ());
  		}
! #endif // DISABLE_RKWINDOWCATCHER
  	} else {
  		issueCommand (".rk.rkreply <- \"Unrecognized call '" + call + "'. Ignoring\"", RCommand::App | RCommand::Sync, "", 0, 0, request->in_chain);

Index: rembed.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rembed.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** rembed.cpp	4 May 2005 14:04:29 -0000	1.17
--- rembed.cpp	4 May 2005 15:23:02 -0000	1.18
***************
*** 20,24 ****
  #include <qtextstream.h>
  #include <qstring.h>
- //#include <qapplication.h>
  
  #include "../settings/rksettingsmoduler.h"
--- 20,23 ----

Index: rkwindowcatcher.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rkwindowcatcher.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** rkwindowcatcher.h	4 May 2005 14:04:30 -0000	1.1
--- rkwindowcatcher.h	4 May 2005 15:23:02 -0000	1.2
***************
*** 19,29 ****
  #define RKWINDOWCATCHER_H
  
  #include <qwidget.h>
  
  /** This class will be used to find out, when R opens a new X11-device, find out the id of that device and embed it into a QWidget.
  
! Unfortunately this does not work, yet. Right when trying to embed the window, there is a crash. Therefore this class is currently deactivated.
  To reactivate it, modify the corresponding Makefile.am, uncomment the x11-override in rpackages/rkward/R/internal.R, and uncomment the
  window_catcher/RKWindowCatcher lines in rinterface.h and rinterface.cpp. Maybe I'll add some #ifdefs instead...
  @author Thomas Friedrichsmeier
  */
--- 19,58 ----
  #define RKWINDOWCATCHER_H
  
+ #define DISABLE_RKWINDOWCATCHER
+ #ifndef DISABLE_RKWINDOWCATCHER
+ 
  #include <qwidget.h>
  
  /** This class will be used to find out, when R opens a new X11-device, find out the id of that device and embed it into a QWidget.
  
! Unfortunately this does not work, yet. Right when trying to embed the window, there is a crash (R segfaults; this also happens when trying to catch a window from another separate R process, so it really seems to be R's fault!). Therefore this class is currently deactivated.
  To reactivate it, modify the corresponding Makefile.am, uncomment the x11-override in rpackages/rkward/R/internal.R, and uncomment the
  window_catcher/RKWindowCatcher lines in rinterface.h and rinterface.cpp. Maybe I'll add some #ifdefs instead...
+ 
+ Given the problems with fetching the window Id (currently only possible by searching for the window title), it's probably a lot easier to instead create a single R call: .rk.catch.window (title="R Graphics: Device...", graph_device_number) that will directly trigger catching.
+ 
+ 
+ Here are some more notes I have taken on the subject of catching R's x11 windows. Current approach is Plan C for simplicity.
+ - Plan A:
+ 	- initialization function seems to be in_do_X11
+ 	- it might be possible to put a wrapper around this using R_setX11Routines
+ 	- this wrapper could watch the list of devices (curDevice, numDevices), see also addDevice to find out how the list is kept internally
+ 	- if a new device gets added grab its winId and capture (using QXEmbed?)!
+ - Plan B:
+ 	- it looks like there's no way to get acces to R_setX11Routines or at least the needed struct R_X11Routines. (?)
+ 	- the level above that seems to be do_X11
+ 	- maybe we can modify the mapping from .Internal (X11) to do_X11 and insert wrapper from Plan A -> R_FunTab
+ 	- 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 ())
+ 	- least preferable solution as we can not be sure we catch every use.
+ - 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
+ 	- event filter should only be active during the wrapper (Plan A-C)
+ 	- event filter should probably do some sanity checking
+ 	- this should give us the window id corresponding to the x11-call
+ 
  @author Thomas Friedrichsmeier
  */
***************
*** 35,43 ****
  	~RKWindowCatcher ();
  	
! 	void start (int prev_cur_device);
! 	void stop (int new_cur_device);
  private:
! 	int last_cur_device;
  };
  
  #endif
--- 64,74 ----
  	~RKWindowCatcher ();
  	
! /*	void start (int prev_cur_device);
! 	void stop (int new_cur_device); */
! 	void catchWindow (const QString &title_start, int corresponding_device_number);
  private:
! //	int last_cur_device;
  };
  
+ #endif //DISABLE_RKWINDOWCATCHER
  #endif

Index: rinterface.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rinterface.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** rinterface.h	4 May 2005 14:04:30 -0000	1.14
--- rinterface.h	4 May 2005 15:23:02 -0000	1.15
***************
*** 30,34 ****
  class RCommand;
  class RKwardApp;
- //class RKWindowCatcher;
  
  /** This class provides the main interface to the R-processor.
--- 30,33 ----
***************
*** 74,78 ****
  	void processREvalRequest (REvalRequest *request);
  //	void processRGetValueRequest (RGetValueRequest);	
- //	RKWindowCatcher *window_catcher;
  friend class RKwardApp;
  	RKwatch *watch;
--- 73,76 ----





More information about the rkward-tracker mailing list