public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "S.J. Luo" <sjaluo@gmail.com>
To: cygwin@cygwin.com
Subject: Re: Window flickering problem in XWin multiwindow mode
Date: Sat, 30 Apr 2022 09:40:06 +0800	[thread overview]
Message-ID: <CAMoHPCa9YQ7vbXwz+muscy_iBHNCrufqqD+UdypF+vvqvm==sA@mail.gmail.com> (raw)
In-Reply-To: <CAMoHPCaPjj-XyzRXc4yv1U5=1PXK_tASbEd5Caxi0dSPZA89og@mail.gmail.com>

SL on Apr 26, 2022:

> I have some EDA tools running on a Linux machine and display on my Windows
> PC using xorg-server-21.1.3 XWin multiwindow mode
> Sometimes the application window flickers forever for an unknown reason.
> The problem became more severe after my PC upgrade to Windows10.

> After re-compiling and debugging, I found a calling loop triggered.
> Knowing the root cause, I am now able to demonstrate the issue with a small
> test case as well as a patch that works for me. Both are attached below.

Any one successfully duplicated the issue?

I minor revised the test case so it won't silently go exit on wrong DISPLAY
setting and added some comment. The running steps:

    gcc -o flicker2 flicker2.c -lX11
    /usr/bin/XWin.exe :11 -ac -multiwindow &
    DISPLAY=:11 flicker2.exe

On running, you would see a window switching rapidly between max and normal
states and never stops.

The key of triggering the window flickering(or flashing) are these two lines:

  SetWindowMax(display, win, _NET_WM_STATE_ADD);
  SetWindowMax(display, win, _NET_WM_STATE_REMOVE);

where they just set the window to be maximized and go back to normal.
Removing either of the two, the test case would become normal.
I've tried this test case on 3PCs including Windows 7 and Windows 10
and in all cases the issue happens.

This issue literally occurs on my work that runs some proprietary Linux
EDA software. I wish this can be solved on next update.

SL


flicker2.c
===================================================================
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define _NET_WM_STATE_REMOVE        0
#define _NET_WM_STATE_ADD           1

void SetWindowMax(Display *dpy, Window win, int state)
{
    XEvent xev;
    Atom wm_state  =  XInternAtom(dpy, "_NET_WM_STATE", False);
    Atom max_horz  =  XInternAtom(dpy, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
    Atom max_vert  =  XInternAtom(dpy, "_NET_WM_STATE_MAXIMIZED_VERT", False);

    memset(&xev, 0, sizeof(xev));
    xev.type = ClientMessage;
    xev.xclient.window = win;
    xev.xclient.message_type = wm_state;
    xev.xclient.format = 32;
    xev.xclient.data.l[0] = state;
    xev.xclient.data.l[1] = max_horz;
    xev.xclient.data.l[2] = max_vert;

    XSendEvent(dpy, DefaultRootWindow(dpy), False,
               SubstructureNotifyMask, &xev);
}

int main(void) {
  Display *display;
  Window win;
  XEvent xev;
  int screen;

  if (!(display = XOpenDisplay(NULL))) {
    printf("Cannot open display. Please check DISPLAY environmet setting.\n");
    exit(1);
  }

  screen = DefaultScreen(display);
  win = XCreateSimpleWindow(display, RootWindow(display, screen),
        10, 10, 100, 100, 0,
        BlackPixel(display, screen), WhitePixel(display, screen));
  XMapWindow(display, win);

  // Uncomment either of the following two lines
  // and window would not go flashing
  SetWindowMax(display, win, _NET_WM_STATE_ADD);
  SetWindowMax(display, win, _NET_WM_STATE_REMOVE);

  while(1) {
    XNextEvent(display, &xev);
  }
  // It is supposed never get here
  XCloseDisplay(display);
  return 0;
}
===================================================================

  reply	other threads:[~2022-04-30  1:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-26  3:53 S.J. Luo
2022-04-30  1:40 ` S.J. Luo [this message]
2022-04-30  2:06   ` Mark Geisert
2022-04-30  3:58     ` Mark Geisert
2022-04-30 15:25 ` Jon Turney
     [not found]   ` <CAMoHPCZ18Q_G=JTwOwu2ij3feJ6cd9CHxddONuProrL3kwgBKw@mail.gmail.com>
2022-05-07  2:01     ` S.J. Luo
2022-08-14 11:08       ` Jon Turney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMoHPCa9YQ7vbXwz+muscy_iBHNCrufqqD+UdypF+vvqvm==sA@mail.gmail.com' \
    --to=sjaluo@gmail.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).