diff options
Diffstat (limited to 'lib/wayland-glib')
-rw-r--r-- | lib/wayland-glib/meson.build | 40 | ||||
-rw-r--r-- | lib/wayland-glib/version | 1 | ||||
-rw-r--r-- | lib/wayland-glib/wl-source.vala | 44 |
3 files changed, 85 insertions, 0 deletions
diff --git a/lib/wayland-glib/meson.build b/lib/wayland-glib/meson.build new file mode 100644 index 0000000..3d93ac0 --- /dev/null +++ b/lib/wayland-glib/meson.build @@ -0,0 +1,40 @@ +project( + 'wayland-glib', + 'vala', + 'c', + version: run_command('cat', join_paths(meson.project_source_root(), 'version')).stdout().strip(), + meson_version: '>= 0.62.0', + default_options: [ + 'warning_level=2', + 'werror=false', + 'c_std=gnu11', + ], +) + +version_split = meson.project_version().split('.') + +deps = [ + dependency('glib-2.0'), + dependency('gio-2.0'), + dependency('gobject-2.0'), + dependency('wayland-client'), +] + +sources = [ + 'wl-source.vala', +] + +lib = static_library( + meson.project_name(), + sources, + dependencies: deps, + vala_header: meson.project_name() + '.h', + vala_vapi: meson.project_name() + '.vapi', +) + +wayland_glib = declare_dependency( + link_with: lib, + include_directories: include_directories('.') + ) + + diff --git a/lib/wayland-glib/version b/lib/wayland-glib/version new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/lib/wayland-glib/version @@ -0,0 +1 @@ +0.1.0 diff --git a/lib/wayland-glib/wl-source.vala b/lib/wayland-glib/wl-source.vala new file mode 100644 index 0000000..f8472fb --- /dev/null +++ b/lib/wayland-glib/wl-source.vala @@ -0,0 +1,44 @@ +namespace WlGlib { +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 (((revents & IOCondition.IN) != 0) && this.display.dispatch() < 0) { + if(callback != null) return callback(); + return Source.REMOVE; + } + return Source.CONTINUE; + } + + public override bool check() { + IOCondition revents = this.query_unix_fd(this.fd); + return revents > 0; + } + + public override bool prepare(out int timeout) { + if(this.display.flush() < 0) + this.error = errno; + timeout = -1; + return false; + } + + public WlSource() { + base(); + 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); + this.attach(null); + } +} +} + |