From 24ae37e874642ce69abe29f2d199c897663adcc5 Mon Sep 17 00:00:00 2001 From: Olaf Schulz Date: Tue, 12 Nov 2019 12:45:16 +0100 Subject: [PATCH] Fix issue which prevents window from downscaling Replace Fixed-Container by Layout-Container to disconnects the window size from the content size. Otherwise the window size can be increased but not decreased. --- src/key-overlay.vala | 18 +++++++++++------- src/neo-window.vala | 17 ++++++++++------- src/scaling-image.vala | 7 +++++-- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/key-overlay.vala b/src/key-overlay.vala index 0b68544..426c3a5 100644 --- a/src/key-overlay.vala +++ b/src/key-overlay.vala @@ -37,7 +37,6 @@ namespace NeoLayoutViewer { this._width = this.winMain.get_allocated_width(); this._height = this.winMain.get_allocated_height(); this.set_size_request(_width, _height); - this.set_size(_width, _height); this.color_event_boxes = (winMain.config.get("color_event_boxes") == "1"); @@ -48,8 +47,11 @@ namespace NeoLayoutViewer { private void main_resized(){ - int width = this.winMain.get_allocated_width(); - int height = this.winMain.get_allocated_height(); + int width; + int height; + //width = this.winMain.get_allocated_width(); + //height = this.winMain.get_allocated_height(); + this.winMain.get_size(out width, out height); if( this._width == width && this._height == height ){ return; // to avoid infinite resize live lock... @@ -63,11 +65,10 @@ namespace NeoLayoutViewer { this._width = width; this._height = height; - - // Propagate new window width/height to this grid. (Redundant?!) + // Propagate new window width/height to this grid. this.set_size_request(width, height); - debug("Move cells"); + debug("Rescale cells"); move_and_scale_cells(); @@ -80,11 +81,14 @@ namespace NeoLayoutViewer { */ public void generateCells() { + // Dimensions of unscaled background image double width_unscaled = (double) winMain.get_unscaled_width(); double height_unscaled = (double) winMain.get_unscaled_height(); int width, height; - winMain.get_size(out width, out height); + // Desirered target size + width = this._width; + height = this._height; double scaleX = width/width_unscaled; double scaleY = height/height_unscaled; diff --git a/src/neo-window.vala b/src/neo-window.vala index caca75f..562d2ec 100644 --- a/src/neo-window.vala +++ b/src/neo-window.vala @@ -258,20 +258,22 @@ namespace NeoLayoutViewer { int win_width = get_image_width_for_monitor(this.monitor_w); int win_height = (backgroundH_unscaled * win_width)/ backgroundW_unscaled; + //this.set_size_request(1, 1); this.resize(win_width, win_height); + this.set_default_size(win_width, win_height); image.show(); - var fixed = new Fixed(); - fixed.put(this.image, 0, 0); + var layout = new Layout(); + layout.put(this.image, 0, 0); #if _NO_WIN this.key_overlay = new KeyOverlay(this); this.key_overlay.show(); - fixed.put(this.key_overlay, 0, 0); + layout.put(this.key_overlay, 0, 0); #endif - add(fixed); - fixed.show(); + add(layout); + layout.show(); //Fenstereigenschaften setzen this.key_press_event.connect(on_key_pressed); @@ -400,7 +402,7 @@ namespace NeoLayoutViewer { // Check images of layers need to be rescaled - if (monitor_rect_dest.width != this.monitor_w && true){ + if (monitor_rect_dest.width != this.monitor_w) { this.monitor_w = monitor_rect_dest.width; int width; @@ -408,7 +410,8 @@ namespace NeoLayoutViewer { width = get_image_width_for_monitor(this.monitor_w); height = get_unscaled_height() * width / get_unscaled_width(); - this.resize(width, height); + //this.resize(width, height); + this.set_default_size(width, height); } int x, y, w, h; diff --git a/src/scaling-image.vala b/src/scaling-image.vala index 6a4d405..1af0093 100644 --- a/src/scaling-image.vala +++ b/src/scaling-image.vala @@ -58,8 +58,11 @@ namespace NeoLayoutViewer { private void main_resized(){ // Get new window size - int win_width2 = this.winMain.get_allocated_width(); - int win_height2 = this.winMain.get_allocated_height(); + int win_width2; + int win_height2; + //win_width2 = this.winMain.get_allocated_width(); + //win_height2 = this.winMain.get_allocated_height(); + this.winMain.get_size(out win_width2, out win_height2); if (win_width == win_width2 && win_height == win_height2) { //debug(@"(ScalingImage $(this.id)) same width $(win_width)");