Bug 497192 - Mode selection popup cut off
Summary: Mode selection popup cut off
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (other bugs)
Version First Reported In: 24.08.3
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-08 08:24 UTC by Grósz Dániel
Modified: 2025-11-19 18:37 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Screenshot (29.49 KB, image/png)
2024-12-08 08:26 UTC, Grósz Dániel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Grósz Dániel 2024-12-08 08:24:56 UTC
SUMMARY
In either Kate or KWrite, when opening the mode (syntax highlighting etc.) selection popup for the first time for a given document, only a small portion in its top left corner is visible (see screenshot). After opening it a second time, it's visible as normally.
(I use a non-default style, but it happens with Breeze too.)

STEPS TO REPRODUCE
1. Create a new file, or open a file.
2. Click the mode button at the right end of the status bar.

OBSERVED RESULT
Only a small portion of the popup visible.

EXPECTED RESULT
The whole popup visible.

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20241206
KDE Plasma Version: 6.2.4
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.1
Kernel Version: 6.11.8-1-default (64-bit)
Graphics Platform: X11

ADDITIONAL INFORMATION
It's been happening for quite a while. Maybe since the Qt 6 transition?
Comment 1 Grósz Dániel 2024-12-08 08:26:51 UTC
Created attachment 176432 [details]
Screenshot
Comment 2 Christoph Cullmann 2024-12-08 16:37:59 UTC
Can reproduce that.
Comment 3 Christoph Cullmann 2024-12-08 16:49:26 UTC
For me only happens on X11.
Comment 4 Christoph Cullmann 2024-12-08 17:24:23 UTC
And there for me only on the second screen, not the first.
Comment 5 Christoph Cullmann 2024-12-08 17:27:49 UTC
This code part induces the problem:

 // Set the menu position
    if (m_pushButton && m_pushButton->isVisible()) {
        /*
         * Get vertical position.
         * NOTE: In KDE Plasma with Wayland, the reference point of the position
         * is the main window, not the desktop. Therefore, if the window is vertically
         * smaller than the menu, it will be positioned on the upper edge of the window.
         */
        int newMenu_y; // New vertical menu position
        if (m_positionY == AlignTop) {
            newMenu_y = m_pushButton->mapToGlobal(QPoint(0, 0)).y() - geometry().height();
            if (newMenu_y < 0) {
                newMenu_y = 0;
            }
        } else {
            newMenu_y = pos().y();
        }

        // Set horizontal position.
        if (m_positionX == AlignRight) {
            // New horizontal menu position
            int newMenu_x = pos().x() - geometry().width() + m_pushButton->geometry().width();
            // Get position of the right edge of the toggle button
            const int buttonPositionRight = m_pushButton->mapToGlobal(QPoint(0, 0)).x() + m_pushButton->geometry().width();
            if (newMenu_x < 0) {
                newMenu_x = 0;
            } else if (newMenu_x + geometry().width() < buttonPositionRight) {
                newMenu_x = buttonPositionRight - geometry().width();
            }
            move(newMenu_x, newMenu_y);
        } else if (m_positionX == AlignLeft) {
            move(m_pushButton->mapToGlobal(QPoint(0, 0)).x(), newMenu_y);
        } else if (m_positionY == AlignTop) {
            // Set vertical position, use the default horizontal position
            move(pos().x(), newMenu_y);
        }
    }
Comment 6 Grósz Dániel 2024-12-09 00:45:03 UTC
(In reply to Christoph Cullmann from comment #4)
> And there for me only on the second screen, not the first.

Yes, I use X11, and it only happens on the second screen for me too, with the second screen arranged to the right of the primary one.
Comment 7 Waqar Ahmed 2024-12-09 07:48:14 UTC
Can reproduce as well. Debugged this a little bit. 

- reproducible with our minimal example in ktexteditor if the window is not maximized
- The mode menu is lazy init, changing it to init early didn't fix it
- If you look at the cut off menu window, it seems to have a square corner which is weird. 

I think this might be a bug somewhere lower in the stack.
Comment 8 Grósz Dániel 2024-12-09 08:24:42 UTC
I can indeed only reproduce it if the window is not maximized, and only in KWrite, not Kate. I *think* I've had it occur in Kate (which I use more, and generally with a maximized window), but I'm not sure.
Comment 9 Waqar Ahmed 2025-08-28 14:25:42 UTC
can not reproduce this anymore, can  you?
Comment 10 Grósz Dániel 2025-08-28 15:04:58 UTC
I can reproduce it in KWrite 25.08.0, non-maximized window, X11, on the right-most screen of two screens (laptop screen on the left, external monitor on the right, the latter one is the primary). I can reproduce it in Kate 25.08.0 too, under the same conditions. It doesn't happen on the screen on the left, or in a maximized window.

Operating System: openSUSE Tumbleweed 20250825
KDE Plasma Version: 6.4.4
KDE Frameworks Version: 6.17.0
Qt Version: 6.9.1
Kernel Version: 6.14.6-1-default (64-bit)
Graphics Platform: X11
Comment 11 Bug Janitor Service 2025-11-16 17:10:33 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/851
Comment 12 Christoph Cullmann 2025-11-16 18:13:55 UTC
Grósz Dániel - can you try my patch?
Comment 13 Christoph Cullmann 2025-11-19 18:37:26 UTC
Git commit 6c0b8406a90a4bff8d3b9274ffcd939b28335537 by Christoph Cullmann.
Committed on 19/11/2025 at 18:31.
Pushed by cullmann into branch 'master'.

ensure proper size of mode selection 'dialog' on first show

fixes position issues on Wayland, too

avoid to use showEvent, move logic to aboutToShow handler

M  +188  -193  src/mode/katemodemenulist.cpp
M  +0    -6    src/mode/katemodemenulist.h

https://invent.kde.org/frameworks/ktexteditor/-/commit/6c0b8406a90a4bff8d3b9274ffcd939b28335537