From: Akihiko Odaki <akihiko.odaki@gmail.com>
To: gustavo@noronha.eti.br, qemu-devel@nongnu.org
Cc: 'Peter Maydell ' <peter.maydell@linaro.org>,
'Markus Armbruster ' <armbru@redhat.com>,
'Gerd Hoffmann ' <kraxel@redhat.com>
Subject: Re: [PATCH v3 1/2] ui/cocoa: capture all keys and combos when mouse is grabbed
Date: Tue, 11 May 2021 12:08:46 +0900 [thread overview]
Message-ID: <12f86bf7-8059-eea7-a03c-1ac1abfd4ab8@gmail.com> (raw)
In-Reply-To: <20210504233232.28423-2-gustavo@noronha.eti.br>
On 2021/05/05 8:32, gustavo@noronha.eti.br wrote:> @@ -344,6 +361,32 @@
- (id)initWithFrame:(NSRect)frameRect
> kbd = qkbd_state_init(dcl.con);
>
> }
> +
> + CGEventMask mask = CGEventMaskBit(kCGEventKeyDown) | CGEventMaskBit(kCGEventKeyUp) | CGEventMaskBit(kCGEventFlagsChanged);
> + eventsTap = CGEventTapCreate(kCGHIDEventTap, kCGHeadInsertEventTap, kCGEventTapOptionDefault,
> + mask, handleTapEvent, self);
> + if (!eventsTap) {
> + warn_report("Could not create event tap, system key combos will not be captured.\n");
> + return self;
> + } else {
> + COCOA_DEBUG("Global events tap created! Will capture system key combos.\n");
> + }
> +
> + CFRunLoopRef runLoop = CFRunLoopGetCurrent();
> + if (!runLoop) {
> + warn_report("Could not obtain current CF RunLoop, system key combos will not be captured.\n");
> + return self;
> + }
> +
> + CFRunLoopSourceRef tapEventsSrc = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventsTap, 0);
> + if (!tapEventsSrc ) {
> + warn_report("Could not obtain current CF RunLoop, system key combos will not be captured.\n");
> + return self;
> + }
> +
> + CFRunLoopAddSource(runLoop, tapEventsSrc, kCFRunLoopDefaultMode);
> + CFRelease(tapEventsSrc);
> +
> return self;
> }
>
These statements should be in "if (self)" block which they follow, or it
may rely on "self" even if it failed to allocate and initialize "self".
Regards,
Akihiko Odaki
next prev parent reply other threads:[~2021-05-11 3:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-04 23:32 [PATCH v3 0/2] cocoa: keyboard quality of life gustavo
2021-05-04 23:32 ` [PATCH v3 1/2] ui/cocoa: capture all keys and combos when mouse is grabbed gustavo
2021-05-10 9:56 ` 'Gerd Hoffmann '
2021-05-11 3:08 ` Akihiko Odaki [this message]
2021-05-11 17:44 ` Gustavo Noronha Silva
2021-05-04 23:32 ` [PATCH v3 2/2] ui/cocoa: add option to swap Option and Command, enable by default gustavo
2021-05-10 9:59 ` 'Gerd Hoffmann '
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=12f86bf7-8059-eea7-a03c-1ac1abfd4ab8@gmail.com \
--to=akihiko.odaki@gmail.com \
--cc=armbru@redhat.com \
--cc=gustavo@noronha.eti.br \
--cc=kraxel@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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).