Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

100% width not operating as expected with vertical monitors #11

Closed
BrodieRobertson opened this issue Jul 26, 2022 · 14 comments
Closed

100% width not operating as expected with vertical monitors #11

BrodieRobertson opened this issue Jul 26, 2022 · 14 comments

Comments

@BrodieRobertson
Copy link

BrodieRobertson commented Jul 26, 2022

I use a mix of vertical and horizontal monitors, when I open it on my horizontal monitor tofi spans across my entire screen
2022-07-26_11-50

But when I open it on my vertical monitor, it seems to keep using the same width as the horizontal monitor
2022-07-26_11-52

Without seeing the code if I had to guess, width 100% is probably being based off of the main monitor width

@philj56
Copy link
Owner

philj56 commented Jul 26, 2022

Ah yep thanks, fixed in d3bf3b0 - It was just using the unrotated width / height for calculating percentages.

@philj56 philj56 closed this as completed Jul 26, 2022
@beucismis
Copy link

beucismis commented Aug 16, 2022

Hi! I'am having a similar problem. Tofi: v0.4.0-1

2022-08-16T06:31:51,669720161+03:00

@philj56 philj56 reopened this Aug 16, 2022
@philj56
Copy link
Owner

philj56 commented Aug 16, 2022

That's strange - could you recompile with debugging enabled, and paste the terminal output of tofi here?

Debugging's the default state, so it should just be:

git clone https://github.com/philj56/tofi.git  # Or download the tarball
cd tofi/
meson build
ninja -C build
ln -s tofi ./build/tofi-run  # Have to do this if you're not installing
./build/tofi-run

@beucismis
Copy link

That's strange - could you recompile with debugging enabled, and paste the terminal output of tofi here?

Sure! Debug outputs:

$ ./build/tofi-run
[ real,   cpu,   maxRSS]
[0.000, 0.020, 15428 KB][DEBUG]: This is tofi.
[0.000, 0.020, 15428 KB][DEBUG]: Loading config file /home/beucismis/.config/tofi/config.
[0.001, 0.021, 15428 KB][DEBUG]: First roundtrip start.
[0.002, 0.021, 15428 KB][DEBUG]: 	Bound to shm 1.
[0.002, 0.021, 15428 KB][DEBUG]: 	Bound to compositor 4.
[0.003, 0.021, 15428 KB][DEBUG]: 	Bound to zwlr_layer_shell_v1 11.
[0.003, 0.021, 15428 KB][DEBUG]: 	Bound to seat 39.
[0.003, 0.021, 15428 KB][DEBUG]: 	Bound to output 41.
[0.003, 0.021, 15428 KB][DEBUG]: First roundtrip done.
[0.003, 0.021, 15428 KB][DEBUG]: Second roundtrip start.
[0.004, 0.022, 15428 KB][DEBUG]: 	Got keyboard from seat.
[0.004, 0.022, 15428 KB][DEBUG]: 	Got pointer from seat.
[0.004, 0.022, 15428 KB][DEBUG]: 	Output configuration done.
[0.004, 0.022, 15428 KB][DEBUG]: Second roundtrip done.
[0.004, 0.022, 15428 KB][DEBUG]: Selected output LVDS-1.
[0.004, 0.022, 15428 KB][DEBUG]: Generating command list.
[0.004, 0.022, 15428 KB][DEBUG]: 	Retrieving PATH.
[0.005, 0.022, 15428 KB][DEBUG]: 	Retrieving cache location.
[0.005, 0.022, 15428 KB][DEBUG]: 	Cache up to date, loading.
[0.007, 0.024, 15428 KB][DEBUG]: 	Moving already known programs to the front.
[0.008, 0.025, 15428 KB][DEBUG]: Command list generated.
[0.008, 0.026, 15428 KB][DEBUG]: Creating main window surface.
[0.008, 0.026, 15428 KB][DEBUG]: Third roundtrip start.
[0.010, 0.026, 15428 KB][DEBUG]: 	Configuring keyboard.
[0.021, 0.036, 15428 KB][DEBUG]: 	Keyboard configured.
[0.021, 0.036, 15428 KB][DEBUG]: 	Key repeat every 40 ms after 600 ms.
[0.021, 0.036, 15428 KB][DEBUG]: 	Layer surface configure, 1280 x 20.
[0.021, 0.036, 15428 KB][DEBUG]: 	Layer surface configure, 1280 x 20.
[0.021, 0.036, 15428 KB][DEBUG]: Third roundtrip done.
[0.021, 0.036, 15428 KB][DEBUG]: Initialising window surface.
[0.021, 0.036, 15428 KB][DEBUG]: 	Created shm file with size 200 KiB.
[0.021, 0.036, 15428 KB][DEBUG]: Window surface initialised.
[0.021, 0.036, 15428 KB][DEBUG]: Initialising renderer.
[0.022, 0.037, 15428 KB][DEBUG]: 	Creating Pango context.
[0.023, 0.038, 15428 KB][DEBUG]: 	Creating Pango font description.
[0.023, 0.039, 15428 KB][DEBUG]: 	Initial text render.
[0.053, 0.070, 15428 KB][DEBUG]: 	Drew 20 results.
[0.053, 0.071, 15428 KB][DEBUG]: Renderer initialised.
[0.054, 0.071, 15428 KB][DEBUG]: Surface entered output.
[0.054, 0.071, 15428 KB][DEBUG]: Layer surface configure, 1280 x 20.

