[education/rkward] /: Fix plot window not showing when created attached

Thomas Friedrichsmeier null at kde.org
Sun Mar 27 14:02:53 BST 2022


Git commit f53c2be9c00a83100b603ea179381da80a2c2d64 by Thomas Friedrichsmeier.
Committed on 27/03/2022 at 13:02.
Pushed by tfry into branch 'master'.

Fix plot window not showing when created attached

M  +1    -0    ChangeLog
M  +1    -0    rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
M  +8    -5    rkward/windows/rkwindowcatcher.cpp
M  +1    -1    rkward/windows/rkwindowcatcher.h

https://invent.kde.org/education/rkward/commit/f53c2be9c00a83100b603ea179381da80a2c2d64

diff --git a/ChangeLog b/ChangeLog
index 92e08b89..2b1c74d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@ TODOS for autotests:
   - Check and update the standards files
   - Use options(warn=1), in order to get warnings into the test?
 
+- Fix plot window not showing when created attached
 - Space-saving placement of main window status bar, and display more tips in it
 - Fixed: Intial graphics window size would be (mostly) ignored
 - Fix some buglets around closing on-screen devices
diff --git a/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp b/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
index e42570f2..f3c2b2b4 100644
--- a/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
+++ b/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
@@ -201,6 +201,7 @@ void RKGraphicsDevice::checkSize() {
 	RK_TRACE (GRAPHICS_DEVICE);
 	if(!view) return;
 	if (view->size () != area.size ()) {
+		if(view->size().isEmpty()) return;
 		RKGlobals::rInterface()->issueCommand(new RCommand ("rkward:::RK.resize(" + QString::number(devices.key(this) + 1) + ',' + QString::number(id) + ')', RCommand::PriorityCommand));
 	}
 }
diff --git a/rkward/windows/rkwindowcatcher.cpp b/rkward/windows/rkwindowcatcher.cpp
index a8199c98..cda54025 100644
--- a/rkward/windows/rkwindowcatcher.cpp
+++ b/rkward/windows/rkwindowcatcher.cpp
@@ -281,6 +281,8 @@ RKCaughtX11Window::RKCaughtX11Window (RKGraphicsDevice* rkward_device, int devic
 	stop_interaction->setEnabled (false);
 	setCaption (rkward_device->viewPort ()->windowTitle ());
 	rkward_device->viewPort()->setFixedSize(rkward_device->viewPort()->size()); // Prevent resizing *before* the window is shown. Will be re-enabled later
+	xembed_container->setFixedSize(rk_native_device->viewPort()->size());
+	xembed_container->show();
 	setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
 
 	QTimer::singleShot (0, this, SLOT (doEmbed()));
@@ -318,10 +320,13 @@ void RKCaughtX11Window::commonInit (int device_number) {
 	scroll_widget->setWidget (xembed_container);
 	xembed_container->hide (); // it seems to be important that the parent of a captured / embedded window is invisible prior to embedding.
 
-	dynamic_size = false;
 	dynamic_size_action->setChecked (false);
 }
 
+bool RKCaughtX11Window::dynamicSize() const {
+	return (xembed_container->parentWidget() == scroll_widget);
+}
+
 void RKCaughtX11Window::doEmbed () {
 	RK_TRACE (MISC);
 
@@ -463,18 +468,16 @@ void RKCaughtX11Window::fixedSizeToggled () {
 	RK_TRACE (MISC);
 
 	if (embedded && !capture) return;  // while in the middle of embedding, don't mess with any of this, it seems to cause trouble
-	if (dynamic_size == dynamic_size_action->isChecked ()) return;
-	dynamic_size = dynamic_size_action->isChecked ();
+	if (dynamicSize() == dynamic_size_action->isChecked ()) return;
 
 	if (dynamic_size_action->isChecked ()) {
-		scroll_widget->takeWidget ();
+		if (scroll_widget->widget()) scroll_widget->takeWidget();
 		scroll_widget->hide ();
 		layout ()->addWidget (xembed_container);
 		xembed_container->show ();
 		xembed_container->setMinimumSize (5, 5);
 		xembed_container->setMaximumSize (32767, 32767);
 	} else {
-		xembed_container->setFixedSize (xembed_container->size ());
 		layout ()->removeWidget (xembed_container);
 		scroll_widget->setWidget (xembed_container);
 		scroll_widget->show ();
diff --git a/rkward/windows/rkwindowcatcher.h b/rkward/windows/rkwindowcatcher.h
index 0cecbcf6..06ec58ef 100644
--- a/rkward/windows/rkwindowcatcher.h
+++ b/rkward/windows/rkwindowcatcher.h
@@ -191,7 +191,7 @@ private:
 	QWidget *capture;  // The captured window (0, if using an rk native device)
 	RKGraphicsDevice *rk_native_device;
 
-	bool dynamic_size;
+	bool dynamicSize() const;
 	KToggleAction *dynamic_size_action;
 	QAction *plot_prev_action;
 	QAction *plot_next_action;


More information about the rkward-tracker mailing list