[rkward/frameworks] /: Fix initial screen placement for RK-device windows

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Fri Mar 18 13:24:43 UTC 2016


Git commit 858709a593539cbeb2e7d52c60dce990ace046fe by Thomas Friedrichsmeier.
Committed on 18/03/2016 at 13:24.
Pushed by tfry into branch 'frameworks'.

Fix initial screen placement for RK-device windows

M  +1    -1    TODO
M  +1    -1    rkward/rkward.cpp
M  +12   -11   rkward/windows/detachedwindowcontainer.cpp
M  +2    -2    rkward/windows/detachedwindowcontainer.h
M  +2    -2    rkward/windows/rkworkplace.cpp

http://commits.kde.org/rkward/858709a593539cbeb2e7d52c60dce990ace046fe

diff --git a/TODO b/TODO
index 9371cd9..1a82cae 100644
--- a/TODO
+++ b/TODO
@@ -9,7 +9,7 @@ Things to test at the end:
 - Everthing concerning loading / saving, from recent files, scripts, workspace, etc.
   - Moved installations, moved workspaces.
 Knwon issues to fix:
-- Initial window placement for plots is always 0, 0 on screen 1, apparently. The above workaround may not be available, here?
+- ???
 
 Minor layout stuff to fix in plugins:
 - Barplot: "Display values" should be checkable frame
diff --git a/rkward/rkward.cpp b/rkward/rkward.cpp
index 4a0f51e..2b3671f 100644
--- a/rkward/rkward.cpp
+++ b/rkward/rkward.cpp
@@ -100,7 +100,7 @@ void bogusCalls () {
 	RKReadLineDialog::readLine (0, QString(), QString(), 0, 0);	// TODO: see above
 	RKSelectListDialog::doSelect (0, QString(), QStringList(), QStringList(), false);	// TODO: see above
 	new RKEditorDataFrame (0, 0);
-	DetachedWindowContainer (0);
+	DetachedWindowContainer (0, false);
 	new RKWorkplaceView (0);
 	new RKEditObjectAgent (QStringList (), 0);
 	RKPrintAgent::printPostscript (QString (), false);
diff --git a/rkward/windows/detachedwindowcontainer.cpp b/rkward/windows/detachedwindowcontainer.cpp
index 5be9d65..f298287 100644
--- a/rkward/windows/detachedwindowcontainer.cpp
+++ b/rkward/windows/detachedwindowcontainer.cpp
@@ -2,7 +2,7 @@
                           detachedwindowcontainer  -  description
                              -------------------
     begin                : Wed Oct 21 2005
-    copyright            : (C) 2005, 2007, 2009, 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2005-2016 by Thomas Friedrichsmeier
     email                : thomas.friedrichsmeier at kdemail.net
  ***************************************************************************/
 
@@ -37,7 +37,7 @@
 #include "../debug.h"
 
 /* Warning! Do not pass a parent widget to the KParts::MainWindow. Otherwise there will be strange crahes while removing the KXMLGUIClients! (In this case: Open a help window, and detach it. Open another help window attached. Close the detached one, then close the attached one -> crash; KDE 3.5.5) */
-DetachedWindowContainer::DetachedWindowContainer (RKMDIWindow *widget_to_capture) : KParts::MainWindow  () {
+DetachedWindowContainer::DetachedWindowContainer (RKMDIWindow *widget_to_capture, bool copy_geometry) : KParts::MainWindow  () {
 	RK_TRACE (APP);
 
 	actionCollection ()->addAction (KStandardAction::Close, "dwindow_close", this, SLOT(close()));
@@ -61,17 +61,18 @@ DetachedWindowContainer::DetachedWindowContainer (RKMDIWindow *widget_to_capture
 	}
 
 // capture widget
-// NOTE: If the window has not been shown, before, its geometry() is always 640*480, unconditionally.
-	setGeometry (widget_to_capture->frameGeometry ());
-	if (!widget_to_capture->isWindow ()) move (widget_to_capture->mapToGlobal (widget_to_capture->pos ()));
+	if (copy_geometry) {
+		setGeometry (widget_to_capture->frameGeometry ());
+		if (!widget_to_capture->isWindow ()) move (widget_to_capture->mapToGlobal (widget_to_capture->pos ()));
 #ifdef Q_OS_WIN
-	// fix for detached tool windows positioned with the frame outside the screen
-	ensurePolished ();
-	QPoint adjust = pos ();
-	if (adjust.x () < 0) adjust.setX (0);
-	if (adjust.y () < 0) adjust.setY (0);
-	if (adjust != pos ()) move (adjust);
+		// fix for detached tool windows positioned with the frame outside the screen
+		ensurePolished ();
+		QPoint adjust = pos ();
+		if (adjust.x () < 0) adjust.setX (0);
+		if (adjust.y () < 0) adjust.setY (0);
+		if (adjust != pos ()) move (adjust);
 #endif
+	}
 	widget_to_capture->setParent (this);
 	setCentralWidget (widget_to_capture);
 	widget_to_capture->show ();
diff --git a/rkward/windows/detachedwindowcontainer.h b/rkward/windows/detachedwindowcontainer.h
index c082141..30f2c5c 100644
--- a/rkward/windows/detachedwindowcontainer.h
+++ b/rkward/windows/detachedwindowcontainer.h
@@ -2,7 +2,7 @@
                           detachedwindowcontainer  -  description
                              -------------------
     begin                : Wed Oct 21 2005
-    copyright            : (C) 2005, 2009, 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2005-2016 by Thomas Friedrichsmeier
     email                : thomas.friedrichsmeier at kdemail.net
  ***************************************************************************/
 
@@ -34,7 +34,7 @@ class DetachedWindowContainer : public KParts::MainWindow {
 public:
 /** constructor.
 @param widget_to_capture The window to reparent into the detached window */
-	explicit DetachedWindowContainer (RKMDIWindow *widget_to_capture);
+	explicit DetachedWindowContainer (RKMDIWindow *widget_to_capture, bool copy_geometry);
 /** destructor. Usually you don't call this explicitly, but rather delete/close the child view. The DetachedWindowContainer will then self destruct via viewDestroyed () */
 	~DetachedWindowContainer ();
 public slots:
diff --git a/rkward/windows/rkworkplace.cpp b/rkward/windows/rkworkplace.cpp
index 94da5ca..6e4b8c7 100644
--- a/rkward/windows/rkworkplace.cpp
+++ b/rkward/windows/rkworkplace.cpp
@@ -229,7 +229,7 @@ void RKWorkplace::detachWindow (RKMDIWindow *window, bool was_attached) {
 		if (!window->isToolWindow ()) view ()->removeWindow (window);
 	}
 
-	DetachedWindowContainer *detached = new DetachedWindowContainer (window);
+	DetachedWindowContainer *detached = new DetachedWindowContainer (window, was_attached);
 	detached->show ();
 	if (!was_attached) window->activate ();
 }
@@ -329,7 +329,7 @@ void RKWorkplace::setWindowPlacementOverrides(const QString& placement, const QS
 	RK_TRACE (APP);
 
 	if (placement == "attached") window_placement_override = RKMDIWindow::Attached;
-	else if (placement == "detached") window_placement_override = RKMDIWindow::Attached;
+	else if (placement == "detached") window_placement_override = RKMDIWindow::Detached;
 	else {
 		RK_ASSERT (placement.isEmpty ());
 		window_placement_override = RKMDIWindow::AnyWindowState;



More information about the rkward-tracker mailing list