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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Jun 4 19:58:13 UTC 2009


Revision: 2517
          http://rkward.svn.sourceforge.net/rkward/?rev=2517&view=rev
Author:   tfry
Date:     2009-06-04 19:58:09 +0000 (Thu, 04 Jun 2009)

Log Message:
-----------
Next step on windows porting. This fixes some compilation quirks and some progress on graphics device capturing.

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/CMakeLists.txt
    trunk/rkward/rkward/qwinhost/CMakeLists.txt
    trunk/rkward/rkward/rbackend/FindR.cmake
    trunk/rkward/rkward/rbackend/rembedinternal.cpp
    trunk/rkward/rkward/rbackend/rthread.cpp
    trunk/rkward/rkward/rkwardapplication.cpp
    trunk/rkward/rkward/windows/rkwindowcatcher.cpp

Added Paths:
-----------
    trunk/rkward/rkward/rkward.bat.template

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2009-06-03 20:13:49 UTC (rev 2516)
+++ trunk/rkward/ChangeLog	2009-06-04 19:58:09 UTC (rev 2517)
@@ -1,3 +1,4 @@
+TODO: add notice on differing licences/copyrights in subdirs
 - Remove support for R 2.6.x and earlier		TODO: clean up more (options ("browser"), internal.R, RData?), adjust debian control
 - Add basic checks for a correct installation of the RKWard resource files
 - Remove "What to expect" dialog at startup

Modified: trunk/rkward/rkward/CMakeLists.txt
===================================================================
--- trunk/rkward/rkward/CMakeLists.txt	2009-06-03 20:13:49 UTC (rev 2516)
+++ trunk/rkward/rkward/CMakeLists.txt	2009-06-04 19:58:09 UTC (rev 2517)
@@ -35,18 +35,24 @@
 LINK_DIRECTORIES(${R_SHAREDLIBDIR})
 
 KDE4_ADD_EXECUTABLE(rkward.bin ${RKWard_Sources})
+
 # wrapper script
 GET_DIRECTORY_PROPERTY(R_EXECUTABLE DIRECTORY rbackend DEFINITION R_EXECUTABLE)
+IF(WIN32)
+	SET(RKWARD_WRAPPER_TEMPLATE rkward.bat.template)
+	SET(RKWARD_WRAPPER_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/rkward.bat)
+ELSE(WIN32)
+	SET(RKWARD_WRAPPER_TEMPLATE rkward.sh.template)
+	SET(RKWARD_WRAPPER_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/rkward)
+ENDIF(WIN32)
 CONFIGURE_FILE(
-	rkward.sh.template
-	${CMAKE_CURRENT_BINARY_DIR}/rkward
+	${RKWARD_WRAPPER_TEMPLATE}
+	${RKWARD_WRAPPER_SCRIPT}
 	@ONLY)
-ADD_DEPENDENCIES(rkward.bin ${CMAKE_CURRENT_BINARY_DIR}/rkward)
+ADD_DEPENDENCIES(rkward.bin ${RKWARD_WRAPPER_SCRIPT})
 
 TARGET_LINK_LIBRARIES(rkward.bin ${KDE4_KDECORE_LIBS} windows ${RKWARD_ADDLIBS} agents dialogs plugin settings dataeditor core scriptbackends rbackend misc ktexteditor ${KDE4_KHTML_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KDEUI_LIBS})
 
-# NOTE: KDE4_KFILE_LIBS still links against Qt3Support
-
 ########### install files ###############
 
 INSTALL(DIRECTORY plugins/ pages DESTINATION ${DATA_INSTALL_DIR}/rkward
@@ -54,7 +60,7 @@
 
 INSTALL(FILES   resource.ver rkwardui.rc rkconsolepart.rc DESTINATION ${DATA_INSTALL_DIR}/rkward )
 INSTALL(TARGETS rkward.bin DESTINATION ${BIN_INSTALL_DIR})
-INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/rkward DESTINATION ${BIN_INSTALL_DIR})
+INSTALL(PROGRAMS ${RKWARD_WRAPPER_SCRIPT} DESTINATION ${BIN_INSTALL_DIR})
 
 INSTALL(FILES rkward.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
 

Modified: trunk/rkward/rkward/qwinhost/CMakeLists.txt
===================================================================
--- trunk/rkward/rkward/qwinhost/CMakeLists.txt	2009-06-03 20:13:49 UTC (rev 2516)
+++ trunk/rkward/rkward/qwinhost/CMakeLists.txt	2009-06-04 19:58:09 UTC (rev 2517)
@@ -1,12 +1,14 @@
 IF(WIN32)
 	INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${KDE4_INCLUDE_DIR} ${QT_INCLUDES})
 