@philj56
Copy link
Owner

philj56 commented Aug 16, 2022

Ok, so the important lines are the

[0.021, 0.036, 15428 KB][DEBUG]: 	Layer surface configure, 1280 x 20.

That's a little suspicious to me, 1280 is the default width of the window if you don't pass any width options. Are you sure you have width = 100% in your config file? You can quickly do either

./build/tofi-run -c themes/dmenu

or pass it explicitly with

./build/tofi-run --width 100%

@beucismis
Copy link

beucismis commented Aug 16, 2022

Are you sure you have width = 100% in your config file?

Yes, sure. My config file:

anchor=bottom
width=100%
height=20
horizontal=true
font-size=9
font=monospace
outline-width=0
border-width=0
background-color=#000000
min-input-width=50
result-spacing=10
padding-top=2
padding-bottom=0

2022-08-16T14:42:20,222920946+03:00

@philj56
Copy link
Owner

philj56 commented Aug 16, 2022

Hmmmm, maybe I broke something when I changed the percentage handling - could you try it with the last commit before I changed that (c9f1dae)?

git checkout c9f1daea03a41c0cad56453e1dcc50f6133f19c6
ninja -C build
./build/tofi-run --width=100%

If that doesn't work, what OS / sway version (sway --version) are you on (assuming you're using sway)?

@beucismis
Copy link

beucismis commented Aug 16, 2022

Hmmmm, maybe I broke something when I changed the percentage handling - could you try it with the last commit before I changed that (c9f1dae)?

I did it but didn't work. I use Devuan Ceres (unstable) and Sway 1.7.

@philj56
Copy link
Owner

philj56 commented Aug 16, 2022

Thanks, I guess I'll give it a go on Devuan myself then and see if I can replicate it.

One last thing, if you're comfortable doing a little source-code hacking, could you stick in some print statements at src/main.c, line 1138 (on the master branch):

log_debug("Output size: %u x %u.\n", el->width, el->height);
log_debug("Desired window size: %u x %u\n", tofi.window.width, tofi.window.height);
log_debug("Percentage?: %d, %d\n", tofi.window.width_is_percent, tofi.window.height_is_percent);

(or in diff format):

diff --git a/src/main.c b/src/main.c
index 8cc913d..9fe5162 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1137,6 +1137,9 @@ int main(int argc, char *argv[])
                tofi.window.scale = el->scale;
                tofi.window.transform = el->transform;
                log_debug("Selected output %s.\n", el->name);
+               log_debug("Output size: %u x %u.\n", el->width, el->height);
+               log_debug("Desired window size: %u x %u\n", tofi.window.width, tofi.window.height);
+               log_debug("Percentage?: %d, %d\n", tofi.window.width_is_percent, tofi.window.height_is_percent);
        }
 
        /* We can now calculate any percentages, as we know the output size. */

And see what the debug output shows then? I'm trying to work out where the wrong value is coming from.

@beucismis
Copy link

beucismis commented Aug 16, 2022

Hi, I hacked and recompiled... Logs you requested:

$ ./build/tofi-run --width=100%
...
[0.004, 0.021,  5752 KB][DEBUG]: Output size: 1280 x 800.
[0.004, 0.021,  5752 KB][DEBUG]: Desired window size: 100 x 20
[0.004, 0.021,  5752 KB][DEBUG]: Percentage?: 1, 0
...

What does the desired window size mean?

@philj56
Copy link
Owner

philj56 commented Aug 16, 2022

Thanks for doing all this, it's very helpful! That's really odd though. The desired window size means the size tofi's going make a buffer for and ask the window manager to display. Here it's working as expected - it's 100% x 20px. The Output size: line is the concerning one - somehow Sway's reporting that your screen is currently set to 1280x800.

The very last thing I can think of (apparently I lied before) is to print something else, at line 514 in output_mode():

