[rkward-cvs] SF.net SVN: rkward: [938] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Sun Nov 26 17:40:56 UTC 2006
Revision: 938
http://svn.sourceforge.net/rkward/?rev=938&view=rev
Author: tfry
Date: 2006-11-26 09:40:56 -0800 (Sun, 26 Nov 2006)
Log Message:
-----------
Catching R X11 windows is working pretty well, now, but no real functionality added to the menu, yet
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/TODO
trunk/rkward/rkward/rbackend/rkwindowcatcher.cpp
trunk/rkward/rkward/rbackend/rkwindowcatcher.h
trunk/rkward/rkward/rkwardapplication.cpp
trunk/rkward/rkward/rkwardapplication.h
trunk/rkward/rkward/windows/Makefile.am
trunk/rkward/rkward/windows/detachedwindowcontainer.cpp
trunk/rkward/rkward/windows/rkmdiwindow.h
trunk/rkward/rkward/windows/rkworkplace.cpp
trunk/rkward/rkward/windows/rkworkplace.h
Added Paths:
-----------
trunk/rkward/rkward/windows/rkcatchedx11windowpart.rc
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2006-11-26 16:04:11 UTC (rev 937)
+++ trunk/rkward/ChangeLog 2006-11-26 17:40:56 UTC (rev 938)
@@ -1,3 +1,4 @@
+- fixed: selecting Window->Close in a detached window would only close the internal view, not the window
- when detaching a window, give it a more reasonable size
- do not open the same script url twice (instead the corresponding window is raised on the second attempt)
- fixed: when closing a detached script editor window, you would not be asked to save changes (if any)
Modified: trunk/rkward/TODO
===================================================================
--- trunk/rkward/TODO 2006-11-26 16:04:11 UTC (rev 937)
+++ trunk/rkward/TODO 2006-11-26 17:40:56 UTC (rev 938)
@@ -27,6 +27,7 @@
- Access to dev.copy (), dev.print (), and a function to copy gaphics to rkward output
- probably in Windows-menu for now
- also allow scroll-bar mode
+ - When attaching an X11 window, it should always go into fixed scroll-bar mode
- Output window should gain some sort of auto-update functionality:
- After user commands, should check, whether the output file was modified. If so, reload
- Option to save workplace per session instead of per workspace
Modified: trunk/rkward/rkward/rbackend/rkwindowcatcher.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkwindowcatcher.cpp 2006-11-26 16:04:11 UTC (rev 937)
+++ trunk/rkward/rkward/rbackend/rkwindowcatcher.cpp 2006-11-26 17:40:56 UTC (rev 938)
@@ -26,20 +26,21 @@
#include <klocale.h>
#include <kwin.h>
-#include <X11/X.h>
-#include <X11/Xlib.h>
-
#include "../rkwardapplication.h"
+#include "../windows/rkworkplace.h"
#include "../windows/qxembedcopy.h"
#include "../debug.h"
RKWindowCatcher::RKWindowCatcher (QWidget *parent) : QWidget (parent) {
+ RK_TRACE (MISC);
}
RKWindowCatcher::~RKWindowCatcher () {
+ RK_TRACE (MISC);
}
void RKWindowCatcher::start (int prev_cur_device) {
+ RK_TRACE (MISC);
RK_DO (qDebug ("Window Catcher activated"), RBACKEND, DL_DEBUG);
RKWardApplication::getApp ()->startWindowCreationDetection ();
@@ -47,22 +48,15 @@
}
void RKWindowCatcher::stop (int new_cur_device) {
+ RK_TRACE (MISC);
RK_DO (qDebug ("Window Catcher deactivated"), RBACKEND, DL_DEBUG);
if (new_cur_device != last_cur_device) {
WId w = RKWardApplication::getApp ()->endWindowCreationDetection ();
- qDebug ("Window id is: %x", w);
if (w) {
- QXEmbedCopy *capture = new QXEmbedCopy (0, 0, Qt::WDestructiveClose);
- capture->setProtocol (QXEmbedCopy::XPLAIN);
- connect (capture, SIGNAL (embeddedWindowDestroyed ()), capture, SLOT (deleteLater ()));
-
- KWin::WindowInfo wininfo = KWin::windowInfo (w);
- capture->setGeometry (wininfo.frameGeometry ());
- capture->embed (w);
-
- capture->show ();
+ RKWorkplace::mainWorkplace ()->newX11Window (w, new_cur_device);
+ //new RKCatchedX11Window (w, new_cur_device);
} else {
KMessageBox::sorry (0, i18n ("You have created a new X11 device window in R. Usually, RKWard tries to detect such windows, to take control of them, and add a menu-bar to them. This time, however, RKWard failed to detect, which window was created, and so can not embed it.\nIf you created the window on a different screen or X11 display, that is to be expected. You might want to consider changing options(\"display\"), then.\nIf you can see the X11 window on the same screen as this message, then RKWard should do better. In this case, please contact us at rkward-devel at lists.sourceforge.net with details on your setup, so we can try to fix this in future versions of RKWard."), i18n ("Could not embed R X11 window"));
}
@@ -70,6 +64,65 @@
last_cur_device = new_cur_device;
}
+
+
+
+RKCatchedX11Window::RKCatchedX11Window (WId window_to_embed, int device_number) : RKMDIWindow (0, X11Window) {
+ RK_TRACE (MISC);
+
+ part = new RKCatchedX11WindowPart (this);
+ setFocusPolicy (QWidget::ClickFocus);
+
+ embedded = window_to_embed;
+ RKCatchedX11Window::device_number = device_number;
+
+ QVBoxLayout *layout = new QVBoxLayout (this);
+ QXEmbedCopy *capture = new QXEmbedCopy (this);
+ capture->setProtocol (QXEmbedCopy::XPLAIN);
+ connect (capture, SIGNAL (embeddedWindowDestroyed ()), this, SLOT (deleteLater ()));
+ layout->addWidget (capture);
+
+ KWin::WindowInfo wininfo = KWin::windowInfo (window_to_embed);
+ setGeometry (wininfo.frameGeometry ());
+ setCaption (wininfo.name ());
+ capture->embed (window_to_embed);
+
+ RKWardApplication::getApp ()->registerNameWatcher (window_to_embed, this);
+
+ show ();
+}
+
+RKCatchedX11Window::~RKCatchedX11Window () {
+ RK_TRACE (MISC);
+
+ RKWardApplication::getApp ()->unregisterNameWatcher (embedded);
+}
+
+KParts::Part *RKCatchedX11Window::getPart () {
+ RK_TRACE (MISC);
+
+ return part;
+}
+
+
+
+
+RKCatchedX11WindowPart::RKCatchedX11WindowPart (RKCatchedX11Window *window) : KParts::Part (0) {
+ RK_TRACE (MISC);
+
+ KInstance* instance = new KInstance ("rkward");
+ setInstance (instance);
+
+ setWidget (window);
+ RKCatchedX11WindowPart::window = window;
+
+ setXMLFile ("rkcatchedx11windowpart.rc");
+}
+
+RKCatchedX11WindowPart::~RKCatchedX11WindowPart () {
+ RK_TRACE (MISC);
+}
+
#include "rkwindowcatcher.moc"
#endif // DISABLE_RKWINDOWCATCHER
Modified: trunk/rkward/rkward/rbackend/rkwindowcatcher.h
===================================================================
--- trunk/rkward/rkward/rbackend/rkwindowcatcher.h 2006-11-26 16:04:11 UTC (rev 937)
+++ trunk/rkward/rkward/rbackend/rkwindowcatcher.h 2006-11-26 17:40:56 UTC (rev 938)
@@ -74,10 +74,40 @@
int last_cur_device;
};
-/*
+#include "../windows/rkmdiwindow.h"
+
+class RKCatchedX11WindowPart;
+
+/** An R X11 device window managed by rkward */
class RKCatchedX11Window : public RKMDIWindow {
+ Q_OBJECT
+public:
+ RKCatchedX11Window (WId window_to_embed, int device_number);
+
+ ~RKCatchedX11Window ();
+
+ KParts::Part *getPart ();
+ QString getRDescription () { return "unimplemtend"; };
+ bool isModified () { return false; };
+private:
+ int device_number;
+ WId embedded;
+ RKCatchedX11WindowPart *part;
};
-*/
+class RKCatchedX11WindowPart : public KParts::Part {
+ Q_OBJECT
+public:
+/** constructor.
+ at param console The console for this part */
+ RKCatchedX11WindowPart (RKCatchedX11Window *window);
+/** destructor */
+ ~RKCatchedX11WindowPart ();
+public slots:
+// TODO
+private:
+ RKCatchedX11Window *window;
+};
+
#endif //DISABLE_RKWINDOWCATCHER
#endif
Modified: trunk/rkward/rkward/rkwardapplication.cpp
===================================================================
--- trunk/rkward/rkward/rkwardapplication.cpp 2006-11-26 16:04:11 UTC (rev 937)
+++ trunk/rkward/rkward/rkwardapplication.cpp 2006-11-26 17:40:56 UTC (rev 938)
@@ -27,6 +27,7 @@
//static
RKWardApplication *RKWardApplication::rkapp = 0;
+Atom wm_name_property;
RKWardApplication::RKWardApplication () : KApplication () {
RK_TRACE (APP);
@@ -34,6 +35,8 @@
rkapp = this;
detect_x11_creations = false;
+
+ wm_name_property = XInternAtom (qt_xdisplay (), "WM_NAME", true);
}
RKWardApplication::~RKWardApplication () {
@@ -61,10 +64,26 @@
RK_ASSERT (detect_x11_creations);
detect_x11_creations = false;
- XSelectInput (qt_xdisplay (), qt_xrootwin (), 0);
+ XSelectInput (qt_xdisplay (), qt_xrootwin (), NoEventMask);
return created_window;
}
+void RKWardApplication::registerNameWatcher (WId watched, QWidget *watcher) {
+ RK_TRACE (APP);
+ RK_ASSERT (!name_watchers_list.contains (watched));
+
+ XSelectInput (qt_xdisplay (), watched, PropertyChangeMask);
+ name_watchers_list.insert (watched, watcher);
+}
+
+void RKWardApplication::unregisterNameWatcher (WId watched) {
+ RK_TRACE (APP);
+ RK_ASSERT (name_watchers_list.contains (watched));
+
+ XSelectInput (qt_xdisplay (), watched, NoEventMask);
+ name_watchers_list.remove (watched);
+}
+
bool RKWardApplication::x11EventFilter (XEvent *e) {
if (detect_x11_creations) {
if (e->type == CreateNotify) {
@@ -81,6 +100,16 @@
}
}
+ if (e->type == PropertyNotify) {
+ if (e->xproperty.atom == wm_name_property) {
+ if (name_watchers_list.contains (e->xproperty.window)) {
+ KWin::WindowInfo wininfo = KWin::windowInfo (e->xproperty.window);
+ name_watchers_list[e->xproperty.window]->setCaption (wininfo.name ());
+ return true;
+ }
+ }
+ }
+
return KApplication::x11EventFilter (e);
}
Modified: trunk/rkward/rkward/rkwardapplication.h
===================================================================
--- trunk/rkward/rkward/rkwardapplication.h 2006-11-26 16:04:11 UTC (rev 937)
+++ trunk/rkward/rkward/rkwardapplication.h 2006-11-26 17:40:56 UTC (rev 938)
@@ -20,6 +20,8 @@
#include <kapplication.h>
+#include <qmap.h>
+
/** The purpose of subclassing KApplication as RKWardApplication, is to obtain raw access to X11 events. This is needed to detect the creation of new toplevel windows (R X11 windows). */
class RKWardApplication : public KApplication {
@@ -35,10 +37,15 @@
void startWindowCreationDetection ();
WId endWindowCreationDetection ();
+
+ void registerNameWatcher (WId watched, QWidget *watcher);
+ void unregisterNameWatcher (WId watched);
private:
static RKWardApplication *rkapp;
bool detect_x11_creations;
WId created_window;
+
+ QMap<WId, QWidget*> name_watchers_list;
};
#endif
Modified: trunk/rkward/rkward/windows/Makefile.am
===================================================================
--- trunk/rkward/rkward/windows/Makefile.am 2006-11-26 16:04:11 UTC (rev 937)
+++ trunk/rkward/rkward/windows/Makefile.am 2006-11-26 17:40:56 UTC (rev 938)
@@ -8,4 +8,5 @@
rkhtmlwindow.cpp rcontrolwindow.cpp detachedwindowcontainer.cpp rkmdiwindow.cpp \
rkworkplaceview.cpp rkworkplace.cpp qxembedcopy.cpp
rcdir = $(kde_datadir)/rkward
-rc_DATA = rkcommandeditorwindowpart.rc rkoutputwindow.rc rkhelpwindow.rc detachedwindowcontainer.rc
+rc_DATA = rkcommandeditorwindowpart.rc rkoutputwindow.rc rkhelpwindow.rc detachedwindowcontainer.rc \
+ rkcatchedx11windowpart.rc
Modified: trunk/rkward/rkward/windows/detachedwindowcontainer.cpp
===================================================================
--- trunk/rkward/rkward/windows/detachedwindowcontainer.cpp 2006-11-26 16:04:11 UTC (rev 937)
+++ trunk/rkward/rkward/windows/detachedwindowcontainer.cpp 2006-11-26 17:40:56 UTC (rev 938)
@@ -33,7 +33,7 @@
// create own GUI
setXMLFile ("detachedwindowcontainer.rc");
- KStdAction::close (widget_to_capture, SLOT (close ()), actionCollection (), "dwindow_close");
+ KStdAction::close (this, SLOT (close ()), actionCollection (), "dwindow_close");
new KAction (i18n ("Attach to main window"), 0, this, SLOT (slotReattach ()), actionCollection (), "dwindow_attach");
createShellGUI ();
Added: trunk/rkward/rkward/windows/rkcatchedx11windowpart.rc
===================================================================
--- trunk/rkward/rkward/windows/rkcatchedx11windowpart.rc (rev 0)
+++ trunk/rkward/rkward/windows/rkcatchedx11windowpart.rc 2006-11-26 17:40:56 UTC (rev 938)
@@ -0,0 +1,9 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="rkward" version="0.4.2">
+ <MenuBar>
+ <Menu name="plot" noMerge="1"><text>&Plot</text>
+ <Action name="close"/>
+ <Merge/>
+ </Menu>
+ </MenuBar>
+</kpartgui>
\ No newline at end of file
Modified: trunk/rkward/rkward/windows/rkmdiwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkmdiwindow.h 2006-11-26 16:04:11 UTC (rev 937)
+++ trunk/rkward/rkward/windows/rkmdiwindow.h 2006-11-26 17:40:56 UTC (rev 938)
@@ -33,6 +33,7 @@
CommandEditorWindow=2,
OutputWindow=4,
HelpWindow=8,
+ X11Window=16,
AnyType=DataEditorWindow | CommandEditorWindow | OutputWindow | HelpWindow
};
@@ -75,7 +76,7 @@
/** type of this window */
Type type;
private:
-/** state of this window (attached / detached). This is set from the RKWorkplace */
+/** state of this window (attached / detached). This is usually set from the RKWorkplace */
State state;
};
Modified: trunk/rkward/rkward/windows/rkworkplace.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.cpp 2006-11-26 16:04:11 UTC (rev 937)
+++ trunk/rkward/rkward/windows/rkworkplace.cpp 2006-11-26 17:40:56 UTC (rev 938)
@@ -34,6 +34,7 @@
#include "../dataeditor/rkeditordataframepart.h"
#include "../settings/rksettingsmoduleoutput.h"
#include "../rbackend/rinterface.h"
+#include "../rbackend/rkwindowcatcher.h"
#include "../rbackend/rcommand.h"
#include "../rkglobals.h"
#include "../rkward.h"
@@ -70,26 +71,29 @@
RKWardMainWindow::getMain ()->partManager ()->addPart (window->getPart ());
}
-void RKWorkplace::detachWindow (RKMDIWindow *window) {
+void RKWorkplace::detachWindow (RKMDIWindow *window, bool was_attached) {
RK_TRACE (APP);
- RK_ASSERT (windows.find (window) != windows.end ()); // Can't detach a window that is not attached
+ RK_ASSERT (windows.find (window) != windows.end ()); // Can't detach a window that is not registered
window->state = RKMDIWindow::Detached;
RK_ASSERT (window->getPart ());
- RKWardMainWindow::getMain ()->partManager ()->removePart (window->getPart ());
- view ()->removePage (window);
+ if (was_attached) {
+ RKWardMainWindow::getMain ()->partManager ()->removePart (window->getPart ());
+ view ()->removePage (window);
+ }
DetachedWindowContainer *detached = new DetachedWindowContainer (window);
detached->show ();
}
-void RKWorkplace::addWindow (RKMDIWindow *window) {
+void RKWorkplace::addWindow (RKMDIWindow *window, bool attached) {
RK_TRACE (APP);
windows.append (window);
connect (window, SIGNAL (destroyed (QObject *)), this, SLOT (windowDestroyed (QObject *)));
- attachWindow (window);
+ if (attached) attachWindow (window);
+ else detachWindow (window, false);
}
bool RKWorkplace::openScriptEditor (const KURL &url, bool use_r_highlighting, bool read_only, const QString &force_caption) {
@@ -153,6 +157,14 @@
}
}
+void RKWorkplace::newX11Window (WId window_to_embed, int device_number) {
+ RK_TRACE (APP);
+
+ RKCatchedX11Window *window = new RKCatchedX11Window (window_to_embed, device_number);
+ window->state = RKMDIWindow::Detached;
+ addWindow (window, false);
+}
+
bool RKWorkplace::canEditObject (RObject *object) {
RK_TRACE (APP);
Modified: trunk/rkward/rkward/windows/rkworkplace.h
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.h 2006-11-26 16:04:11 UTC (rev 937)
+++ trunk/rkward/rkward/windows/rkworkplace.h 2006-11-26 17:40:56 UTC (rev 938)
@@ -55,7 +55,7 @@
/** Attach an already created window. */
void attachWindow (RKMDIWindow *window);
/** Dettach a window (it is removed from the view (), and placed in a top-level DetachedWindowContainer instead. */
- void detachWindow (RKMDIWindow *window);
+ void detachWindow (RKMDIWindow *window, bool was_attached=true);
/** @returns a pointer to the current window. Detached windows are not considered, only those attached to the workplace(view) */
RKMDIWindow *activeAttachedWindow ();
@@ -76,6 +76,8 @@
TODO: this should be obsoleted somehow */
void newOutput ();
+ void newX11Window (WId window_to_embed, int device_number);
+
/** @returns true if there is a known editor for this type of object, false otherwise */
bool canEditObject (RObject *object);
/** Creates a new editor of an appropriate type, and loads the given object into the editor
@@ -125,7 +127,7 @@
/** the view. @See view () */
RKWorkplaceView *wview;
/** Internal function to add an existing window to the list of mdi windows */
- void addWindow (RKMDIWindow *window);
+ void addWindow (RKMDIWindow *window, bool attached=true);
/** static pointer to the workplace. @See mainWorkplace () */
static RKWorkplace *main_workplace;
};
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