+	# QT4-automoc does not work, as qwinhost.cpp does not have the #include "qwhinhost.moc"-line.
+	# We don't want to add it to keep changes small, and use manual moccing, here, instead
+	QT4_WRAP_CPP(MANUAL_MOC_CXX qwinhost.h)
 	SET(qwinhost_STAT_SRCS
 		qwinhost.cpp
+		${MANUAL_MOC_CXX}
 	)
 
-	QT4_AUTOMOC(${qwinhost_STAT_SRCS})
-
 	ADD_LIBRARY(qwinhost STATIC ${qwinhost_STAT_SRCS})
 ELSE(WIN32)
 	MESSAGE(STATUS "Only needed on windows")

Modified: trunk/rkward/rkward/rbackend/FindR.cmake
===================================================================
--- trunk/rkward/rkward/rbackend/FindR.cmake	2009-06-03 20:13:49 UTC (rev 2516)
+++ trunk/rkward/rkward/rbackend/FindR.cmake	2009-06-04 19:58:09 UTC (rev 2517)
@@ -89,7 +89,13 @@
 	MESSAGE(STATUS "No, it does not exist in ${R_SHAREDLIBDIR}")
 ELSE(NOT LIBR_LAPACK)
 	MESSAGE(STATUS "Yes, ${LIBR_LAPACK} exists")
-	SET(R_USED_LIBS ${R_USED_LIBS} Rlapack gfortran)
+	SET(R_USED_LIBS ${R_USED_LIBS} Rlapack)
+	IF(NOT WIN32)
+		# needed when linking to Rlapack on linux for some unknown reason.
+		# apparently not needed on windows (let's see, when it comes back to bite us, though)
+		# and compiling on windows is hard enough even without requiring libgfortran, too.
+		SET(R_USED_LIBS ${R_USED_LIBS} gfortran)
+	ENDIF(NOT WIN32)
 ENDIF(NOT LIBR_LAPACK)
 
 # for at least some versions of R, we seem to have to link against -lRlapack. Else loading some

Modified: trunk/rkward/rkward/rbackend/rembedinternal.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rembedinternal.cpp	2009-06-03 20:13:49 UTC (rev 2516)
+++ trunk/rkward/rkward/rbackend/rembedinternal.cpp	2009-06-04 19:58:09 UTC (rev 2517)
@@ -66,14 +66,25 @@
 #define IS_LATIN1(x) (Rf_getCharCE(x) == CE_LATIN1)
 
 #ifdef Q_WS_WIN
+	// needed for R includes
 #	define Win32
+#endif
+
+#include "Rdefines.h"
+#include "R_ext/Rdynload.h"
+#include "R_ext/eventloop.h"
+#include "R_ext/Callbacks.h"
+#include "R.h"
+#include "Rinternals.h"
+#include "R_ext/Parse.h"
+#include "Rembedded.h"
+
+#ifdef Q_WS_WIN
 #	include "R_ext/RStartup.h"
 #	include "R_ext/Utils.h"
 
-	extern int R_interrupts_pending;
-#	warning Or is it UserBreak?
 	void RK_scheduleIntr () {
-		R_interrupts_pending = 1;
+		UserBreak = 1;
 	}
 
 	void RK_doIntr () {
@@ -86,22 +97,16 @@
 #	define RK_doIntr Rf_onintr
 #	include "Rinterface.h"
 #endif
-#include "Rdefines.h"
-#include "R_ext/Rdynload.h"
-#include "R_ext/eventloop.h"
-#include "R_ext/Callbacks.h"
-#include "R.h"
-#include "Rinternals.h"
-#include "R_ext/Parse.h"
-#include "Rembedded.h"
 
 // some functions we need that are not declared
 extern void Rf_PrintWarnings (void);
 extern int Rf_initialize_R(int ac, char **av);	// in embedded.h in R 2.9.0. TODO: check presence in R 2.7.0
 extern void setup_Rmainloop(void);	// in embedded.h in R 2.9.0. TODO: check presence in R 2.7.0
+#ifndef Q_WS_WIN
 extern uintptr_t R_CStackLimit;	// inRinterface.h in R 2.9.0. TODO: check presence in R 2.7.0
 extern uintptr_t R_CStackStart;	// inRinterface.h in R 2.9.0. TODO: check presence in R 2.7.0
 extern Rboolean R_Interactive;	// inRinterface.h in R 2.9.0. TODO: check presence in R 2.7.0
+#endif
 SEXP R_LastvalueSymbol;
 #include "R_ext/eventloop.h"
 }
@@ -733,6 +738,8 @@
 	r_running = true;
 	Rf_initialize_R (argc, argv);
 