diff --git a/src/main.c b/src/main.c
index 8cc913d..93d175e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -512,6 +512,7 @@ static void output_mode(
 {
        struct tofi *tofi = data;
        struct output_list_element *el;
+       log_debug("Output %p, Mode %d x %d, current? %d\n", wl_output, width, height, flags & WL_OUTPUT_MODE_CURRENT);
        wl_list_for_each(el, &tofi->output_list, link) {
                if (el->wl_output == wl_output) {
                        if (flags & WL_OUTPUT_MODE_CURRENT) {

If that's reporting 1280 x 800 as the only current resolution, I'm fairly sure this is a bug in Sway / wlroots.

@beucismis
Copy link

beucismis commented Aug 16, 2022

You're welcome. I have an idea. I think it might have something to do with the Sway scale value. I am using the scale 0.8. I changed it and made it default (1.0). Debugging like this. And yes it worked as expected.

$ ./build/tofi-run --width=100%
[ real,   cpu,   maxRSS]
[0.000, 0.019,  5772 KB][DEBUG]: This is tofi.
[0.000, 0.019,  5772 KB][DEBUG]: Loading config file /home/beucismis/.config/tofi/config.
[0.001, 0.020,  5772 KB][DEBUG]: First roundtrip start.
[0.002, 0.020,  5772 KB][DEBUG]: 	Bound to shm 1.
[0.002, 0.020,  5772 KB][DEBUG]: 	Bound to compositor 4.
[0.002, 0.020,  5772 KB][DEBUG]: 	Bound to zwlr_layer_shell_v1 11.
[0.002, 0.020,  5772 KB][DEBUG]: 	Bound to seat 39.
[0.002, 0.021,  5772 KB][DEBUG]: 	Bound to output 41.
[0.002, 0.021,  5772 KB][DEBUG]: First roundtrip done.
[0.002, 0.021,  5772 KB][DEBUG]: Second roundtrip start.
[0.004, 0.021,  5772 KB][DEBUG]: 	Got keyboard from seat.
[0.005, 0.021,  5772 KB][DEBUG]: 	Got pointer from seat.
[0.005, 0.021,  5772 KB][DEBUG]: 	Output 0x559e9edb6940, Mode 1280 x 800, current? 1
[0.006, 0.021,  5772 KB][DEBUG]: 	Output configuration done.
[0.006, 0.021,  5772 KB][DEBUG]: Second roundtrip done.
[0.006, 0.021,  5772 KB][DEBUG]: Selected output LVDS-1.
[0.006, 0.021,  5772 KB][DEBUG]: Output size: 1280 x 800.
[0.006, 0.021,  5772 KB][DEBUG]: Desired window size: 100 x 20
[0.006, 0.021,  5772 KB][DEBUG]: Percentage?: 1, 0
[0.006, 0.021,  5772 KB][DEBUG]: Generating command list.
[0.006, 0.021,  5772 KB][DEBUG]: 	Retrieving PATH.
[0.006, 0.021,  5772 KB][DEBUG]: 	Retrieving cache location.
[0.007, 0.022,  5772 KB][DEBUG]: 	Cache up to date, loading.
[0.008, 0.023,  7500 KB][DEBUG]: 	Moving already known programs to the front.
[0.009, 0.024,  7500 KB][DEBUG]: Command list generated.
[0.010, 0.025,  7500 KB][DEBUG]: Creating main window surface.
[0.010, 0.025,  7500 KB][DEBUG]: Third roundtrip start.
[0.011, 0.025,  7500 KB][DEBUG]: 	Configuring keyboard.
[0.023, 0.037,  8312 KB][DEBUG]: 	Keyboard configured.
[0.023, 0.037,  8312 KB][DEBUG]: 	Key repeat every 40 ms after 600 ms.
[0.023, 0.037,  8312 KB][DEBUG]: 	Layer surface configure, 1280 x 20.
[0.023, 0.037,  8312 KB][DEBUG]: 	Layer surface configure, 1280 x 20.
[0.023, 0.038,  8312 KB][DEBUG]: Third roundtrip done.
[0.023, 0.038,  8312 KB][DEBUG]: Initialising window surface.
[0.024, 0.038,  8312 KB][DEBUG]: 	Created shm file with size 200 KiB.
[0.024, 0.038,  8312 KB][DEBUG]: Window surface initialised.
[0.024, 0.038,  8312 KB][DEBUG]: Initialising renderer.
[0.025, 0.039,  8312 KB][DEBUG]: 	Creating Pango context.
[0.025, 0.040,  9076 KB][DEBUG]: 	Creating Pango font description.
[0.026, 0.040,  9076 KB][DEBUG]: 	Initial text render.
[0.061, 0.080, 13044 KB][DEBUG]: 	Drew 19 results.
[0.061, 0.080, 13044 KB][DEBUG]: Renderer initialised.
[0.062, 0.080, 13044 KB][DEBUG]: Surface entered output.
[0.062, 0.080, 13044 KB][DEBUG]: Layer surface configure, 1280 x 20.

@philj56
Copy link
Owner

philj56 commented Aug 16, 2022

Ahhhh, that'd do it. There's no way (that I'm aware of) for an application to be aware of a fractional scale factor directly - all of the Wayland protocols (such as wl_output_scale) use integers for the scale factor. Sway achieves fractional scaling (I think) by passing the next largest integer to the application, then scaling it down.

As a workaround, you can pass --width 0 to tofi. This will leave the decision of how big to make the window up to Sway, so as long as you're anchored in the center of the screen horizontally, it'll do the right thing. I don't think there's any way to make it so that percentages <100% work with fractional scaling though.

I'll close this issue and open a new one with this info for anyone else who runs into it.

@philj56 philj56 closed this as completed Aug 16, 2022
@beucismis
Copy link

Thanks for everything. Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants