rofi icon indicating copy to clipboard operation
rofi copied to clipboard

Rofi changes size when entering text, even when number of rows is the same

Open marcoms opened this issue 7 years ago • 30 comments

Version

Output of rofi -v

Version: 1.5.1

Configuration

Output of rofi -help (in a gist)

Launch Command

The commandline used to launch rofi

rofi -modi drun -show drun -normal-window

Steps to reproduce

  • Type a single character

What behaviour you see

  • The bottom padding decreases by a visible amount
  • Deleting the single character doesn't return the original padding

What behaviour you expect to see

  • The padding/size should stay the same

Seems to only occur with -normal-window, which I use to get rofi to run on the correct monitor. I'm using sway 1.0-rc3

marcoms avatar Feb 25 '19 19:02 marcoms

sway is a tiling window manager right? with normal-window it should be treated as a tiled window.. It should not change size then.

On i3 with X11 I cannot reproduce this (normal-window, normal-window floating). Can you make a quick screencast so I can see what happens?

DaveDavenport avatar Feb 25 '19 20:02 DaveDavenport

Sorry, I forgot to mention I have a line in my sway config that enables floating behavior for rofi. Heres an example:

ezgif-4-a354cd676bca

Excuse the bad video recording - AFAIK there's no good way to screenrecord on sway :(

marcoms avatar Feb 25 '19 20:02 marcoms

The only way I can see this happens if the font information is not correct, the initial size is determined by getting the font ascent and descent information. Once rendered and updated it uses the information of the actual rendering. If this does not match, it could happen.

Have not been able to reproduce, what font do you use? (can you pastebin your theme? rofi -dump-theme)

DaveDavenport avatar Mar 04 '19 16:03 DaveDavenport

/**
 * rofi -dump-theme output.
 * Rofi version: 1.5.1
 **/
* {
    selected-normal-foreground:  @lightbg;
    foreground:                  rgba ( 0, 43, 54, 100 % );
    normal-foreground:           @foreground;
    alternate-normal-background: @lightbg;
    red:                         rgba ( 220, 50, 47, 100 % );
    selected-urgent-foreground:  @background;
    blue:                        rgba ( 38, 139, 210, 100 % );
    urgent-foreground:           @red;
    alternate-urgent-background: @lightbg;
    active-foreground:           @blue;
    lightbg:                     rgba ( 238, 232, 213, 100 % );
    selected-active-foreground:  @background;
    alternate-active-background: @lightbg;
    background:                  rgba ( 253, 246, 227, 100 % );
    alternate-normal-foreground: @foreground;
    normal-background:           @background;
    lightfg:                     rgba ( 88, 104, 117, 100 % );
    selected-normal-background:  @lightfg;
    border-color:                @foreground;
    spacing:                     2;
    separatorcolor:              @foreground;
    urgent-background:           @background;
    selected-urgent-background:  @red;
    alternate-urgent-foreground: @red;
    background-color:            rgba ( 0, 0, 0, 0 % );
    alternate-active-foreground: @blue;
    active-background:           @background;
    selected-active-background:  @blue;
}
window {
    background-color: @background;
    border:           1;
    padding:          5;
}
mainbox {
    border:  0;
    padding: 0;
}
message {
    border:       2px dash 0px 0px ;
    border-color: @separatorcolor;
    padding:      1px ;
}
textbox {
    text-color: @foreground;
}
listview {
    fixed-height: 0;
    border:       2px dash 0px 0px ;
    border-color: @separatorcolor;
    spacing:      2px ;
    scrollbar:    true;
    padding:      2px 0px 0px ;
}
element {
    border:  0;
    padding: 1px ;
}
element normal.normal {
    background-color: @normal-background;
    text-color:       @normal-foreground;
}
element normal.urgent {
    background-color: @urgent-background;
    text-color:       @urgent-foreground;
}
element normal.active {
    background-color: @active-background;
    text-color:       @active-foreground;
}
element selected.normal {
    background-color: @selected-normal-background;
    text-color:       @selected-normal-foreground;
}
element selected.urgent {
    background-color: @selected-urgent-background;
    text-color:       @selected-urgent-foreground;
}
element selected.active {
    background-color: @selected-active-background;
    text-color:       @selected-active-foreground;
}
element alternate.normal {
    background-color: @alternate-normal-background;
    text-color:       @alternate-normal-foreground;
}
element alternate.urgent {
    background-color: @alternate-urgent-background;
    text-color:       @alternate-urgent-foreground;
}
element alternate.active {
    background-color: @alternate-active-background;
    text-color:       @alternate-active-foreground;
}
scrollbar {
    width:        4px ;
    border:       0;
    handle-color: @normal-foreground;
    handle-width: 8px ;
    padding:      0;
}
sidebar {
    border:       2px dash 0px 0px ;
    border-color: @separatorcolor;
}
button {
    spacing:    0;
    text-color: @normal-foreground;
}
button selected {
    background-color: @selected-normal-background;
    text-color:       @selected-normal-foreground;
}
inputbar {
    spacing:    0px ;
    text-color: @normal-foreground;
    padding:    1px ;
    children:   [ prompt,textbox-prompt-colon,entry,case-indicator ];
}
case-indicator {
    spacing:    0;
    text-color: @normal-foreground;
}
entry {
    spacing:    0;
    text-color: @normal-foreground;
}
prompt {
    spacing:    0;
    text-color: @normal-foreground;
}
textbox-prompt-colon {
    expand:     false;
    str:        ":";
    margin:     0px 0.3000em 0.0000em 0.0000em ;
    text-color: inherit;
}

I believe this is the stock theme. I can reproduce with the default monospace font or with -font "Ubuntu 14", however I can only do so on sway (-normal-window passed to rofi and for_window [class="Rofi"] floating_enable in sway config). Other sessions such as i3 and GNOME Wayland seem fine.

marcoms avatar Mar 12 '19 20:03 marcoms

I will leave the issue open. Patches welcome, but given I don use wayland and sway nor have any intention too, it is hard for me to debug what is going wrong.

DaveDavenport avatar Mar 14 '19 14:03 DaveDavenport

I have the same issue on i3wm only when using non monospace font. With monospace font all is well.

behollder avatar Mar 14 '20 10:03 behollder

can you provide some information? version, config+theme? (work and fail) I have not been able to reproduce this.

DaveDavenport avatar Mar 14 '20 10:03 DaveDavenport

@DaveDavenport

Rofi Version: 1.5.4

Now I testing different configs and what I see, this issue appears when I changed size of font not font type. Different size of different fonts cause to this issue.

I have issue with FontAwesome any size (and size of rofi window changes on top and bottom) Ubuntu 10 and 14 DeJavu Sans 10 and 14 DeJavu Sans Mono 10 and 14

ezgif com-video-to-gif

Config
configuration {
    /*	modi: "window,run,ssh";*/
    width: 50;
    lines: 8;
    columns: 2;
    font: "FontAwesome 13";
    bw: 0;
    location: 0;
    /* padding: 20; */
    /*	yoffset: 0;*/
    /*	xoffset: 0;*/
    /*	fixed-num-lines: true;*/
    /*	show-icons: false;*/
    /*	terminal: "rofi-sensible-terminal";*/
    /*	ssh-client: "ssh";*/
    /*	ssh-command: "{terminal} -e {ssh-client} {host}";*/
    /*	run-command: "{cmd}";*/
    /*	run-list-command: "";*/
    /*	run-shell-command: "{terminal} -e {cmd}";*/
    /*	window-command: "xkill -id {window}";*/
    /*	window-match-fields: "all";*/
    /*	drun-icon-theme: ;*/
    /* drun-match-fields: "name,generic,exec,categories"; */
    drun-match-fields: "name,generic,exec";
    /*	disable-history: false;*/
    /*	sort: false;*/
    levenshtein-sort: true;
    case-sensitive: false;
    /*	cycle: true;*/
    /*	sidebar-mode: false;*/
    /*	eh: 1;*/
    /*	auto-select: false;*/
    /*	parse-hosts: false;*/
    /*	parse-known-hosts: true;*/
    /*	combi-modi: "window,run";*/
    matching: "normal";
    /*	tokenize: true;*/
    /*	m: "-5";*/
    /* line-margin: 5; */
    /* line-padding: 5; */
    /*	filter: ;*/
    separator-style: "none";
    hide-scrollbar: true;
    /*	fullscreen: false;*/
    /*	fake-transparency: false;*/
    /*	dpi: -1;*/
    /*	threads: 0;*/
    scrollbar-width: 8;
    /*	scroll-method: 0;*/
    /*	fake-background: "screenshot";*/
    /*	window-format: "{w}    {i}{c}   {t}";*/
    click-to-exit: true;
    show-match: false;
    /*	theme: ;*/
    color-normal: "#ff393939, #ffffffff, #00393939, #aa268bd2, #ffffffff";
    color-urgent: "#aa393939, #aaf3843d, #00393939, #aa268bd2, #aaffc39c";
    color-active: "#aa393939, #aa268bd2, #00393939, #aa268bd2, #aa205171";
    color-window: "#aa393939, #00393939, #00393939";
    /*	max-history-size: 25;*/
    /*	combi-hide-mode-prefix: false;*/
    /*	pid: "/run/user/1000/rofi.pid";*/
    /*	display-window: ;*/
    /*	display-windowcd: ;*/
    display-run: "";
    /*	display-ssh: ;*/
    display-drun: "";
    /*	display-combi: ;*/
    /*	display-keys: ;*/
    /*	kb-primary-paste: "Control+V,Shift+Insert";*/
    /*	kb-secondary-paste: "Control+v,Insert";*/
    /*	kb-clear-line: "Control+w";*/
    /*	kb-move-front: "Control+a";*/
    /*	kb-move-end: "Control+e";*/
    /*	kb-move-word-back: "Alt+b";*/
    /*	kb-move-word-forward: "Alt+f";*/
    /*	kb-move-char-back: "Left,Control+b";*/
    /*	kb-move-char-forward: "Right,Control+f";*/
    /*	kb-remove-word-back: "Control+Alt+h,Control+BackSpace";*/
    /*	kb-remove-word-forward: "Control+Alt+d";*/
    /*	kb-remove-char-forward: "Delete,Control+d";*/
    /*	kb-remove-char-back: "BackSpace,Control+h";*/
    /*	kb-remove-to-eol: "Control+k";*/
    /*	kb-remove-to-sol: "Control+u";*/
    /*	kb-accept-entry: "Control+j,Control+m,Return,KP_Enter";*/
    /*	kb-accept-custom: "Control+Return";*/
    /*	kb-accept-alt: "Shift+Return";*/
    /*	kb-delete-entry: "Shift+Delete";*/
    /*	kb-mode-next: "Shift+Right,Control+Tab";*/
    /*	kb-mode-previous: "Shift+Left,Control+ISO_Left_Tab";*/
    /*	kb-row-left: "Control+Page_Up";*/
    /*	kb-row-right: "Control+Page_Down";*/
    /*	kb-row-up: "Up,Control+p,ISO_Left_Tab";*/
    /*	kb-row-down: "Down,Control+n";*/
    /*	kb-row-tab: "Tab";*/
    /*	kb-page-prev: "Page_Up";*/
    /*	kb-page-next: "Page_Down";*/
    /*	kb-row-first: "Home,KP_Home";*/
    /*	kb-row-last: "End,KP_End";*/
    /*	kb-row-select: "Control+space";*/
    /*	kb-screenshot: "Alt+S";*/
    /*	kb-toggle-case-sensitivity: "grave,dead_grave";*/
    /*	kb-toggle-sort: "Alt+grave";*/
    /*	kb-cancel: "Escape,Control+g,Control+bracketleft";*/
    /*	kb-custom-1: "Alt+1";*/
    /*	kb-custom-2: "Alt+2";*/
    /*	kb-custom-3: "Alt+3";*/
    /*	kb-custom-4: "Alt+4";*/
    /*	kb-custom-5: "Alt+5";*/
    /*	kb-custom-6: "Alt+6";*/
    /*	kb-custom-7: "Alt+7";*/
    /*	kb-custom-8: "Alt+8";*/
    /*	kb-custom-9: "Alt+9";*/
    /*	kb-custom-10: "Alt+0";*/
    /*	kb-custom-11: "Alt+exclam";*/
    /*	kb-custom-12: "Alt+at";*/
    /*	kb-custom-13: "Alt+numbersign";*/
    /*	kb-custom-14: "Alt+dollar";*/
    /*	kb-custom-15: "Alt+percent";*/
    /*	kb-custom-16: "Alt+dead_circumflex";*/
    /*	kb-custom-17: "Alt+ampersand";*/
    /*	kb-custom-18: "Alt+asterisk";*/
    /*	kb-custom-19: "Alt+parenleft";*/
    /*	kb-select-1: "Super+1";*/
    /*	kb-select-2: "Super+2";*/
    /*	kb-select-3: "Super+3";*/
    /*	kb-select-4: "Super+4";*/
    /*	kb-select-5: "Super+5";*/
    /*	kb-select-6: "Super+6";*/
    /*	kb-select-7: "Super+7";*/
    /*	kb-select-8: "Super+8";*/
    /*	kb-select-9: "Super+9";*/
    /*	kb-select-10: "Super+0";*/
    /*	ml-row-left: "ScrollLeft";*/
    /*	ml-row-right: "ScrollRight";*/
    /*	ml-row-up: "ScrollUp";*/
    /*	ml-row-down: "ScrollDown";*/
    me-select-entry: "MouseDPrimary";
    me-accept-entry: "MousePrimary";
    /*	me-accept-custom: "Control+MouseDPrimary";*/
}
/* "~/Pictures/Wallpapers/girl_silhouette_moon_122062_1920x1080.jpg" */
* {
    text-color:            White;
    /* font:            "FontAwesome 12"; */
    background-color: transparent;
}
#window {
    /* y-offset: 40px; */
    anchor:     center;
    location:   center;
    width:      1000px;
    padding:    20px;

    /* fullscreen: true; */
    children:   [ horibox ];
    transparency: "real";
    background-color: rgba(127,127,127,0.4);


    /* border: 10px; */
    /* border-radius: 10; */
    /* border-color: rgba(127,127,127,0.1); */
}

#horibox {
    orientation: vertical;
    children:   [ entry, listview ];

}

#listview {
    layout:     vertical;
    spacing:    10px;
}

#entry {
    expand:     false;
    width:      10em;
    margin: 5px;

    background-color: rgba(0,0,0,0);
}

#element {
    padding: 2px 2px;
    /* background-color: rgba(0,0,0,0.1); */
    border-radius: 50px;

}
#element selected {
    background-color: rgba(0,122,255, 1.0);
}

behollder avatar Mar 14 '20 11:03 behollder

Frustratingly, still cannot reproduce here with that theme and the mentioned fonts.

Can you take screenshot with this added to theme:

* {
        border: 1px;
        border-color: red;
}

for the 2 cases (like in gif). so I can see a bit where it sizes.

(what distro are you on? can you see what dpi you are running at ? (rofi --help shows it)

DaveDavenport avatar Mar 14 '20 11:03 DaveDavenport

If it will be helpfull 2020-03-14-135447_722x434_scrot

ezgif com-video-to-gif(1)

behollder avatar Mar 14 '20 11:03 behollder

So pango is reporting different height a rendered empty and full string on your system.. fun. 2px difference.

DaveDavenport avatar Mar 14 '20 11:03 DaveDavenport

Can you try this patch against git?

diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c
index aa299113..187fa5f8 100644
--- a/source/widgets/textbox.c
+++ b/source/widgets/textbox.c
@@ -852,7 +852,8 @@ int _textbox_get_height ( widget *wid )
 {
     textbox *tb = (textbox *) wid;
     if ( tb->flags & TB_AUTOHEIGHT ) {
-        return textbox_get_height ( tb );
+           return textbox_get_estimated_height(tb, 1);
+//        return textbox_get_height ( tb );
     }
     return tb->widget.h;
 }

(this will break some other stuff, so no fix, just for diagnosis).

DaveDavenport avatar Mar 14 '20 12:03 DaveDavenport

@DaveDavenport nothing visual changed

behollder avatar Mar 14 '20 13:03 behollder

hmm yeah, forgot one..

diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c
index aa299113..e867e60b 100644
--- a/source/widgets/textbox.c
+++ b/source/widgets/textbox.c
@@ -97,7 +97,8 @@ static int textbox_get_desired_height ( widget *wid )
     if ( tb->changed ) {
         __textbox_update_pango_text ( tb );
     }
-    int height = textbox_get_height ( tb );
+    int height = textbox_get_estimated_height(tb, 1);
+//textbox_get_height ( tb );
     return height;
 }
 