+#ifndef Q_WS_WIN
+	// in R on windows the stack limits detection seems to work out of the box for threads
 	if (stack_check) {
 		char dummy;
 		size_t stacksize;
@@ -744,6 +751,7 @@
 		R_CStackStart = (uintptr_t) -1;
 		R_CStackLimit = (uintptr_t) -1;
 	}
+#endif
 
 #ifdef Q_WS_WIN
 	R_set_command_line_arguments(argc, argv);
@@ -752,6 +760,8 @@
 
 	setup_Rmainloop ();
 
+#ifndef Q_WS_WIN
+	// in R on windows the stack limits detection seems to work out of the box for threads
 	if (stack_check) {
 		// safety check: If we are beyond the stack boundaries already, we better disable stack checking
 		// this has to come *after* the first setup_Rmainloop ()!
@@ -764,8 +774,12 @@
 			setup_Rmainloop ();
 		}
 	}
+#endif
 
+#ifndef Q_WS_WIN
+	// on windows, set in connectCallbacks() for technical reasons
 	R_Interactive = (Rboolean) TRUE;
+#endif
 
 	RKGlobals::na_double = NA_REAL;
 	R_ReplDLLinit ();

Modified: trunk/rkward/rkward/rbackend/rthread.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.cpp	2009-06-03 20:13:49 UTC (rev 2516)
+++ trunk/rkward/rkward/rbackend/rthread.cpp	2009-06-04 19:58:09 UTC (rev 2517)
@@ -52,6 +52,11 @@
 	current_output = 0;
 	out_buf_len = 0;
 	output_paused = false;
