stuartlangridge / magnus

A very simple screen magnifier for Ubuntu
MIT License
38 stars 13 forks source link

can not resize the window and make it small to a certain width #10

Closed binoysarker closed 3 years ago

binoysarker commented 4 years ago

Hello sir i am using ubuntu budgie 20.04 and i opened the app and resize to a almost half of the width of my window screen. But when i want to resize the width i can not do that. Pleas let me know how can i fix this. Thnaks.

stuartlangridge commented 4 years ago

Hi! This is obviously not supposed to happen, so I will leave this bug open. However, you can remove the configuration file, which is ~/.cache/magnus.json (you can find this by showing hidden files in your file manager and then removing the magnus.json file in the .cache folder), which should cause it to forget the incorrect size.

bgarnham commented 4 years ago

Hi, I wanted to let you know some more detail regarding what I believe to be the same bug. I've been using Magnus on a new upgrade to Ubuntu Mate 20.04.1.

I've found that whatever size Magnus is when it is closed becomes the new minimum window size. When it is reopened, neither the width nor the height can be decreased from what they were when it was last closed but both can be increased from that point. Repeatedly sizing up, closing then reopening Magnus consistently causes the same issue. The size can be increased in either dimension but never decreased below the size it was when most recently closed. Deleting magnus.json resets to the default 300x300 but the behavior is the same, you cannot resize below 300 in width or height.

This bug aside, I quite like the program. I hope this is useful to you in tracking down the cause.

stuartlangridge commented 4 years ago

This is actually the same bug as https://github.com/stuartlangridge/ColourPicker/issues/69 and so could maybe be fixed in the same way, although that isn't marked as fixed either. Worth investigating, though.

paddylandau commented 4 years ago

I don't know how to upvote this issue, but what @bgarnham says is correct. Once you close Magnus, you can't resize it smaller. I ended up with Magnus covering almost my entire screen!

I was looking for the configuration file, and I discovered that you place it in the cache. Might I suggest that ~/.cache is not the right place? The folder ~/.config is made for configuration files. Thank you

kankaristo commented 3 years ago

I'm seeing this issue as well. I'm currently always removing the config/cache file in the script that I use to open/close Magnus.

I'm using Devilspie2 to automatically set the window size and position, so I don't need the window size to be remembered.

stuartlangridge commented 3 years ago

PR https://github.com/stuartlangridge/magnus/pull/11 merged, which should fix the "it won't resize smaller" problem: thank you @bgarnham!

@paddylandau the saved data file is in .cache rather than .config because it's not required; Magnus works without it. That makes it a cache, in my opinion; it can be safely removed at any time without a problem. I admit the line's a little blurred here, but I'm happy with the saved data file being where it is.

@kankaristo I've opened #14 to track being able to ignore the saved sizes, for people who want to manually control that, although this should be alleviated by @bgarnham's work to allow proper resizing.

paddylandau commented 3 years ago

@stuartlangridge — Thank you for all of that.

Regarding ~/.cache vs ~/.config, it's always that case that a configuration file isn't required. For any app, you can safely delete its configuration file (or folder, in some cases, such as ~/.config/gedit or ~/.config/filezilla).

However, the intent behind the configuration file is to retain user settings, and to allow a person to include them on their backups (my ~/.config is included in my daily backups, for example).

The cache's intent is to hold temporary files that might be deleted at just about any time, including by automated clean-up. For example, I use Ubuntu 20.04, which has an automated clean-up system that deletes cache files regularly — on my system, anything over 30 days old, but by default it can be tailored from as little as 1 hour. Thus, on my system, the Magnus configuration file in the cache will be automatically deleted every month. A person who has low storage available might set it to one hour, so the Magnus configuration file will be deleted every hour.

For that reason, I ask you please reconsider your configuration file's location.

Again, thank you

kankaristo commented 3 years ago

I agree with @paddylandau, the file created by Magnus would be more appropriately stored under ~/.config.

Many applications (e.g. Transmission and Geany) have their config under ~/.config, and save the window's previous position there (similar to Magnus, but Magnus is the only application I've seen do this under ~/.cache).

tonywyattparker commented 3 years ago

I have managed to fix the restoration of window metrics at opening on my machine(ubuntu 20.04)

In the place of the following part of the code:

    self.w.set_size_request(
        int(sw * metrics["ww"]), int(sh * metrics["wh"]))
    self.w.move(int(sw * metrics["wx"]), int(sh * metrics["wy"]))

i put these lines:

    self.w.set_default_size(300, 300)
    self.w.resize(
        int(sw * metrics["ww"] - 52), int(sh * metrics["wh"] - 99))
    self.w.move(int(sw * metrics["wx"] + 26), int(sh * metrics["wy"] + 23))

Now (after the replacement) the window appears always at the same x and y position at opening with the last changed size and can be resized to 300x300 after enlargement, but i can't guarantee that it will work so well on any other linux distribution.