@@ -852,7 +853,8 @@ int _textbox_get_height ( widget *wid )
 {
     textbox *tb = (textbox *) wid;
     if ( tb->flags & TB_AUTOHEIGHT ) {
-        return textbox_get_height ( tb );
+           return textbox_get_estimated_height(tb, 1);
+//        return textbox_get_height ( tb );
     }
     return tb->widget.h;
 }

but I need to find a way to reproduce.. What distro/version are you on?

DaveDavenport avatar Mar 14 '20 15:03 DaveDavenport

Yes, it's works.

My setup: OS: Manjaro 19.0.2 Kyria Kernel: x86_64 Linux 5.5.7-1-MANJARO WM: i3

behollder avatar Mar 14 '20 15:03 behollder

I wonder why the font library behaves differently.

DaveDavenport avatar Mar 14 '20 16:03 DaveDavenport

can you test last commit?

DaveDavenport avatar Mar 29 '20 14:03 DaveDavenport

can you test last commit?

works, but last row not visible (in config I have 8 rows) 2020-03-30-135000_1920x1080_scrot

behollder avatar Mar 30 '20 10:03 behollder

Interesting issue.

DaveDavenport avatar Mar 30 '20 10:03 DaveDavenport

Can you share theme? I cannot reproduce with themes here.

DaveDavenport avatar Mar 30 '20 10:03 DaveDavenport