+
+#ifdef Q_WS_WIN
+	// we hope that on other platforms the default is reasonable
+	setStackSize (0xa00000);	// 10MB as recommended by r_exts-manual
+#endif
 }
 
 RThread::~RThread() {

Added: trunk/rkward/rkward/rkward.bat.template
===================================================================
--- trunk/rkward/rkward/rkward.bat.template	                        (rev 0)
+++ trunk/rkward/rkward/rkward.bat.template	2009-06-04 19:58:09 UTC (rev 2517)
@@ -0,0 +1,16 @@
+ at ECHO off
+REM Wrapper script to start RKWard.
+REM It the *first* parameter is "--debugger", run through the specified debugger
+
+SET R_BINARY=@R_EXECUTABLE@
+SET RKWARD.BIN=%~dp0\rkward.bin.exe
+SET DEBUGGER=
+
+IF NOT "%1" == "--debugger" GOTO run
+REM else:
+SHIFT
+SET DEBUGGER=%1
+SHIFT
+
+:run
+CALL %R_BINARY% CMD %DEBUGGER% %RKWARD.BIN% %1 %2 %3 %4 %5 %6 %7 %8 %9

Modified: trunk/rkward/rkward/rkwardapplication.cpp
===================================================================
--- trunk/rkward/rkward/rkwardapplication.cpp	2009-06-03 20:13:49 UTC (rev 2516)
+++ trunk/rkward/rkward/rkwardapplication.cpp	2009-06-04 19:58:09 UTC (rev 2517)
@@ -31,10 +31,48 @@
 #	include <netwm_def.h>
 //static
 Atom wm_name_property;
-#endif
+#endif	//Q_WS_WIN
 
 #include "debug.h"
 
+#warning TODO: We could really use the detection logic from windows for x11, too. It seems much easier.
+#ifdef Q_WS_WIN
+#include <stdio.h>
+namespace RKWardApplicationPrivate {
+	QList<WId> toplevel_windows;
+
+	BOOL CALLBACK EnumWindowsCallback (HWND hwnd, LPARAM) {
+		toplevel_windows.append (hwnd);
+		return true;
+	}
+
+	void updateToplevelWindowList () {
+		RK_TRACE (APP);
+
+		toplevel_windows.clear ();
+		EnumWindows (EnumWindowsCallback, 0);
+	};
+
+// TODO: this is a test, only
+	BOOL CALLBACK ChildWindowCallback (HWND hwnd, LPARAM) {
+		WINDOWINFO info;
+		info.cbSize = sizeof (WINDOWINFO);
+		GetWindowInfo (hwnd, &info);
+qDebug ("%p: rect: %d, %d, %d, %d, client: %d, %d, %d, %d, style: %d, exstyle: %d, status: %d, borders: %d %d", hwnd,
+		info.rcWindow.left, info.rcWindow.top, info.rcWindow.right, info.rcWindow.bottom,
+		info.rcClient.left, info.rcClient.top, info.rcClient.right, info.rcClient.bottom,
+		info.dwStyle, info.dwExStyle, info.dwWindowStatus, info.cxWindowBorders, info.cyWindowBorders);
+
+		return true;
+	}
+
+	void showWindowChildren (HWND hwnd) {
+		ChildWindowCallback (hwnd, 0);
+		EnumChildWindows (hwnd, ChildWindowCallback, 0);
+	}
+}
+#endif	//Q_WS_WIN
+
 //static
 RKWardApplication *RKWardApplication::rkapp = 0;
 
@@ -47,7 +85,7 @@
 
 #ifndef Q_WS_WIN
 	wm_name_property = XInternAtom (QX11Info::display (), "WM_NAME", true);
-#endif
+#endif	//nQ_WS_WIN
 }
 
 RKWardApplication::~RKWardApplication () {
@@ -67,10 +105,12 @@
 	created_window = 0;
 	detect_x11_creations = true;
 
-#ifndef Q_WS_WIN
+#ifdef Q_WS_WIN
+	RKWardApplicationPrivate::updateToplevelWindowList ();
+#else	//Q_WS_WIN
 	XSelectInput (QX11Info::display (), QX11Info::appRootWindow (), SubstructureNotifyMask);
 	syncX ();	// this is to make sure we don't miss out on the window creation (if it happens very early). Testing shows, we really need this.
-#endif
+#endif	//Q_WS_WIN
 }
 
 WId RKWardApplication::endWindowCreationDetection () {
@@ -78,12 +118,32 @@
 	RK_ASSERT (detect_x11_creations);
 
 #ifdef Q_WS_WIN
-	created_window = FindWindow (NULL, "RKTest (ACTIVE)");
-qDebug ("found window %p", created_window);
+	QList<WId> old_windows = RKWardApplicationPrivate::toplevel_windows;
+	RKWardApplicationPrivate::updateToplevelWindowList ();
+	QList<WId> candidate_windows = RKWardApplicationPrivate::toplevel_windows;
+
 	detect_x11_creations = false;
-	return created_window;
-#	warning TODO: correct this mockup (EnumWindows, etc.)
-#else
+
+	// remove all windows that existed before the call to startWindowCreationDetection
+	for (int i = 0; i < old_windows.size (); ++i) {
+		candidate_windows.removeAll (old_windows[i]);
+	}
+	// ideally we have a single candidate remaining, now
+
+	// we could do some more checking, e.g. based on whether the window belongs to our
+	// own process, and whether it appears to be of a sane size, but for now, we keep
+	// things simple.
+
+	if (candidate_windows.size ()) {
+		RK_ASSERT (candidate_windows.size () < 2);
+		for (int i = 0; i < candidate_windows.size (); ++i) {
+			qDebug ("candidate: %d", i);
+			RKWardApplicationPrivate::showWindowChildren (candidate_windows[i]);
+		}
+		return candidate_windows[0];
+	}	// else
+	return 0;
+#else	//Q_WS_WIN
 	if (!created_window) {
 		// we did not see the window, yet? Maybe the event simply hasn't been processed, yet.
 		syncX ();
@@ -93,7 +153,7 @@
 	detect_x11_creations = false;
 	XSelectInput (QX11Info::display (), QX11Info::appRootWindow (), NoEventMask);
 	return created_window;
-#endif
+#endif	//Q_WS_WIN
 }
 
 void RKWardApplication::registerNameWatcher (WId watched, RKMDIWindow *watcher) {
@@ -102,7 +162,7 @@
 
 #ifndef Q_WS_WIN
 	XSelectInput (QX11Info::display (), watched, PropertyChangeMask);
-#endif
+#endif	//nQ_WS_WIN
 	name_watchers_list.insert (watched, watcher);
 }
 
@@ -112,7 +172,7 @@
 
 #ifndef Q_WS_WIN
 	XSelectInput (QX11Info::display (), watched, NoEventMask);
-#endif
+#endif	//nQ_WS_WIN
 	name_watchers_list.remove (watched);
 }
 
@@ -146,4 +206,4 @@
 
 	return KApplication::x11EventFilter (e);
 }
-#endif
+#endif	//nQ_WS_WIN

Modified: trunk/rkward/rkward/windows/rkwindowcatcher.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.cpp	2009-06-03 20:13:49 UTC (rev 2516)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.cpp	2009-06-04 19:58:09 UTC (rev 2517)
@@ -68,7 +68,7 @@
 #include <QScrollArea>
 #include <qlabel.h>
 #ifdef Q_WS_WIN
-#	include "../foreign/qwinhost.h"
+#	include "../qwinhost/qwinhost.h"
 #else
 #	include <QX11EmbedContainer>
 #endif


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