[rkward-cvs] rkward/rkward/rbackend rkwindowcatcher.cpp,NONE,1.1 rkwindowcatcher.h,NONE,1.1 Makefile.am,1.6,1.7 rembed.cpp,1.16,1.17 rembedinternal.cpp,1.14,1.15 rinterface.cpp,1.20,1.21 rinterface.h,1.13,1.14 rthread.h,1.12,1.13
Thomas Friedrichsmeier
tfry at users.sourceforge.net
Wed May 4 14:04:32 UTC 2005
Update of /cvsroot/rkward/rkward/rkward/rbackend
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2782/rkward/rbackend
Modified Files:
Makefile.am rembed.cpp rembedinternal.cpp rinterface.cpp
rinterface.h rthread.h
Added Files:
rkwindowcatcher.cpp rkwindowcatcher.h
Log Message:
Adding some dead/deactivated code I hoped would work to embed R X11 windows. Unfortunately, if activated, it crashes when trying to embed such a window.
--- NEW FILE: rkwindowcatcher.cpp ---
/***************************************************************************
rwindowcatcher.cpp - description
-------------------
begin : Wed May 4 2005
copyright : (C) 2005 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "rkwindowcatcher.h"
#include <kapplication.h>
#include <qxembed.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include "../debug.h"
// function below is a slightly adapted copy from http://lists.trolltech.com/qt-interest/1999-10/msg00224.html
Window Window_With_Name (Display *dp, Window top, const char *name) {
Window *children, dummy;
unsigned int nchildren;
int i;
Window w=0;
char *window_name;
if (XFetchName(dp, top, &window_name)) {
if (QString (window_name).startsWith (name)) return(top);
}
if (!XQueryTree(dp, top, &dummy, &dummy, &children, &nchildren))
return(0);
for (i=0; i<nchildren; i++) {
w = Window_With_Name(dp, children[i], name);
if (w)
break;
}
if (children) XFree ((char *)children);
return(w);
}
RKWindowCatcher::RKWindowCatcher (QWidget *parent) : QWidget (parent) {
}
RKWindowCatcher::~RKWindowCatcher () {
}
void RKWindowCatcher::start (int prev_cur_device) {
RK_DO (qDebug ("Window Catcher activated"), RBACKEND, DL_DEBUG);
last_cur_device = prev_cur_device;
}
void RKWindowCatcher::stop (int new_cur_device) {
RK_DO (qDebug ("Window Catcher deactivated"), RBACKEND, DL_DEBUG);
if (new_cur_device != last_cur_device) {
QString dummy = "R Graphics: Device ";
//dummy.append (QString::number (new_cur_device));
//dummy.append (" ");
Window w = Window_With_Name (qt_xdisplay (), qApp->desktop ()->winId (), dummy.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 ();
}
}
last_cur_device = new_cur_device;
}
#include "rkwindowcatcher.moc"
Index: Makefile.am
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/Makefile.am,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Makefile.am 7 Sep 2004 13:45:24 -0000 1.6
--- Makefile.am 4 May 2005 14:04:29 -0000 1.7
***************
*** 3,7 ****
noinst_LIBRARIES = librbackend.a
! librbackend_a_SOURCES = rembed.cpp rembedinternal.cpp rinterface.cpp rthread.cpp rcommand.cpp rcommandstack.cpp
! noinst_HEADERS = rembed.h rembedinternal.h rinterface.h rthread.h rcommand.h rcommandreceiver.h rcommandstack.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.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** rinterface.cpp 28 Apr 2005 20:05:09 -0000 1.20
--- rinterface.cpp 4 May 2005 14:04:30 -0000 1.21
***************
*** 28,31 ****
--- 28,32 ----
#include "../core/rkmodificationtracker.h"
#include "../dialogs/rkloadlibsdialog.h"
+ //#include "rkwindowcatcher.h"
#include "../rkglobals.h"
***************
*** 53,59 ****
RInterface::RInterface () {
RK_TRACE (RBACKEND);
// 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
// setting is good, everything is fine anyway.
-
char *env_r_home = getenv ("R_HOME");
if (!env_r_home) {
--- 54,63 ----
RInterface::RInterface () {
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
// setting is good, everything is fine anyway.
char *env_r_home = getenv ("R_HOME");
if (!env_r_home) {
***************
*** 253,256 ****
--- 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);
Index: rembedinternal.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rembedinternal.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** rembedinternal.cpp 3 May 2005 20:56:14 -0000 1.14
--- rembedinternal.cpp 4 May 2005 14:04:30 -0000 1.15
***************
*** 48,52 ****
}
! static int testcounter = 0;
void REmbedInternal::processX11Events () {
--- 48,52 ----
}
! static int timeout_counter = 0;
void REmbedInternal::processX11Events () {
***************
*** 65,74 ****
R_PolledEvents ();
! /* Maybe we also need to also call R_timeout_handler once in a while? Needed for tkStartGUI () to do something. Obviously this is
! extremely crude code! */
! if (++testcounter < 1000) {
extern void (* R_timeout_handler) ();
if (R_timeout_handler) R_timeout_handler ();
! testcounter = 0;
}
}
--- 65,74 ----
R_PolledEvents ();
! /* Maybe we also need to also call R_timeout_handler once in a while? Obviously this is extremely crude code!
! TODO: verify we really need this. */
! if (++timeout_counter > 100) {
extern void (* R_timeout_handler) ();
if (R_timeout_handler) R_timeout_handler ();
! timeout_counter = 0;
}
}
Index: rembed.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rembed.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** rembed.cpp 28 Apr 2005 20:05:09 -0000 1.16
--- rembed.cpp 4 May 2005 14:04:29 -0000 1.17
***************
*** 20,23 ****
--- 20,24 ----
#include <qtextstream.h>
#include <qstring.h>
+ //#include <qapplication.h>
#include "../settings/rksettingsmoduler.h"
--- NEW FILE: rkwindowcatcher.h ---
/***************************************************************************
rwindowcatcher.h - description
-------------------
begin : Wed May 4 2005
copyright : (C) 2005 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKWINDOWCATCHER_H
#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
*/
class RKWindowCatcher : public QWidget {
Q_OBJECT
public:
RKWindowCatcher (QWidget *parent);
~RKWindowCatcher ();
void start (int prev_cur_device);
void stop (int new_cur_device);
private:
int last_cur_device;
};
#endif
Index: rinterface.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rinterface.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** rinterface.h 28 Apr 2005 23:41:08 -0000 1.13
--- rinterface.h 4 May 2005 14:04:30 -0000 1.14
***************
*** 30,33 ****
--- 30,34 ----
class RCommand;
class RKwardApp;
+ //class RKWindowCatcher;
/** This class provides the main interface to the R-processor.
***************
*** 72,76 ****
void processREvalRequest (REvalRequest *request);
! // void processRGetValueRequest (RGetValueRequest);
friend class RKwardApp;
RKwatch *watch;
--- 73,78 ----
void processREvalRequest (REvalRequest *request);
! // void processRGetValueRequest (RGetValueRequest);
! // RKWindowCatcher *window_catcher;
friend class RKwardApp;
RKwatch *watch;
Index: rthread.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rthread.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** rthread.h 28 Apr 2005 23:41:08 -0000 1.12
--- rthread.h 4 May 2005 14:04:30 -0000 1.13
***************
*** 32,36 ****
#define RSTARTED_EVENT 11001
#define R_EVAL_REQUEST_EVENT 12001
! // don't use the number following RSTARTUP_ERROR_EVENT, because an error code will be added!
#define RSTARTUP_ERROR_EVENT 13000
--- 32,36 ----
#define RSTARTED_EVENT 11001
#define R_EVAL_REQUEST_EVENT 12001
! // don't use the numbers following RSTARTUP_ERROR_EVENT, because an error code will be added!
#define RSTARTUP_ERROR_EVENT 13000
More information about the rkward-tracker
mailing list