From 1bc38cf97875ce46da5e3080729603f6f25c5d98 Mon Sep 17 00:00:00 2001 From: kotontrion Date: Mon, 28 Oct 2024 15:37:27 +0100 Subject: move wayland-glib into its own lib --- lib/wayland-glib/wl-source.vala | 57 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 lib/wayland-glib/wl-source.vala (limited to 'lib/wayland-glib/wl-source.vala') diff --git a/lib/wayland-glib/wl-source.vala b/lib/wayland-glib/wl-source.vala new file mode 100644 index 0000000..57b9866 --- /dev/null +++ b/lib/wayland-glib/wl-source.vala @@ -0,0 +1,57 @@ +namespace WlSource { +public class WlSource : Source { + + public Wl.Display display; + public void* fd; + public int error; + + public override bool dispatch(SourceFunc callback) { + IOCondition revents = this.query_unix_fd(this.fd); + if(this.error > 0 || (revents & (IOCondition.ERR | IOCondition.HUP)) != 0) { + errno = this.error; + if(callback != null) return callback(); + return Source.REMOVE; + } + if(this.display.dispatch_pending() < 0) { + if(callback != null) return callback(); + return Source.REMOVE; + } + return Source.CONTINUE; + } + + public override bool check() { + if(this.error > 0) return true; + IOCondition revents = this.query_unix_fd(this.fd); + if((revents & IOCondition.IN) != 0) { + if(this.display.read_events() < 0) { + this.error = errno; + } + } + else { + this.display.cancel_read(); + } + return revents > 0; + } + + public override bool prepare(out int timeout) { + timeout = 0; + if(this.display.prepare_read() != 0) return true; + else if (this.display.flush() < 0 ){ + this.error = errno; + return true; + } + timeout = -1; + return false; + } + + public WlSource() { + base(); + this.display = Wl.Display.connect(null); + if(this.display == null) return; + this.fd = this.add_unix_fd(this.display.get_fd(), IOCondition.IN | IOCondition.ERR | IOCondition.HUP); + this.attach(null); + } + +} +} + -- cgit v1.2.3 From 5860d721c59efa8de9c44dbaeeb546c2420ba7c4 Mon Sep 17 00:00:00 2001 From: kotontrion Date: Fri, 8 Nov 2024 11:27:49 +0100 Subject: wayland-glib: fix freeze occured sometimes when used by multiple libs at the same time --- lib/wayland-glib/wl-source.vala | 75 +++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 44 deletions(-) (limited to 'lib/wayland-glib/wl-source.vala') diff --git a/lib/wayland-glib/wl-source.vala b/lib/wayland-glib/wl-source.vala index 57b9866..28495d0 100644 --- a/lib/wayland-glib/wl-source.vala +++ b/lib/wayland-glib/wl-source.vala @@ -1,57 +1,44 @@ namespace WlSource { public class WlSource : Source { - public Wl.Display display; - public void* fd; - public int error; + public Wl.Display display; + public void* fd; + public int error; - public override bool dispatch(SourceFunc callback) { - IOCondition revents = this.query_unix_fd(this.fd); - if(this.error > 0 || (revents & (IOCondition.ERR | IOCondition.HUP)) != 0) { - errno = this.error; - if(callback != null) return callback(); - return Source.REMOVE; + public override bool dispatch(SourceFunc callback) { + IOCondition revents = this.query_unix_fd(this.fd); + if (this.error > 0 || (revents & (IOCondition.ERR | IOCondition.HUP)) != 0) { + errno = this.error; + if(callback != null) return callback(); + return Source.REMOVE; + } + if (((revents & IOCondition.IN) != 0) && this.display.dispatch() < 0) { + if(callback != null) return callback(); + return Source.REMOVE; + } + return Source.CONTINUE; } - if(this.display.dispatch_pending() < 0) { - if(callback != null) return callback(); - return Source.REMOVE; - } - return Source.CONTINUE; - } - public override bool check() { - if(this.error > 0) return true; - IOCondition revents = this.query_unix_fd(this.fd); - if((revents & IOCondition.IN) != 0) { - if(this.display.read_events() < 0) { - this.error = errno; - } - } - else { - this.display.cancel_read(); + public override bool check() { + IOCondition revents = this.query_unix_fd(this.fd); + return revents > 0; } - return revents > 0; - } - public override bool prepare(out int timeout) { - timeout = 0; - if(this.display.prepare_read() != 0) return true; - else if (this.display.flush() < 0 ){ - this.error = errno; - return true; + public override bool prepare(out int timeout) { + if(this.display.flush() < 0) + this.error = errno; + timeout = -1; + return false; } - timeout = -1; - return false; - } - - public WlSource() { - base(); - this.display = Wl.Display.connect(null); - if(this.display == null) return; - this.fd = this.add_unix_fd(this.display.get_fd(), IOCondition.IN | IOCondition.ERR | IOCondition.HUP); - this.attach(null); - } + public WlSource() { + base(); + this.display = Wl.Display.connect(null); + if(this.display == null) return; + this.fd = this.add_unix_fd(this.display.get_fd(), + IOCondition.IN | IOCondition.ERR | IOCondition.HUP); + this.attach(null); + } } } -- cgit v1.2.3 From 5b2a0e8905fc32ac603437c22fb6eaee6adeafd8 Mon Sep 17 00:00:00 2001 From: kotontrion Date: Tue, 17 Dec 2024 09:16:32 +0100 Subject: wayland-glib: clean up vapi --- lib/wayland-glib/wl-source.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/wayland-glib/wl-source.vala') diff --git a/lib/wayland-glib/wl-source.vala b/lib/wayland-glib/wl-source.vala index 28495d0..7870672 100644 --- a/lib/wayland-glib/wl-source.vala +++ b/lib/wayland-glib/wl-source.vala @@ -33,7 +33,7 @@ public class WlSource : Source { public WlSource() { base(); - this.display = Wl.Display.connect(null); + this.display = new Wl.Display.connect(null); if(this.display == null) return; this.fd = this.add_unix_fd(this.display.get_fd(), IOCondition.IN | IOCondition.ERR | IOCondition.HUP); -- cgit v1.2.3 From 5ed7a1416c2532188a7e01fead3842602fdb670f Mon Sep 17 00:00:00 2001 From: kotontrion Date: Fri, 20 Dec 2024 09:47:59 +0100 Subject: wayland-glib: rename namespace --- lib/wayland-glib/wl-source.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/wayland-glib/wl-source.vala') diff --git a/lib/wayland-glib/wl-source.vala b/lib/wayland-glib/wl-source.vala index 7870672..f8472fb 100644 --- a/lib/wayland-glib/wl-source.vala +++ b/lib/wayland-glib/wl-source.vala @@ -1,4 +1,4 @@ -namespace WlSource { +namespace WlGlib { public class WlSource : Source { public Wl.Display display; -- cgit v1.2.3