Revision f789bd67cf66bfc467d3a6df7fddc4fe2551adc5
sadrul at pidgin.im
sadrul at pidgin.im
Fri Mar 9 01:49:32 EST 2007
o -----------------------------------------------------------------
| Revision: f789bd67cf66bfc467d3a6df7fddc4fe2551adc5
| Ancestor: 907cb5d765157ac901255f8d5d413f5721014464
| Author: sadrul at pidgin.im
| Date: 2007-03-09T07:04:37
| Branch: im.pidgin.pidgin
|
| Modified files:
| console/plugins/gntclipboard.c
|
| ChangeLog:
|
| Fork\!
|
| ============================================================
| --- console/plugins/gntclipboard.c 47e39e9026dcc625f41ac18098659daab13e7b08
| +++ console/plugins/gntclipboard.c 5b5780a30ce0f088c25b6b729713bf6fa3b644f1
| @@ -30,6 +30,9 @@
| #include <X11/Xatom.h>
| #endif
|
| +#include <sys/types.h>
| +#include <signal.h>
| +
| #include <glib.h>
|
| #include <plugin.h>
| @@ -39,11 +42,11 @@
|
| #include <gntplugin.h>
|
| -static gboolean stop = FALSE;
| +static pid_t child = 0;
|
| static gulong sig_handle;
|
| -static gpointer *
| +static void
| set_clip(gchar *string)
| {
| #ifdef HAVE_X11
| @@ -54,16 +57,16 @@ set_clip(gchar *string)
| Display *dpy = XOpenDisplay(NULL);
|
| if (!dpy)
| - return NULL;
| + return;
| ids = getenv("WINDOWID");
| if (ids == NULL)
| - return NULL;
| + return;
| w = atoi(ids);
| XSetSelectionOwner(dpy, XA_PRIMARY, w, CurrentTime);
| XFlush(dpy);
| XSelectInput(dpy, w, StructureNotifyMask);
| - while (!stop) {
| - XNextEvent(dpy, &e);
| + while (TRUE) {
| + XNextEvent(dpy, &e); /* this blocks. */
| req = &e.xselectionrequest;
| if (e.type == SelectionRequest) {
| XChangeProperty(dpy,
| @@ -83,33 +86,38 @@ set_clip(gchar *string)
| XSendEvent(dpy, req->requestor, 0, 0, &respond);
| XFlush (dpy);
| } else if (e.type == SelectionClear) {
| - return NULL;
| + return;
| }
| }
| #endif
| - return NULL;
| + return;
| }
|
| static void
| clipboard_changed(GntWM *wm, gchar *string)
| {
| #ifdef HAVE_X11
| - static GThread *thread = NULL;
| - if (thread) {
| - stop = TRUE;
| - thread = g_thread_join(thread);
| + if (child) {
| + kill(child, SIGTERM);
| }
| - g_thread_create((GThreadFunc)set_clip, string, TRUE, NULL);
| + if ((child = fork() == 0)) {
| + set_clip(string);
| + _exit(0);
| + }
| #endif
| }
|
| static gboolean
| plugin_load(GaimPlugin *plugin)
| {
| - if (!XOpenDisplay(NULL))
| + if (!XOpenDisplay(NULL)) {
| gaim_debug_warning("gntclipboard", "Couldn't find X display\n");
| - if (!getenv("WINDOWID"))
| + return FALSE;
| + }
| + if (!getenv("WINDOWID")) {
| gaim_debug_warning("gntclipboard", "Couldn't find window\n");
| + return FALSE;
| + }
| sig_handle = g_signal_connect(G_OBJECT(gnt_get_clipboard()), "clipboard_changed", G_CALLBACK(clipboard_changed), NULL);
| return TRUE;
| }
| @@ -117,6 +125,10 @@ plugin_unload(GaimPlugin *plugin)
| static gboolean
| plugin_unload(GaimPlugin *plugin)
| {
| + if (child) {
| + kill(child, SIGTERM);
| + child = 0;
| + }
| g_signal_handler_disconnect(G_OBJECT(gnt_get_clipboard()), sig_handle);
| return TRUE;
| }
| @@ -151,7 +163,6 @@ init_plugin(GaimPlugin *plugin)
| static void
| init_plugin(GaimPlugin *plugin)
| {
| - g_thread_init(NULL);
| }
|
| GAIM_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info)
To get the patch for this revision, please do this:
mtn log --last 1 --diffs --from f789bd67cf66bfc467d3a6df7fddc4fe2551adc5
More information about the Commits
mailing list