diff --git a/meson.build b/meson.build index c00de92..851dfb6 100644 --- a/meson.build +++ b/meson.build @@ -9,6 +9,7 @@ json_glib_dep = dependency('json-glib-1.0') gee_dep = dependency('gee-0.8') libnotify_dep = dependency('libnotify') gdk_dep = dependency('gdk-3.0') +gtk_dep = dependency('gtk+-3.0') atspi_dep = dependency('atspi-2') gnutls_dep = dependency('gnutls') posix_dep = meson.get_compiler('vala').find_library('posix') @@ -58,7 +59,7 @@ mconnect_prog = executable('mconnect', mconnect_src, json_glib_dep, gee_dep, libnotify_dep, gdk_dep, atspi_dep, gnutls_dep, - posix_dep], + posix_dep, gtk_dep], install: true) mconnectctl_src = 'src/mconnectctl/main.vala' diff --git a/src/mconnect/main.vala b/src/mconnect/main.vala index b9dc643..50d2a22 100644 --- a/src/mconnect/main.vala +++ b/src/mconnect/main.vala @@ -24,5 +24,8 @@ public static int main(string[] args) // needed for mousepad protocol handler Gdk.init(ref args); + // needed for clipboard sharing + Gtk.init(ref args); + return app.run(args); } \ No newline at end of file diff --git a/src/mconnect/share.vala b/src/mconnect/share.vala index 9ca4405..13684c2 100644 --- a/src/mconnect/share.vala +++ b/src/mconnect/share.vala @@ -106,5 +106,12 @@ class ShareHandler : Object, PacketHandlerInterface { } private void handle_text(Device dev, Packet pkt) { + var text = pkt.body.get_string_member("text"); + debug("shared text '%s'", text); + var display = Gdk.Display.get_default(); + if (display != null) { + var cb = Gtk.Clipboard.get_default(display); + cb.set_text(text, -1); + } } } \ No newline at end of file