Giter Site home page Giter Site logo

Comments (9)

phillipberndt avatar phillipberndt commented on May 28, 2024

I'd prefer to try to fix bugs with WMs directly before using such a drastic approach. Which issues do you experience, and with which WM?

from pqiv.

CamilleScholtz avatar CamilleScholtz commented on May 28, 2024

I'm using openbox & fvwm.

This is kinda hard to explain, especially since English is my second language but I'll try: I want this options because I don't use the center window option of pqiv, but when loading multiple images I want the center of the window to stay the same (however the center of the window doesn't have to be center of the monitor!).

in both openbox and fvwm I've set an option that makes new windows spawn under the cursor. By combining this with a replace-window option the windows jump around way less.

I created a webm that hopefully explains this a bit better: https://sr.ht/fOOp.webm

The first image viewer is pqiv, like you can see the image jumps around a lot, the second one is pho.

from pqiv.

phillipberndt avatar phillipberndt commented on May 28, 2024

You can use --window-position=off to switch off positioning. That's not quite what you want - it will (probably) leave the upper left corner in place instead of the window's center. Combined with

gtk_window_set_gravity(main_window, GDK_GRAVITY_CENTER);

somewhere in create_window, around line 3950, this should what you want?! (This line will have some unexpected side effects though, I'll probably have to work around some bugs. That said, resizing around the window's center does indeed feel much better, I'm tempted to make this the default behaviour.)

from pqiv.

phillipberndt avatar phillipberndt commented on May 28, 2024

See my latest upload (to the center-gravity branch). Is this an improvement?

from pqiv.

CamilleScholtz avatar CamilleScholtz commented on May 28, 2024

It's better but not perfect yet, Example:

https://sr.ht/pikY.png jumps too https://sr.ht/Agpr.png

The two pictures in question: https://sr.ht/oxgN.jpg https://sr.ht/m6MB.jpg

from pqiv.

phillipberndt avatar phillipberndt commented on May 28, 2024

Too bad.. in Cinnamon, this works as expected with your images. I thought about reimplementing the whole resizing/positioning on my own for a while now, because there are indeed many incompatibilities and rough edges in general between the different WMs and GDKs code for handling it. I'll look into this soon.

In the meantime, in image_loaded_handler, near line 1442, directly above the line that calls set_scale_level_for_screen, insert

if(!main_window_in_fullscreen) {
    gtk_widget_unmap(GTK_WIDGET(main_window));
    gtk_widget_map(GTK_WIDGET(main_window));
}

This should close & reopen the window whenever a new image is loaded. Combined with --window-position=off this should work as expected.

from pqiv.

CamilleScholtz avatar CamilleScholtz commented on May 28, 2024

The unmap/map thing didn't really work, I think the window actually needs to be destroyed in order for it to work. Anyways I've been experimenting with a "follow cursor position option", keep in mind I don't know anything about programming :p

    if(!main_window_in_fullscreen) {
        gint cursor_x = -1;
        gint cursor_y = -1;
        gint window_w = -1;
        gint window_h = -1;

        gdk_window_get_pointer(NULL, &cursor_x, &cursor_y, NULL);
        gtk_window_get_size(main_window, &window_w, &window_h);

        gtk_window_move(main_window, cursor_x - window_w / 2, cursor_y - window_h / 2);
    }

This works great when all images are the exact same size, however the pqiv window still jumps when the image size differs.

from pqiv.

phillipberndt avatar phillipberndt commented on May 28, 2024

Lacking a working better solution, I now added --recreate-window in the recreate-window branch. Does this work as expected, and do you still need the feature?

from pqiv.

CamilleScholtz avatar CamilleScholtz commented on May 28, 2024

Works perfectly, thanks!

from pqiv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.