[education/rkward] /: Fix graphics windows initial size

Thomas Friedrichsmeier null at kde.org
Sat Mar 19 23:17:44 GMT 2022


Git commit db19e9610025e5ca2e5d392688b5633a0bef42f1 by Thomas Friedrichsmeier.
Committed on 19/03/2022 at 23:17.
Pushed by tfry into branch 'master'.

Fix graphics windows initial size

M  +1    -3    ChangeLog
M  +6    -0    rkward/windows/detachedwindowcontainer.cpp
M  +7    -2    rkward/windows/rkwindowcatcher.cpp

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

diff --git a/ChangeLog b/ChangeLog
index 25e031a8..76a77813 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,8 @@
-TODO:
-- Fix initial graphics window size
-
 TODOS for autotests:
   - Check and update the standards files
   - Use options(warn=1), in order to get warnings into the test?
 
+- Fixed: Intial graphics window size would be (mostly) ignored
 - Fix some buglets around closing on-screen devices
 - Implement new R graphics functions: gradients, patterns, clip paths
 - Add icons to settings dialog for quick visual orientation
diff --git a/rkward/windows/detachedwindowcontainer.cpp b/rkward/windows/detachedwindowcontainer.cpp
index 3e2be316..ae69edd7 100644
--- a/rkward/windows/detachedwindowcontainer.cpp
+++ b/rkward/windows/detachedwindowcontainer.cpp
@@ -79,6 +79,12 @@ DetachedWindowContainer::DetachedWindowContainer (RKMDIWindow *widget_to_capture
 	createGUI(widget_to_capture->getPart());
 //	if (widget_to_capture->uiBuddy()) factory()->addClient(widget_to_capture->uiBuddy());
 	captured = widget_to_capture;
+	// Special case for graph windows: We don't want to touch their default size before showing. So tell the toolbars to step back, if needed.
+	if (widget_to_capture->isType(RKMDIWindow::X11Window)) {
+		foreach (KToolBar *bar, toolBars()) {
+			bar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
+		}
+	}
 
 	hideEmptyMenus ();
 	// hide empty menus now, and after any reloads
diff --git a/rkward/windows/rkwindowcatcher.cpp b/rkward/windows/rkwindowcatcher.cpp
index 0371669d..a8199c98 100644
--- a/rkward/windows/rkwindowcatcher.cpp
+++ b/rkward/windows/rkwindowcatcher.cpp
@@ -273,8 +273,6 @@ RKCaughtX11Window::RKCaughtX11Window (RKGraphicsDevice* rkward_device, int devic
 
 	commonInit (device_number);
 	rk_native_device = rkward_device;
-	xembed_container->setFixedSize (rk_native_device->viewPort ()->size ());
-	resize (xembed_container->size ());
 	rk_native_device->viewPort ()->setParent (xembed_container);
 	xembed_container->layout ()->addWidget (rk_native_device->viewPort ());
 	connect (rkward_device, &RKGraphicsDevice::captionChanged, this, &RKCaughtX11Window::setCaption);
@@ -282,6 +280,8 @@ RKCaughtX11Window::RKCaughtX11Window (RKGraphicsDevice* rkward_device, int devic
 	stop_interaction->setVisible (true);
 	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
+	setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
 
 	QTimer::singleShot (0, this, SLOT (doEmbed()));
 }
@@ -336,6 +336,11 @@ void RKCaughtX11Window::doEmbed () {
 		xembed_container->layout ()->addWidget (capture);
 		xembed_container->show ();
 	}
+	if (rk_native_device) {
+		rk_native_device->viewPort()->setMinimumSize(5,5);
+		rk_native_device->viewPort()->setMaximumSize(32768,32768);
+		setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+	}
 
 	if (!isAttached ()) {
 		// make xembed_container resizable, again, now that it actually has a content


More information about the rkward-tracker mailing list