summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorkotontrion <[email protected]>2024-11-08 11:27:49 +0100
committerkotontrion <[email protected]>2024-12-17 09:01:40 +0100
commit5860d721c59efa8de9c44dbaeeb546c2420ba7c4 (patch)
tree6f61988961382b81c66475df7f73c0452c0e32a4 /lib
parent1bc38cf97875ce46da5e3080729603f6f25c5d98 (diff)
wayland-glib: fix freeze
occured sometimes when used by multiple libs at the same time
Diffstat (limited to 'lib')
-rw-r--r--lib/wayland-glib/wl-source.vala75
1 files changed, 31 insertions, 44 deletions
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);
+ }
}
}