~eliasnaur/gio-patches

gio: app/internal/wm: [macOS] run closure on main thread earlier if possible v1 PROPOSED

~pierrec
~pierrec: 1
 app/internal/wm: [macOS] run closure on main thread earlier if possible

 2 files changed, 9 insertions(+), 0 deletions(-)
#475618 apple.yml success
#475619 freebsd.yml success
#475620 linux.yml success
#475621 openbsd.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~eliasnaur/gio-patches/patches/21747/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH gio] app/internal/wm: [macOS] run closure on main thread earlier if possible Export this patch

~pierrec
From: pierre <pierre.curto@gmail.com>

Signed-off-by: pierre <pierre.curto@gmail.com>
---
-

 app/internal/wm/os_darwin.go | 5 +++++
 app/internal/wm/os_darwin.m  | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/app/internal/wm/os_darwin.go b/app/internal/wm/os_darwin.go
index d804c9cf..1b6c6a3a 100644
--- a/app/internal/wm/os_darwin.go
+++ b/app/internal/wm/os_darwin.go
@@ -16,6 +16,7 @@ __attribute__ ((visibility ("hidden"))) void gio_setDisplayLinkDisplay(CFTypeRef
__attribute__ ((visibility ("hidden"))) void gio_hideCursor();
__attribute__ ((visibility ("hidden"))) void gio_showCursor();
__attribute__ ((visibility ("hidden"))) void gio_setCursor(NSUInteger curID);
__attribute__ ((visibility ("hidden"))) bool gio_isMainThread();
*/
import "C"
import (
@@ -55,6 +56,10 @@ var mainFuncs = make(chan func(), 1)

// runOnMain runs the function on the main thread.
func runOnMain(f func()) {
	if C.gio_isMainThread() {
		f()
		return
	}
	go func() {
		mainFuncs <- f
		C.gio_wakeupMainThread()
diff --git a/app/internal/wm/os_darwin.m b/app/internal/wm/os_darwin.m
index dc4f00b7..7c57266b 100644
--- a/app/internal/wm/os_darwin.m
+++ b/app/internal/wm/os_darwin.m
@@ -11,6 +11,10 @@ void gio_wakeupMainThread(void) {
	});
}

bool gio_isMainThread() {
  return [NSThread isMainThread];
}

NSUInteger gio_nsstringLength(CFTypeRef cstr) {
	NSString *str = (__bridge NSString *)cstr;
	return [str length];
-- 
2.30.2
builds.sr.ht
gio/patches: SUCCESS in 22m51s

[app/internal/wm: [macOS] run closure on main thread earlier if possible][0] from [~pierrec][1]

[0]: https://lists.sr.ht/~eliasnaur/gio-patches/patches/21747
[1]: mailto:pierre.curto@gmail.com

✓ #475620 SUCCESS gio/patches/linux.yml   https://builds.sr.ht/~eliasnaur/job/475620
✓ #475619 SUCCESS gio/patches/freebsd.yml https://builds.sr.ht/~eliasnaur/job/475619
✓ #475621 SUCCESS gio/patches/openbsd.yml https://builds.sr.ht/~eliasnaur/job/475621
✓ #475618 SUCCESS gio/patches/apple.yml   https://builds.sr.ht/~eliasnaur/job/475618
Thanks, merged!

Elias