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

            Bug ID: 431133
           Summary: XKeyboardUngrab generated FocusOut event improperly
                    handled
           Product: kwin
           Version: 5.20.4
          Platform: Debian testing
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: platform-x11-standalone
          Assignee: kwin-bugs-n...@kde.org
          Reporter: ge...@hostfission.com
  Target Milestone: ---

When an application calls XKeyboardUngrab as per the X11 specifications, a
`FocusOut` event is generated with the mode set to `NotifyUngrab`. kwin
incorrectly processes this event and unhighlights the application caption bar
as well as the icon on the task bar.

STEPS TO REPRODUCE
1. Compile the following application using:

gcc reproduce.c -L/usr/X11R6/lib -lX11 -o reproduce


#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int main(void) {
   Display *d;
   Window w;
   XEvent e;
   const char *msg = "Hello, World!";
   int s;
   bool toggle = false;

   d = XOpenDisplay(NULL);
   if (d == NULL) {
      fprintf(stderr, "Cannot open display\n");
      exit(1);
   }

   s = DefaultScreen(d);
   w = XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 100, 100, 1,
                           BlackPixel(d, s), WhitePixel(d, s));
   XSelectInput(d, w, ExposureMask | KeyPressMask);
   XMapWindow(d, w);

   while (1) {
      XNextEvent(d, &e);
      if (e.type == Expose) {
         XFillRectangle(d, w, DefaultGC(d, s), 20, 20, 10, 10);
         XDrawString(d, w, DefaultGC(d, s), 10, 50, msg, strlen(msg));
      }
      if (e.type == KeyPress)
      {
        toggle = !toggle;
        if (toggle)
          XGrabKeyboard(
            d,
            w,
            true,
            GrabModeAsync,
            GrabModeAsync,
            CurrentTime);
        else
          XUngrabKeyboard(d, CurrentTime);
      }
   }

   XCloseDisplay(d);
   return 0;
}

2. Run the resulting application
3. Press any key on the keyboard to toggle the keyboard grab/ungrab

OBSERVED RESULT

The application shows that it has lost focus and the taskbar panel, and in the
case of a full-screen application the taskbar will overlap the application.

EXPECTED RESULT

The application to show it still has focus and the taskbar panel to remain
behind the application.

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

Reply via email to