https://bugs.kde.org/show_bug.cgi?id=474502

            Bug ID: 474502
           Summary: Multi monitor window position clipping error
    Classification: Plasma
           Product: plasmashell
           Version: 5.27.4
          Platform: Ubuntu
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: Desktop Containment
          Assignee: plasma-b...@kde.org
          Reporter: john.wayne.corn...@gmail.com
                CC: notm...@gmail.com
  Target Milestone: 1.0

SUMMARY
***
When programatically setting window size and position of a window on a monitor
that does not show a Panel the area is clipped as though a Panel were present
and if the main panel is on the bottom of the primary monitor the window is
moved upwards so that the title bar is off screen. 
***


STEPS TO REPRODUCE
1.  Save the following code to myapp.c

#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <X11/Xlib.h>

static void on_button_clicked(GtkWidget *button, gpointer user_data) {
    GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window), "Test Window");
    gtk_window_set_default_size(GTK_WINDOW(window), 400, 300);

    gtk_widget_show_all(window);

    // Maximize the window
    gtk_window_maximize(GTK_WINDOW(window));

    // Allow the window to actually maximize before retrieving its size and
position
    while (gtk_events_pending())
        gtk_main_iteration();

     // Using X11 to retrieve the geometry
    GdkWindow *gdkwindow = gtk_widget_get_window(window);
    Window xwindow = GDK_WINDOW_XID(gdkwindow);

    Display *display = XOpenDisplay(NULL);
    if (!display) {
        g_printerr("Failed to open X display\n");
        return;
    }

    sleep(1);

    int x, y;
    Window child;
    unsigned int width, height, border_width, depth;
    Window root_return;

    XGetGeometry(display, xwindow, &root_return, &x, &y, &width, &height,
&border_width, &depth);

    XTranslateCoordinates(display, xwindow,
XRootWindowOfScreen(XDefaultScreenOfDisplay(display)),
                      x, y, &x, &y, &child);
    g_print("Window geometry: x=%d, y=%d, width=%u, height=%u\n", x, y, width,
height);

    gtk_window_unmaximize(GTK_WINDOW(window));
    while (gtk_events_pending())
        gtk_main_iteration();

    // Set the size and position

    XMoveResizeWindow(display, xwindow, x, y, width, height);
    XSync(display, FALSE);

    while (gtk_events_pending())
        gtk_main_iteration();

    XGetGeometry(display, xwindow, &root_return, &x, &y, &width, &height,
&border_width, &depth);

    XTranslateCoordinates(display, xwindow,
XRootWindowOfScreen(XDefaultScreenOfDisplay(display)),
                      x, y, &x, &y, &child);
    g_print("Window geometry: x=%d, y=%d, width=%u, height=%u\n", x, y, width,
height);

    XCloseDisplay(display);
}

int main(int argc, char *argv[]) {
    gtk_init(&argc, &argv);

    GtkWidget *main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(main_window), "Main Window");
    gtk_window_set_default_size(GTK_WINDOW(main_window), 200, 100);
    g_signal_connect(main_window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

    GtkWidget *button = gtk_button_new_with_label("Create Window");
    g_signal_connect(button, "clicked", G_CALLBACK(on_button_clicked), NULL);
    gtk_container_add(GTK_CONTAINER(main_window), button);

    gtk_widget_show_all(main_window);
    gtk_main();

    return 0;
}


2. Compile
gcc `pkg-config --cflags gtk+-3.0` -o myapp myapp.c `pkg-config --libs
gtk+-3.0` -lX11

3.  execute
./myapp

4 Move the window to a monitor on which the panel is parallel top or bottom in
desktop coordinates.
5 Press the button

OBSERVED RESULT
the window size and position taken from the maximized position for the second
monitor are cropped where the Panel would be displayed. Pushing up if the Panel
would be at the bottom or cropping and moving down if the Panel would be at the
top.

EXPECTED RESULT
A Window positioned and sized to the maximized position and size. 

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
Operating System: Ubuntu Studio 23.04
KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.104.0
Qt Version: 5.15.8
Kernel Version: 6.2.0-1012-lowlatency (64-bit)
Graphics Platform: X11
Processors: 8 × AMD FX(tm)-8300 Eight-Core Processor
Memory: 31.2 GiB of RAM
Graphics Processor: NVIDIA RTX A5000/PCIe/SSE2

ADDITIONAL INFORMATION
This error prevents utility functions from being able to properly position
windows across runs on a secondary display. It definitely isn't an X11 problem
or windows could not be maximized correctly. In short when the Panel is
parallel in desktop coordinates the window rect is clipped as though the panel
is displayed on every monitor

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to