From: telephil9@gmail.com
To: 9front@9front.org
Subject: [9front] focus bug in libdraw program
Date: Wed, 14 Apr 2021 08:03:51 +0200 [thread overview]
Message-ID: <54D0DFB7C443777FB95F48DA583D5F84@gmail.com> (raw)
Hi,
I have noticed a strange behaviour in a libdraw program where mouse events are wrongfully retriggered when the window focus is "stolen" by another window because of an event.
To illustrate this, here is a test case (full code below):
- A window has a clickable area where a right-click plumbs a mail message. This opens a nedmail window so focus is no more on the main window.
- Hide our window through winwatch or the rio menu, you'll see the nedmail window open once again
- Unhide our window, nedmail window for the third time
This 2 last steps highlight the bug where our main window still receives event and the Mouse struct read from the Mousectl chan has coordinates inside our window whereas we're not there anymore.
I'll try to dig into this but I'm not quite sure, at this stage, where the issue might be. Any kind of help/hints would be appreciated.
--phil
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <mouse.h>
#include <keyboard.h>
#include <thread.h>
#include <plumb.h>
enum
{
Emouse,
Eresize,
Ekeyboard
};
Rectangle clickr;
void
redraw(void)
{
clickr = insetrect(screen->r, 20);
draw(screen, screen->r, display->white, nil, ZP);
border(screen, clickr, 1, display->black, ZP);
flushimage(display, 1);
}
void
plumbmsg(void)
{
int fd;
fd = plumbopen("send", OWRITE|OCEXEC);
if(fd<0)
return;
plumbsendtext(fd, "test", nil, nil, "/mail/fs/mbox/1");
close(fd);
}
void
threadmain(int argc, char *argv[])
{
USED(argc);
USED(argv);
Mousectl *mctl;
Keyboardctl *kctl;
Mouse m;
Rune k;
Alt alts[] = {
{ nil, &m, CHANRCV },
{ nil, nil, CHANRCV },
{ nil, &k, CHANRCV },
{ nil, nil, CHANEND },
};
if(initdraw(nil, nil, "test")<0)
sysfatal("initdraw: %r");
if((mctl = initmouse(nil, screen))==nil)
sysfatal("initmouse: %r");
if((kctl = initkeyboard(nil))==nil)
sysfatal("initkeyboard: %r");
alts[Emouse].c = mctl->c;
alts[Eresize].c = mctl->resizec;
alts[Ekeyboard].c = kctl->c;
redraw();
for(;;){
switch(alt(alts)){
case Emouse:
if(ptinrect(m.xy, clickr)){
if(m.buttons&4)
plumbmsg();
}
break;
case Eresize:
if(getwindow(display, Refnone)<0)
sysfatal("getwindow: %r");
redraw();
break;
case Ekeyboard:
if(k=='q' || k==Kdel)
threadexitsall(nil);
break;
}
}
}
next reply other threads:[~2021-04-14 6:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-14 6:03 telephil9 [this message]
2021-04-22 15:26 ` istvan bak
2021-04-24 11:17 ` cinap_lenrek
2021-04-25 17:25 ` istvan bak
2021-04-26 5:04 ` telephil9
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=54D0DFB7C443777FB95F48DA583D5F84@gmail.com \
--to=telephil9@gmail.com \
--cc=9front@9front.org \
/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 NNTP newsgroup(s).