diff options
Diffstat (limited to 'plugins/clipboard')
-rw-r--r-- | plugins/clipboard/Makefile.am | 53 | ||||
-rw-r--r-- | plugins/clipboard/Makefile.in | 699 | ||||
-rw-r--r-- | plugins/clipboard/clipboard.mate-settings-plugin.in | 8 | ||||
-rw-r--r-- | plugins/clipboard/gsd-clipboard-manager.c | 1069 | ||||
-rw-r--r-- | plugins/clipboard/gsd-clipboard-manager.h | 61 | ||||
-rw-r--r-- | plugins/clipboard/gsd-clipboard-plugin.c | 104 | ||||
-rw-r--r-- | plugins/clipboard/gsd-clipboard-plugin.h | 63 | ||||
-rw-r--r-- | plugins/clipboard/list.c | 150 | ||||
-rw-r--r-- | plugins/clipboard/list.h | 57 | ||||
-rw-r--r-- | plugins/clipboard/xutils.c | 117 | ||||
-rw-r--r-- | plugins/clipboard/xutils.h | 50 |
11 files changed, 2431 insertions, 0 deletions
diff --git a/plugins/clipboard/Makefile.am b/plugins/clipboard/Makefile.am new file mode 100644 index 0000000..f50a86e --- /dev/null +++ b/plugins/clipboard/Makefile.am @@ -0,0 +1,53 @@ +NULL = + +plugin_LTLIBRARIES = \ + libclipboard.la \ + $(NULL) + +libclipboard_la_SOURCES = \ + gsd-clipboard-plugin.h \ + gsd-clipboard-plugin.c \ + gsd-clipboard-manager.h \ + gsd-clipboard-manager.c \ + xutils.h \ + xutils.c \ + list.h \ + list.c \ + $(NULL) + +libclipboard_la_CPPFLAGS = \ + -I$(top_srcdir)/mate-settings-daemon \ + -DMATE_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \ + $(AM_CPPFLAGS) + +libclipboard_la_CFLAGS = \ + $(SETTINGS_PLUGIN_CFLAGS) \ + $(AM_CFLAGS) + +libclipboard_la_LDFLAGS = \ + $(GSD_PLUGIN_LDFLAGS) \ + $(NULL) + +libclipboard_la_LIBADD = \ + $(SETTINGS_PLUGIN_LIBS) \ + $(NULL) + +plugin_in_files = \ + clipboard.mate-settings-plugin.in \ + $(NULL) + +plugin_DATA = $(plugin_in_files:.mate-settings-plugin.in=.mate-settings-plugin) + +EXTRA_DIST = \ + $(plugin_in_files) \ + $(NULL) + +CLEANFILES = \ + $(plugin_DATA) \ + $(NULL) + +DISTCLEANFILES = \ + $(plugin_DATA) \ + $(NULL) + +@GSD_INTLTOOL_PLUGIN_RULE@ diff --git a/plugins/clipboard/Makefile.in b/plugins/clipboard/Makefile.in new file mode 100644 index 0000000..3516b51 --- /dev/null +++ b/plugins/clipboard/Makefile.in @@ -0,0 +1,699 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = plugins/clipboard +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(plugindir)" +LTLIBRARIES = $(plugin_LTLIBRARIES) +am__DEPENDENCIES_1 = +libclipboard_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am__objects_1 = +am_libclipboard_la_OBJECTS = libclipboard_la-gsd-clipboard-plugin.lo \ + libclipboard_la-gsd-clipboard-manager.lo \ + libclipboard_la-xutils.lo libclipboard_la-list.lo \ + $(am__objects_1) +libclipboard_la_OBJECTS = $(am_libclipboard_la_OBJECTS) +libclipboard_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libclipboard_la_CFLAGS) \ + $(CFLAGS) $(libclipboard_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libclipboard_la_SOURCES) +DIST_SOURCES = $(libclipboard_la_SOURCES) +DATA = $(plugin_DATA) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEBUG_CFLAGS = @DEBUG_CFLAGS@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@ +FONTCONFIG_LIBS = @FONTCONFIG_LIBS@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GIOUNIX_CFLAGS = @GIOUNIX_CFLAGS@ +GIOUNIX_LIBS = @GIOUNIX_LIBS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GREP = @GREP@ +GSD_INTLTOOL_PLUGIN_RULE = @GSD_INTLTOOL_PLUGIN_RULE@ +GSD_PLUGIN_LDFLAGS = @GSD_PLUGIN_LDFLAGS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBEXECDIR = @LIBEXECDIR@ +LIBMATEKBDUI_CFLAGS = @LIBMATEKBDUI_CFLAGS@ +LIBMATEKBDUI_LIBS = @LIBMATEKBDUI_LIBS@ +LIBMATENOTIFY_CFLAGS = @LIBMATENOTIFY_CFLAGS@ +LIBMATENOTIFY_LIBS = @LIBMATENOTIFY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MATECONFTOOL = @MATECONFTOOL@ +MATECONF_SCHEMA_CONFIG_SOURCE = @MATECONF_SCHEMA_CONFIG_SOURCE@ +MATECONF_SCHEMA_FILE_DIR = @MATECONF_SCHEMA_FILE_DIR@ +MATE_KEYBINDINGS_KEYSDIR = @MATE_KEYBINDINGS_KEYSDIR@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NSS_CFLAGS = @NSS_CFLAGS@ +NSS_DATABASE = @NSS_DATABASE@ +NSS_LIBS = @NSS_LIBS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POFILES = @POFILES@ +POLKIT_CFLAGS = @POLKIT_CFLAGS@ +POLKIT_LIBS = @POLKIT_LIBS@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +PULSE_CFLAGS = @PULSE_CFLAGS@ +PULSE_LIBS = @PULSE_LIBS@ +RANLIB = @RANLIB@ +SED = @SED@ +SETTINGS_DAEMON_CFLAGS = @SETTINGS_DAEMON_CFLAGS@ +SETTINGS_DAEMON_LIBS = @SETTINGS_DAEMON_LIBS@ +SETTINGS_PLUGIN_CFLAGS = @SETTINGS_PLUGIN_CFLAGS@ +SETTINGS_PLUGIN_LIBS = @SETTINGS_PLUGIN_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ +X11_LIBS = @X11_LIBS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XGETTEXT = @XGETTEXT@ +XINPUT_LIBS = @XINPUT_LIBS@ +XMKMF = @XMKMF@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +plugindir = @plugindir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +NULL = +plugin_LTLIBRARIES = \ + libclipboard.la \ + $(NULL) + +libclipboard_la_SOURCES = \ + gsd-clipboard-plugin.h \ + gsd-clipboard-plugin.c \ + gsd-clipboard-manager.h \ + gsd-clipboard-manager.c \ + xutils.h \ + xutils.c \ + list.h \ + list.c \ + $(NULL) + +libclipboard_la_CPPFLAGS = \ + -I$(top_srcdir)/mate-settings-daemon \ + -DMATE_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \ + $(AM_CPPFLAGS) + +libclipboard_la_CFLAGS = \ + $(SETTINGS_PLUGIN_CFLAGS) \ + $(AM_CFLAGS) + +libclipboard_la_LDFLAGS = \ + $(GSD_PLUGIN_LDFLAGS) \ + $(NULL) + +libclipboard_la_LIBADD = \ + $(SETTINGS_PLUGIN_LIBS) \ + $(NULL) + +plugin_in_files = \ + clipboard.mate-settings-plugin.in \ + $(NULL) + +plugin_DATA = $(plugin_in_files:.mate-settings-plugin.in=.mate-settings-plugin) +EXTRA_DIST = \ + $(plugin_in_files) \ + $(NULL) + +CLEANFILES = \ + $(plugin_DATA) \ + $(NULL) + +DISTCLEANFILES = \ + $(plugin_DATA) \ + $(NULL) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu plugins/clipboard/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu plugins/clipboard/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(plugindir)" || $(MKDIR_P) "$(DESTDIR)$(plugindir)" + @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \ + } + +uninstall-pluginLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \ + done + +clean-pluginLTLIBRARIES: + -test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES) + @list='$(plugin_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libclipboard.la: $(libclipboard_la_OBJECTS) $(libclipboard_la_DEPENDENCIES) + $(libclipboard_la_LINK) -rpath $(plugindir) $(libclipboard_la_OBJECTS) $(libclipboard_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclipboard_la-gsd-clipboard-manager.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclipboard_la-gsd-clipboard-plugin.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclipboard_la-list.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclipboard_la-xutils.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +libclipboard_la-gsd-clipboard-plugin.lo: gsd-clipboard-plugin.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libclipboard_la_CPPFLAGS) $(CPPFLAGS) $(libclipboard_la_CFLAGS) $(CFLAGS) -MT libclipboard_la-gsd-clipboard-plugin.lo -MD -MP -MF $(DEPDIR)/libclipboard_la-gsd-clipboard-plugin.Tpo -c -o libclipboard_la-gsd-clipboard-plugin.lo `test -f 'gsd-clipboard-plugin.c' || echo '$(srcdir)/'`gsd-clipboard-plugin.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libclipboard_la-gsd-clipboard-plugin.Tpo $(DEPDIR)/libclipboard_la-gsd-clipboard-plugin.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gsd-clipboard-plugin.c' object='libclipboard_la-gsd-clipboard-plugin.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libclipboard_la_CPPFLAGS) $(CPPFLAGS) $(libclipboard_la_CFLAGS) $(CFLAGS) -c -o libclipboard_la-gsd-clipboard-plugin.lo `test -f 'gsd-clipboard-plugin.c' || echo '$(srcdir)/'`gsd-clipboard-plugin.c + +libclipboard_la-gsd-clipboard-manager.lo: gsd-clipboard-manager.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libclipboard_la_CPPFLAGS) $(CPPFLAGS) $(libclipboard_la_CFLAGS) $(CFLAGS) -MT libclipboard_la-gsd-clipboard-manager.lo -MD -MP -MF $(DEPDIR)/libclipboard_la-gsd-clipboard-manager.Tpo -c -o libclipboard_la-gsd-clipboard-manager.lo `test -f 'gsd-clipboard-manager.c' || echo '$(srcdir)/'`gsd-clipboard-manager.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libclipboard_la-gsd-clipboard-manager.Tpo $(DEPDIR)/libclipboard_la-gsd-clipboard-manager.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gsd-clipboard-manager.c' object='libclipboard_la-gsd-clipboard-manager.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libclipboard_la_CPPFLAGS) $(CPPFLAGS) $(libclipboard_la_CFLAGS) $(CFLAGS) -c -o libclipboard_la-gsd-clipboard-manager.lo `test -f 'gsd-clipboard-manager.c' || echo '$(srcdir)/'`gsd-clipboard-manager.c + +libclipboard_la-xutils.lo: xutils.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libclipboard_la_CPPFLAGS) $(CPPFLAGS) $(libclipboard_la_CFLAGS) $(CFLAGS) -MT libclipboard_la-xutils.lo -MD -MP -MF $(DEPDIR)/libclipboard_la-xutils.Tpo -c -o libclipboard_la-xutils.lo `test -f 'xutils.c' || echo '$(srcdir)/'`xutils.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libclipboard_la-xutils.Tpo $(DEPDIR)/libclipboard_la-xutils.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xutils.c' object='libclipboard_la-xutils.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libclipboard_la_CPPFLAGS) $(CPPFLAGS) $(libclipboard_la_CFLAGS) $(CFLAGS) -c -o libclipboard_la-xutils.lo `test -f 'xutils.c' || echo '$(srcdir)/'`xutils.c + +libclipboard_la-list.lo: list.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libclipboard_la_CPPFLAGS) $(CPPFLAGS) $(libclipboard_la_CFLAGS) $(CFLAGS) -MT libclipboard_la-list.lo -MD -MP -MF $(DEPDIR)/libclipboard_la-list.Tpo -c -o libclipboard_la-list.lo `test -f 'list.c' || echo '$(srcdir)/'`list.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libclipboard_la-list.Tpo $(DEPDIR)/libclipboard_la-list.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='list.c' object='libclipboard_la-list.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libclipboard_la_CPPFLAGS) $(CPPFLAGS) $(libclipboard_la_CFLAGS) $(CFLAGS) -c -o libclipboard_la-list.lo `test -f 'list.c' || echo '$(srcdir)/'`list.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-pluginDATA: $(plugin_DATA) + @$(NORMAL_INSTALL) + test -z "$(plugindir)" || $(MKDIR_P) "$(DESTDIR)$(plugindir)" + @list='$(plugin_DATA)'; test -n "$(plugindir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(plugindir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(plugindir)" || exit $$?; \ + done + +uninstall-pluginDATA: + @$(NORMAL_UNINSTALL) + @list='$(plugin_DATA)'; test -n "$(plugindir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(plugindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(plugindir)" && rm -f $$files + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(DATA) +installdirs: + for dir in "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(plugindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-pluginDATA install-pluginLTLIBRARIES + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-pluginDATA uninstall-pluginLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-pluginLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-pluginDATA \ + install-pluginLTLIBRARIES install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-pluginDATA uninstall-pluginLTLIBRARIES + + +@GSD_INTLTOOL_PLUGIN_RULE@ + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/plugins/clipboard/clipboard.mate-settings-plugin.in b/plugins/clipboard/clipboard.mate-settings-plugin.in new file mode 100644 index 0000000..3a5536f --- /dev/null +++ b/plugins/clipboard/clipboard.mate-settings-plugin.in @@ -0,0 +1,8 @@ +[MATE Settings Plugin] +Module=clipboard +IAge=0 +_Name=Clipboard +_Description=Clipboard plugin +Authors=Matthias Clasen +Copyright=Copyright © 2007 Matthias Clasen +Website= diff --git a/plugins/clipboard/gsd-clipboard-manager.c b/plugins/clipboard/gsd-clipboard-manager.c new file mode 100644 index 0000000..fcbc839 --- /dev/null +++ b/plugins/clipboard/gsd-clipboard-manager.c @@ -0,0 +1,1069 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 Matthias Clasen + * Copyright (C) 2007 Anders Carlsson + * Copyright (C) 2007 Rodrigo Moya + * Copyright (C) 2007 William Jon McCann <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#include "config.h" + +#include <sys/types.h> +#include <sys/wait.h> +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> + +#include <locale.h> + +#include <glib.h> +#include <glib/gi18n.h> +#include <gdk/gdk.h> +#include <gdk/gdkx.h> +#include <gtk/gtk.h> +#include <X11/Xlib.h> +#include <X11/Xatom.h> + +#include "xutils.h" +#include "list.h" + +#include "mate-settings-profile.h" +#include "gsd-clipboard-manager.h" + +#define GSD_CLIPBOARD_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_CLIPBOARD_MANAGER, GsdClipboardManagerPrivate)) + +struct GsdClipboardManagerPrivate +{ + Display *display; + Window window; + Time timestamp; + + List *contents; + List *conversions; + + Window requestor; + Atom property; + Time time; +}; + +typedef struct +{ + unsigned char *data; + int length; + Atom target; + Atom type; + int format; + int refcount; +} TargetData; + +typedef struct +{ + Atom target; + TargetData *data; + Atom property; + Window requestor; + int offset; +} IncrConversion; + +static void gsd_clipboard_manager_class_init (GsdClipboardManagerClass *klass); +static void gsd_clipboard_manager_init (GsdClipboardManager *clipboard_manager); +static void gsd_clipboard_manager_finalize (GObject *object); + +static void clipboard_manager_watch_cb (GsdClipboardManager *manager, + Window window, + Bool is_start, + long mask, + void *cb_data); + +G_DEFINE_TYPE (GsdClipboardManager, gsd_clipboard_manager, G_TYPE_OBJECT) + +static gpointer manager_object = NULL; + +/* We need to use reference counting for the target data, since we may + * need to keep the data around after loosing the CLIPBOARD ownership + * to complete incremental transfers. + */ +static TargetData * +target_data_ref (TargetData *data) +{ + data->refcount++; + return data; +} + +static void +target_data_unref (TargetData *data) +{ + data->refcount--; + if (data->refcount == 0) { + free (data->data); + free (data); + } +} + +static void +conversion_free (IncrConversion *rdata) +{ + if (rdata->data) { + target_data_unref (rdata->data); + } + free (rdata); +} + +static void +send_selection_notify (GsdClipboardManager *manager, + Bool success) +{ + XSelectionEvent notify; + + notify.type = SelectionNotify; + notify.serial = 0; + notify.send_event = True; + notify.display = manager->priv->display; + notify.requestor = manager->priv->requestor; + notify.selection = XA_CLIPBOARD_MANAGER; + notify.target = XA_SAVE_TARGETS; + notify.property = success ? manager->priv->property : None; + notify.time = manager->priv->time; + + gdk_error_trap_push (); + + XSendEvent (manager->priv->display, + manager->priv->requestor, + False, + NoEventMask, + (XEvent *)¬ify); + XSync (manager->priv->display, False); + + gdk_error_trap_pop (); +} + +static void +finish_selection_request (GsdClipboardManager *manager, + XEvent *xev, + Bool success) +{ + XSelectionEvent notify; + + notify.type = SelectionNotify; + notify.serial = 0; + notify.send_event = True; + notify.display = xev->xselectionrequest.display; + notify.requestor = xev->xselectionrequest.requestor; + notify.selection = xev->xselectionrequest.selection; + notify.target = xev->xselectionrequest.target; + notify.property = success ? xev->xselectionrequest.property : None; + notify.time = xev->xselectionrequest.time; + + gdk_error_trap_push (); + + XSendEvent (xev->xselectionrequest.display, + xev->xselectionrequest.requestor, + False, NoEventMask, (XEvent *) ¬ify); + XSync (manager->priv->display, False); + + gdk_error_trap_pop (); +} + +static int +clipboard_bytes_per_item (int format) +{ + switch (format) { + case 8: return sizeof (char); + case 16: return sizeof (short); + case 32: return sizeof (long); + default: ; + } + + return 0; +} + +static void +save_targets (GsdClipboardManager *manager, + Atom *save_targets, + int nitems) +{ + int nout, i; + Atom *multiple; + TargetData *tdata; + + multiple = (Atom *) malloc (2 * nitems * sizeof (Atom)); + + nout = 0; + for (i = 0; i < nitems; i++) { + if (save_targets[i] != XA_TARGETS && + save_targets[i] != XA_MULTIPLE && + save_targets[i] != XA_DELETE && + save_targets[i] != XA_INSERT_PROPERTY && + save_targets[i] != XA_INSERT_SELECTION && + save_targets[i] != XA_PIXMAP) { + tdata = (TargetData *) malloc (sizeof (TargetData)); + tdata->data = NULL; + tdata->length = 0; + tdata->target = save_targets[i]; + tdata->type = None; + tdata->format = 0; + tdata->refcount = 1; + manager->priv->contents = list_prepend (manager->priv->contents, tdata); + + multiple[nout++] = save_targets[i]; + multiple[nout++] = save_targets[i]; + } + } + + XFree (save_targets); + + XChangeProperty (manager->priv->display, manager->priv->window, + XA_MULTIPLE, XA_ATOM_PAIR, + 32, PropModeReplace, (const unsigned char *) multiple, nout); + free (multiple); + + XConvertSelection (manager->priv->display, XA_CLIPBOARD, + XA_MULTIPLE, XA_MULTIPLE, + manager->priv->window, manager->priv->time); +} + +static int +find_content_target (TargetData *tdata, + Atom target) +{ + return tdata->target == target; +} + +static int +find_content_type (TargetData *tdata, + Atom type) +{ + return tdata->type == type; +} + +static int +find_conversion_requestor (IncrConversion *rdata, + XEvent *xev) +{ + return (rdata->requestor == xev->xproperty.window && + rdata->property == xev->xproperty.atom); +} + +static void +get_property (TargetData *tdata, + GsdClipboardManager *manager) +{ + Atom type; + int format; + unsigned long length; + unsigned long remaining; + unsigned char *data; + + XGetWindowProperty (manager->priv->display, + manager->priv->window, + tdata->target, + 0, + 0x1FFFFFFF, + True, + AnyPropertyType, + &type, + &format, + &length, + &remaining, + &data); + + if (type == None) { + manager->priv->contents = list_remove (manager->priv->contents, tdata); + free (tdata); + } else if (type == XA_INCR) { + tdata->type = type; + tdata->length = 0; + XFree (data); + } else { + tdata->type = type; + tdata->data = data; + tdata->length = length * clipboard_bytes_per_item (format); + tdata->format = format; + } +} + +static Bool +receive_incrementally (GsdClipboardManager *manager, + XEvent *xev) +{ + List *list; + TargetData *tdata; + Atom type; + int format; + unsigned long length, nitems, remaining; + unsigned char *data; + + if (xev->xproperty.window != manager->priv->window) + return False; + + list = list_find (manager->priv->contents, + (ListFindFunc) find_content_target, (void *) xev->xproperty.atom); + + if (!list) + return False; + + tdata = (TargetData *) list->data; + + if (tdata->type != XA_INCR) + return False; + + XGetWindowProperty (xev->xproperty.display, + xev->xproperty.window, + xev->xproperty.atom, + 0, 0x1FFFFFFF, True, AnyPropertyType, + &type, &format, &nitems, &remaining, &data); + + length = nitems * clipboard_bytes_per_item (format); + if (length == 0) { + tdata->type = type; + tdata->format = format; + + if (!list_find (manager->priv->contents, + (ListFindFunc) find_content_type, (void *)XA_INCR)) { + /* all incremental transfers done */ + send_selection_notify (manager, True); + manager->priv->requestor = None; + } + + XFree (data); + } else { + if (!tdata->data) { + tdata->data = data; + tdata->length = length; + } else { + tdata->data = realloc (tdata->data, tdata->length + length + 1); + memcpy (tdata->data + tdata->length, data, length + 1); + tdata->length += length; + XFree (data); + } + } + + return True; +} + +static Bool +send_incrementally (GsdClipboardManager *manager, + XEvent *xev) +{ + List *list; + IncrConversion *rdata; + unsigned long length; + unsigned long items; + unsigned char *data; + + list = list_find (manager->priv->conversions, + (ListFindFunc) find_conversion_requestor, xev); + if (list == NULL) + return False; + + rdata = (IncrConversion *) list->data; + + data = rdata->data->data + rdata->offset; + length = rdata->data->length - rdata->offset; + if (length > SELECTION_MAX_SIZE) + length = SELECTION_MAX_SIZE; + + rdata->offset += length; + + items = length / clipboard_bytes_per_item (rdata->data->format); + XChangeProperty (manager->priv->display, rdata->requestor, + rdata->property, rdata->data->type, + rdata->data->format, PropModeAppend, + data, items); + + if (length == 0) { + manager->priv->conversions = list_remove (manager->priv->conversions, rdata); + conversion_free (rdata); + } + + return True; +} + +static void +convert_clipboard_manager (GsdClipboardManager *manager, + XEvent *xev) +{ + Atom type = None; + int format; + unsigned long nitems; + unsigned long remaining; + Atom *targets = NULL; + + if (xev->xselectionrequest.target == XA_SAVE_TARGETS) { + if (manager->priv->requestor != None || manager->priv->contents != NULL) { + /* We're in the middle of a conversion request, or own + * the CLIPBOARD already + */ + finish_selection_request (manager, xev, False); + } else { + gdk_error_trap_push (); + + clipboard_manager_watch_cb (manager, + xev->xselectionrequest.requestor, + True, + StructureNotifyMask, + NULL); + XSelectInput (manager->priv->display, + xev->xselectionrequest.requestor, + StructureNotifyMask); + XSync (manager->priv->display, False); + + if (gdk_error_trap_pop () != Success) + return; + + gdk_error_trap_push (); + + if (xev->xselectionrequest.property != None) { + XGetWindowProperty (manager->priv->display, + xev->xselectionrequest.requestor, + xev->xselectionrequest.property, + 0, 0x1FFFFFFF, False, XA_ATOM, + &type, &format, &nitems, &remaining, + (unsigned char **) &targets); + + if (gdk_error_trap_pop () != Success) { + if (targets) + XFree (targets); + + return; + } + } + + manager->priv->requestor = xev->xselectionrequest.requestor; + manager->priv->property = xev->xselectionrequest.property; + manager->priv->time = xev->xselectionrequest.time; + + if (type == None) + XConvertSelection (manager->priv->display, XA_CLIPBOARD, + XA_TARGETS, XA_TARGETS, + manager->priv->window, manager->priv->time); + else + save_targets (manager, targets, nitems); + } + } else if (xev->xselectionrequest.target == XA_TIMESTAMP) { + XChangeProperty (manager->priv->display, + xev->xselectionrequest.requestor, + xev->xselectionrequest.property, + XA_INTEGER, 32, PropModeReplace, + (unsigned char *) &manager->priv->timestamp, 1); + + finish_selection_request (manager, xev, True); + } else if (xev->xselectionrequest.target == XA_TARGETS) { + int n_targets = 0; + Atom targets[3]; + + targets[n_targets++] = XA_TARGETS; + targets[n_targets++] = XA_TIMESTAMP; + targets[n_targets++] = XA_SAVE_TARGETS; + + XChangeProperty (manager->priv->display, + xev->xselectionrequest.requestor, + xev->xselectionrequest.property, + XA_ATOM, 32, PropModeReplace, + (unsigned char *) targets, n_targets); + + finish_selection_request (manager, xev, True); + } else + finish_selection_request (manager, xev, False); +} + +static void +convert_clipboard_target (IncrConversion *rdata, + GsdClipboardManager *manager) +{ + TargetData *tdata; + Atom *targets; + int n_targets; + List *list; + unsigned long items; + XWindowAttributes atts; + + if (rdata->target == XA_TARGETS) { + n_targets = list_length (manager->priv->contents) + 2; + targets = (Atom *) malloc (n_targets * sizeof (Atom)); + + n_targets = 0; + + targets[n_targets++] = XA_TARGETS; + targets[n_targets++] = XA_MULTIPLE; + + for (list = manager->priv->contents; list; list = list->next) { + tdata = (TargetData *) list->data; + targets[n_targets++] = tdata->target; + } + + XChangeProperty (manager->priv->display, rdata->requestor, + rdata->property, + XA_ATOM, 32, PropModeReplace, + (unsigned char *) targets, n_targets); + free (targets); + } else { + /* Convert from stored CLIPBOARD data */ + list = list_find (manager->priv->contents, + (ListFindFunc) find_content_target, (void *) rdata->target); + + /* We got a target that we don't support */ + if (!list) + return; + + tdata = (TargetData *)list->data; + if (tdata->type == XA_INCR) { + /* we haven't completely received this target yet */ + rdata->property = None; + return; + } + + rdata->data = target_data_ref (tdata); + items = tdata->length / clipboard_bytes_per_item (tdata->format); + if (tdata->length <= SELECTION_MAX_SIZE) + XChangeProperty (manager->priv->display, rdata->requestor, + rdata->property, + tdata->type, tdata->format, PropModeReplace, + tdata->data, items); + else { + /* start incremental transfer */ + rdata->offset = 0; + + gdk_error_trap_push (); + + XGetWindowAttributes (manager->priv->display, rdata->requestor, &atts); + XSelectInput (manager->priv->display, rdata->requestor, + atts.your_event_mask | PropertyChangeMask); + + XChangeProperty (manager->priv->display, rdata->requestor, + rdata->property, + XA_INCR, 32, PropModeReplace, + (unsigned char *) &items, 1); + + XSync (manager->priv->display, False); + + gdk_error_trap_pop (); + } + } +} + +static void +collect_incremental (IncrConversion *rdata, + GsdClipboardManager *manager) +{ + if (rdata->offset >= 0) + manager->priv->conversions = list_prepend (manager->priv->conversions, rdata); + else { + if (rdata->data) { + target_data_unref (rdata->data); + rdata->data = NULL; + } + free (rdata); + } +} + +static void +convert_clipboard (GsdClipboardManager *manager, + XEvent *xev) +{ + List *list; + List *conversions; + IncrConversion *rdata; + Atom type; + int i; + int format; + unsigned long nitems; + unsigned long remaining; + Atom *multiple; + + conversions = NULL; + type = None; + + if (xev->xselectionrequest.target == XA_MULTIPLE) { + XGetWindowProperty (xev->xselectionrequest.display, + xev->xselectionrequest.requestor, + xev->xselectionrequest.property, + 0, 0x1FFFFFFF, False, XA_ATOM_PAIR, + &type, &format, &nitems, &remaining, + (unsigned char **) &multiple); + + if (type != XA_ATOM_PAIR || nitems == 0) { + if (multiple) + free (multiple); + return; + } + + for (i = 0; i < nitems; i += 2) { + rdata = (IncrConversion *) malloc (sizeof (IncrConversion)); + rdata->requestor = xev->xselectionrequest.requestor; + rdata->target = multiple[i]; + rdata->property = multiple[i+1]; + rdata->data = NULL; + rdata->offset = -1; + conversions = list_prepend (conversions, rdata); + } + } else { + multiple = NULL; + + rdata = (IncrConversion *) malloc (sizeof (IncrConversion)); + rdata->requestor = xev->xselectionrequest.requestor; + rdata->target = xev->xselectionrequest.target; + rdata->property = xev->xselectionrequest.property; + rdata->data = NULL; + rdata->offset = -1; + conversions = list_prepend (conversions, rdata); + } + + list_foreach (conversions, (Callback) convert_clipboard_target, manager); + + if (conversions->next == NULL && + ((IncrConversion *) conversions->data)->property == None) { + finish_selection_request (manager, xev, False); + } else { + if (multiple) { + i = 0; + for (list = conversions; list; list = list->next) { + rdata = (IncrConversion *)list->data; + multiple[i++] = rdata->target; + multiple[i++] = rdata->property; + } + XChangeProperty (xev->xselectionrequest.display, + xev->xselectionrequest.requestor, + xev->xselectionrequest.property, + XA_ATOM_PAIR, 32, PropModeReplace, + (unsigned char *) multiple, nitems); + } + finish_selection_request (manager, xev, True); + } + + list_foreach (conversions, (Callback) collect_incremental, manager); + list_free (conversions); + + if (multiple) + free (multiple); +} + +static Bool +clipboard_manager_process_event (GsdClipboardManager *manager, + XEvent *xev) +{ + Atom type; + int format; + unsigned long nitems; + unsigned long remaining; + Atom *targets; + + targets = NULL; + + switch (xev->xany.type) { + case DestroyNotify: + if (xev->xdestroywindow.window == manager->priv->requestor) { + list_foreach (manager->priv->contents, (Callback)target_data_unref, NULL); + list_free (manager->priv->contents); + manager->priv->contents = NULL; + + clipboard_manager_watch_cb (manager, + manager->priv->requestor, + False, + 0, + NULL); + manager->priv->requestor = None; + } + break; + case PropertyNotify: + if (xev->xproperty.state == PropertyNewValue) { + return receive_incrementally (manager, xev); + } else { + return send_incrementally (manager, xev); + } + + case SelectionClear: + if (xev->xany.window != manager->priv->window) + return False; + + if (xev->xselectionclear.selection == XA_CLIPBOARD_MANAGER) { + /* We lost the manager selection */ + if (manager->priv->contents) { + list_foreach (manager->priv->contents, (Callback)target_data_unref, NULL); + list_free (manager->priv->contents); + manager->priv->contents = NULL; + + XSetSelectionOwner (manager->priv->display, + XA_CLIPBOARD, + None, manager->priv->time); + } + + return True; + } + if (xev->xselectionclear.selection == XA_CLIPBOARD) { + /* We lost the clipboard selection */ + list_foreach (manager->priv->contents, (Callback)target_data_unref, NULL); + list_free (manager->priv->contents); + manager->priv->contents = NULL; + clipboard_manager_watch_cb (manager, + manager->priv->requestor, + False, + 0, + NULL); + manager->priv->requestor = None; + + return True; + } + break; + + case SelectionNotify: + if (xev->xany.window != manager->priv->window) + return False; + + if (xev->xselection.selection == XA_CLIPBOARD) { + /* a CLIPBOARD conversion is done */ + if (xev->xselection.property == XA_TARGETS) { + XGetWindowProperty (xev->xselection.display, + xev->xselection.requestor, + xev->xselection.property, + 0, 0x1FFFFFFF, True, XA_ATOM, + &type, &format, &nitems, &remaining, + (unsigned char **) &targets); + + save_targets (manager, targets, nitems); + } else if (xev->xselection.property == XA_MULTIPLE) { + List *tmp; + + tmp = list_copy (manager->priv->contents); + list_foreach (tmp, (Callback) get_property, manager); + list_free (tmp); + + manager->priv->time = xev->xselection.time; + XSetSelectionOwner (manager->priv->display, XA_CLIPBOARD, + manager->priv->window, manager->priv->time); + + if (manager->priv->property != None) + XChangeProperty (manager->priv->display, + manager->priv->requestor, + manager->priv->property, + XA_ATOM, 32, PropModeReplace, + (unsigned char *)&XA_NULL, 1); + + if (!list_find (manager->priv->contents, + (ListFindFunc)find_content_type, (void *)XA_INCR)) { + /* all transfers done */ + send_selection_notify (manager, True); + clipboard_manager_watch_cb (manager, + manager->priv->requestor, + False, + 0, + NULL); + manager->priv->requestor = None; + } + } + else if (xev->xselection.property == None) { + send_selection_notify (manager, False); + clipboard_manager_watch_cb (manager, + manager->priv->requestor, + False, + 0, + NULL); + manager->priv->requestor = None; + } + + return True; + } + break; + + case SelectionRequest: + if (xev->xany.window != manager->priv->window) { + return False; + } + + if (xev->xselectionrequest.selection == XA_CLIPBOARD_MANAGER) { + convert_clipboard_manager (manager, xev); + return True; + } else if (xev->xselectionrequest.selection == XA_CLIPBOARD) { + convert_clipboard (manager, xev); + return True; + } + break; + + default: ; + } + + return False; +} + +static GdkFilterReturn +clipboard_manager_event_filter (GdkXEvent *xevent, + GdkEvent *event, + GsdClipboardManager *manager) +{ + if (clipboard_manager_process_event (manager, (XEvent *)xevent)) { + return GDK_FILTER_REMOVE; + } else { + return GDK_FILTER_CONTINUE; + } +} + +static void +clipboard_manager_watch_cb (GsdClipboardManager *manager, + Window window, + Bool is_start, + long mask, + void *cb_data) +{ + GdkWindow *gdkwin; + GdkDisplay *display; + + display = gdk_display_get_default (); + gdkwin = gdk_window_lookup_for_display (display, window); + + if (is_start) { + if (gdkwin == NULL) { + gdkwin = gdk_window_foreign_new_for_display (display, window); + } else { + g_object_ref (gdkwin); + } + + gdk_window_add_filter (gdkwin, + (GdkFilterFunc)clipboard_manager_event_filter, + manager); + } else { + if (gdkwin == NULL) { + return; + } + gdk_window_remove_filter (gdkwin, + (GdkFilterFunc)clipboard_manager_event_filter, + manager); + g_object_unref (gdkwin); + } +} + +static gboolean +start_clipboard_idle_cb (GsdClipboardManager *manager) +{ + XClientMessageEvent xev; + + + mate_settings_profile_start (NULL); + + init_atoms (manager->priv->display); + + /* check if there is a clipboard manager running */ + if (XGetSelectionOwner (manager->priv->display, XA_CLIPBOARD_MANAGER)) { + g_warning ("Clipboard manager is already running."); + return FALSE; + } + + manager->priv->contents = NULL; + manager->priv->conversions = NULL; + manager->priv->requestor = None; + + manager->priv->window = XCreateSimpleWindow (manager->priv->display, + DefaultRootWindow (manager->priv->display), + 0, 0, 10, 10, 0, + WhitePixel (manager->priv->display, + DefaultScreen (manager->priv->display)), + WhitePixel (manager->priv->display, + DefaultScreen (manager->priv->display))); + clipboard_manager_watch_cb (manager, + manager->priv->window, + True, + PropertyChangeMask, + NULL); + XSelectInput (manager->priv->display, + manager->priv->window, + PropertyChangeMask); + manager->priv->timestamp = get_server_time (manager->priv->display, manager->priv->window); + + XSetSelectionOwner (manager->priv->display, + XA_CLIPBOARD_MANAGER, + manager->priv->window, + manager->priv->timestamp); + + /* Check to see if we managed to claim the selection. If not, + * we treat it as if we got it then immediately lost it + */ + if (XGetSelectionOwner (manager->priv->display, XA_CLIPBOARD_MANAGER) == manager->priv->window) { + xev.type = ClientMessage; + xev.window = DefaultRootWindow (manager->priv->display); + xev.message_type = XA_MANAGER; + xev.format = 32; + xev.data.l[0] = manager->priv->timestamp; + xev.data.l[1] = XA_CLIPBOARD_MANAGER; + xev.data.l[2] = manager->priv->window; + xev.data.l[3] = 0; /* manager specific data */ + xev.data.l[4] = 0; /* manager specific data */ + + XSendEvent (manager->priv->display, + DefaultRootWindow (manager->priv->display), + False, + StructureNotifyMask, + (XEvent *)&xev); + } else { + clipboard_manager_watch_cb (manager, + manager->priv->window, + False, + 0, + NULL); + /* FIXME: manager->priv->terminate (manager->priv->cb_data); */ + } + + mate_settings_profile_end (NULL); + + return FALSE; +} + +gboolean +gsd_clipboard_manager_start (GsdClipboardManager *manager, + GError **error) +{ + mate_settings_profile_start (NULL); + + g_idle_add ((GSourceFunc) start_clipboard_idle_cb, manager); + + mate_settings_profile_end (NULL); + + return TRUE; +} + +void +gsd_clipboard_manager_stop (GsdClipboardManager *manager) +{ + g_debug ("Stopping clipboard manager"); + + clipboard_manager_watch_cb (manager, + manager->priv->window, + FALSE, + 0, + NULL); + XDestroyWindow (manager->priv->display, manager->priv->window); + + list_foreach (manager->priv->conversions, (Callback) conversion_free, NULL); + list_free (manager->priv->conversions); + + list_foreach (manager->priv->contents, (Callback) target_data_unref, NULL); + list_free (manager->priv->contents); +} + +static void +gsd_clipboard_manager_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GsdClipboardManager *self; + + self = GSD_CLIPBOARD_MANAGER (object); + + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gsd_clipboard_manager_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GsdClipboardManager *self; + + self = GSD_CLIPBOARD_MANAGER (object); + + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static GObject * +gsd_clipboard_manager_constructor (GType type, + guint n_construct_properties, + GObjectConstructParam *construct_properties) +{ + GsdClipboardManager *clipboard_manager; + GsdClipboardManagerClass *klass; + + klass = GSD_CLIPBOARD_MANAGER_CLASS (g_type_class_peek (GSD_TYPE_CLIPBOARD_MANAGER)); + + clipboard_manager = GSD_CLIPBOARD_MANAGER (G_OBJECT_CLASS (gsd_clipboard_manager_parent_class)->constructor (type, + n_construct_properties, + construct_properties)); + + return G_OBJECT (clipboard_manager); +} + +static void +gsd_clipboard_manager_dispose (GObject *object) +{ + GsdClipboardManager *clipboard_manager; + + clipboard_manager = GSD_CLIPBOARD_MANAGER (object); + + G_OBJECT_CLASS (gsd_clipboard_manager_parent_class)->dispose (object); +} + +static void +gsd_clipboard_manager_class_init (GsdClipboardManagerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->get_property = gsd_clipboard_manager_get_property; + object_class->set_property = gsd_clipboard_manager_set_property; + object_class->constructor = gsd_clipboard_manager_constructor; + object_class->dispose = gsd_clipboard_manager_dispose; + object_class->finalize = gsd_clipboard_manager_finalize; + + g_type_class_add_private (klass, sizeof (GsdClipboardManagerPrivate)); +} + +static void +gsd_clipboard_manager_init (GsdClipboardManager *manager) +{ + manager->priv = GSD_CLIPBOARD_MANAGER_GET_PRIVATE (manager); + + manager->priv->display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); + +} + +static void +gsd_clipboard_manager_finalize (GObject *object) +{ + GsdClipboardManager *clipboard_manager; + + g_return_if_fail (object != NULL); + g_return_if_fail (GSD_IS_CLIPBOARD_MANAGER (object)); + + clipboard_manager = GSD_CLIPBOARD_MANAGER (object); + + g_return_if_fail (clipboard_manager->priv != NULL); + + G_OBJECT_CLASS (gsd_clipboard_manager_parent_class)->finalize (object); +} + +GsdClipboardManager * +gsd_clipboard_manager_new (void) +{ + if (manager_object != NULL) { + g_object_ref (manager_object); + } else { + manager_object = g_object_new (GSD_TYPE_CLIPBOARD_MANAGER, NULL); + g_object_add_weak_pointer (manager_object, + (gpointer *) &manager_object); + } + + return GSD_CLIPBOARD_MANAGER (manager_object); +} diff --git a/plugins/clipboard/gsd-clipboard-manager.h b/plugins/clipboard/gsd-clipboard-manager.h new file mode 100644 index 0000000..0338799 --- /dev/null +++ b/plugins/clipboard/gsd-clipboard-manager.h @@ -0,0 +1,61 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 William Jon McCann <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#ifndef __GSD_CLIPBOARD_MANAGER_H +#define __GSD_CLIPBOARD_MANAGER_H + +#include <glib-object.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define GSD_TYPE_CLIPBOARD_MANAGER (gsd_clipboard_manager_get_type ()) +#define GSD_CLIPBOARD_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_CLIPBOARD_MANAGER, GsdClipboardManager)) +#define GSD_CLIPBOARD_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_CLIPBOARD_MANAGER, GsdClipboardManagerClass)) +#define GSD_IS_CLIPBOARD_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_CLIPBOARD_MANAGER)) +#define GSD_IS_CLIPBOARD_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_CLIPBOARD_MANAGER)) +#define GSD_CLIPBOARD_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_CLIPBOARD_MANAGER, GsdClipboardManagerClass)) + +typedef struct GsdClipboardManagerPrivate GsdClipboardManagerPrivate; + +typedef struct +{ + GObject parent; + GsdClipboardManagerPrivate *priv; +} GsdClipboardManager; + +typedef struct +{ + GObjectClass parent_class; +} GsdClipboardManagerClass; + +GType gsd_clipboard_manager_get_type (void); + +GsdClipboardManager * gsd_clipboard_manager_new (void); +gboolean gsd_clipboard_manager_start (GsdClipboardManager *manager, + GError **error); +void gsd_clipboard_manager_stop (GsdClipboardManager *manager); + +#ifdef __cplusplus +} +#endif + +#endif /* __GSD_CLIPBOARD_MANAGER_H */ diff --git a/plugins/clipboard/gsd-clipboard-plugin.c b/plugins/clipboard/gsd-clipboard-plugin.c new file mode 100644 index 0000000..f384b52 --- /dev/null +++ b/plugins/clipboard/gsd-clipboard-plugin.c @@ -0,0 +1,104 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 William Jon McCann <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#include "config.h" + +#include <glib/gi18n-lib.h> +#include <gmodule.h> + +#include "mate-settings-plugin.h" +#include "gsd-clipboard-plugin.h" +#include "gsd-clipboard-manager.h" + +struct GsdClipboardPluginPrivate { + GsdClipboardManager *manager; +}; + +#define GSD_CLIPBOARD_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GSD_TYPE_CLIPBOARD_PLUGIN, GsdClipboardPluginPrivate)) + +MATE_SETTINGS_PLUGIN_REGISTER (GsdClipboardPlugin, gsd_clipboard_plugin) + +static void +gsd_clipboard_plugin_init (GsdClipboardPlugin *plugin) +{ + plugin->priv = GSD_CLIPBOARD_PLUGIN_GET_PRIVATE (plugin); + + g_debug ("GsdClipboardPlugin initializing"); + + plugin->priv->manager = gsd_clipboard_manager_new (); +} + +static void +gsd_clipboard_plugin_finalize (GObject *object) +{ + GsdClipboardPlugin *plugin; + + g_return_if_fail (object != NULL); + g_return_if_fail (GSD_IS_CLIPBOARD_PLUGIN (object)); + + g_debug ("GsdClipboardPlugin finalizing"); + + plugin = GSD_CLIPBOARD_PLUGIN (object); + + g_return_if_fail (plugin->priv != NULL); + + if (plugin->priv->manager != NULL) { + g_object_unref (plugin->priv->manager); + } + + G_OBJECT_CLASS (gsd_clipboard_plugin_parent_class)->finalize (object); +} + +static void +impl_activate (MateSettingsPlugin *plugin) +{ + gboolean res; + GError *error; + + g_debug ("Activating clipboard plugin"); + + error = NULL; + res = gsd_clipboard_manager_start (GSD_CLIPBOARD_PLUGIN (plugin)->priv->manager, &error); + if (! res) { + g_warning ("Unable to start clipboard manager: %s", error->message); + g_error_free (error); + } +} + +static void +impl_deactivate (MateSettingsPlugin *plugin) +{ + g_debug ("Deactivating clipboard plugin"); + gsd_clipboard_manager_stop (GSD_CLIPBOARD_PLUGIN (plugin)->priv->manager); +} + +static void +gsd_clipboard_plugin_class_init (GsdClipboardPluginClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + MateSettingsPluginClass *plugin_class = MATE_SETTINGS_PLUGIN_CLASS (klass); + + object_class->finalize = gsd_clipboard_plugin_finalize; + + plugin_class->activate = impl_activate; + plugin_class->deactivate = impl_deactivate; + + g_type_class_add_private (klass, sizeof (GsdClipboardPluginPrivate)); +} diff --git a/plugins/clipboard/gsd-clipboard-plugin.h b/plugins/clipboard/gsd-clipboard-plugin.h new file mode 100644 index 0000000..4148c09 --- /dev/null +++ b/plugins/clipboard/gsd-clipboard-plugin.h @@ -0,0 +1,63 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 William Jon McCann <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#ifndef __GSD_CLIPBOARD_PLUGIN_H__ +#define __GSD_CLIPBOARD_PLUGIN_H__ + +#include <glib.h> +#include <glib-object.h> +#include <gmodule.h> + +#include "mate-settings-plugin.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define GSD_TYPE_CLIPBOARD_PLUGIN (gsd_clipboard_plugin_get_type ()) +#define GSD_CLIPBOARD_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_CLIPBOARD_PLUGIN, GsdClipboardPlugin)) +#define GSD_CLIPBOARD_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_CLIPBOARD_PLUGIN, GsdClipboardPluginClass)) +#define GSD_IS_CLIPBOARD_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_CLIPBOARD_PLUGIN)) +#define GSD_IS_CLIPBOARD_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_CLIPBOARD_PLUGIN)) +#define GSD_CLIPBOARD_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_CLIPBOARD_PLUGIN, GsdClipboardPluginClass)) + +typedef struct GsdClipboardPluginPrivate GsdClipboardPluginPrivate; + +typedef struct +{ + MateSettingsPlugin parent; + GsdClipboardPluginPrivate *priv; +} GsdClipboardPlugin; + +typedef struct +{ + MateSettingsPluginClass parent_class; +} GsdClipboardPluginClass; + +GType gsd_clipboard_plugin_get_type (void) G_GNUC_CONST; + +/* All the plugins must implement this function */ +G_MODULE_EXPORT GType register_mate_settings_plugin (GTypeModule *module); + +#ifdef __cplusplus +} +#endif + +#endif /* __GSD_CLIPBOARD_PLUGIN_H__ */ diff --git a/plugins/clipboard/list.c b/plugins/clipboard/list.c new file mode 100644 index 0000000..477eead --- /dev/null +++ b/plugins/clipboard/list.c @@ -0,0 +1,150 @@ +/* + * Copyright © 2004 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Red Hat not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Red Hat makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Matthias Clasen, Red Hat, Inc. + */ + +#include <stdlib.h> +#include <list.h> + + +void +list_foreach (List *list, + Callback func, + void *user_data) +{ + while (list) + { + func (list->data, user_data); + + list = list->next; + } +} + +List * +list_prepend (List *list, + void *data) +{ + List *link; + + link = (List *) malloc (sizeof (List)); + link->next = list; + link->data = data; + + return link; +} + +void +list_free (List *list) +{ + while (list) + { + List *next = list->next; + + free (list); + + list = next; + } +} + +List * +list_find (List *list, + ListFindFunc func, + void *user_data) +{ + List *tmp; + + for (tmp = list; tmp; tmp = tmp->next) + { + if ((*func) (tmp->data, user_data)) + break; + } + + return tmp; +} + +List * +list_remove (List *list, + void *data) +{ + List *tmp, *prev; + + prev = NULL; + for (tmp = list; tmp; tmp = tmp->next) + { + if (tmp->data == data) + { + if (prev) + prev->next = tmp->next; + else + list = tmp->next; + + free (tmp); + break; + } + + prev = tmp; + } + + return list; +} + +int +list_length (List *list) +{ + List *tmp; + int length; + + length = 0; + for (tmp = list; tmp; tmp = tmp->next) + length++; + + return length; +} + +List * +list_copy (List *list) +{ + List *new_list = NULL; + + if (list) + { + List *last; + + new_list = (List *) malloc (sizeof (List)); + new_list->data = list->data; + new_list->next = NULL; + + last = new_list; + list = list->next; + + while (list) + { + last->next = (List *) malloc (sizeof (List)); + last = last->next; + last->data = list->data; + list = list->next; + } + + last->next = NULL; + } + + return new_list; +} diff --git a/plugins/clipboard/list.h b/plugins/clipboard/list.h new file mode 100644 index 0000000..158b779 --- /dev/null +++ b/plugins/clipboard/list.h @@ -0,0 +1,57 @@ +/* + * Copyright © 2004 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Red Hat not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Red Hat makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Matthias Clasen, Red Hat, Inc. + */ +#ifndef LIST_H +#define LIST_H + + +typedef struct _List List; +typedef void (*Callback) (void *data, + void *user_data); + + +struct _List +{ + void *data; + + List *next; +}; + +typedef int (*ListFindFunc) (void *data, + void *user_data); + +void list_foreach (List *list, + Callback func, + void *user_data); +List *list_prepend (List *list, + void *data); +void list_free (List *list); +List *list_find (List *list, + ListFindFunc func, + void *user_data); +List *list_remove (List *list, + void *data); +int list_length (List *list); + +List *list_copy (List *list); + +#endif /* LIST_H */ diff --git a/plugins/clipboard/xutils.c b/plugins/clipboard/xutils.c new file mode 100644 index 0000000..4e48b98 --- /dev/null +++ b/plugins/clipboard/xutils.c @@ -0,0 +1,117 @@ +/* + * Copyright © 2004 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Red Hat not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Red Hat makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Matthias Clasen, Red Hat, Inc. + */ + +#include <stdlib.h> + +#include "xutils.h" + +Atom XA_ATOM_PAIR; +Atom XA_CLIPBOARD_MANAGER; +Atom XA_CLIPBOARD; +Atom XA_DELETE; +Atom XA_INCR; +Atom XA_INSERT_PROPERTY; +Atom XA_INSERT_SELECTION; +Atom XA_MANAGER; +Atom XA_MULTIPLE; +Atom XA_NULL; +Atom XA_SAVE_TARGETS; +Atom XA_TARGETS; +Atom XA_TIMESTAMP; + +unsigned long SELECTION_MAX_SIZE = 0; + + +void +init_atoms (Display *display) +{ + unsigned long max_request_size; + + if (SELECTION_MAX_SIZE > 0) + return; + + XA_ATOM_PAIR = XInternAtom (display, "ATOM_PAIR", False); + XA_CLIPBOARD_MANAGER = XInternAtom (display, "CLIPBOARD_MANAGER", False); + XA_CLIPBOARD = XInternAtom (display, "CLIPBOARD", False); + XA_DELETE = XInternAtom (display, "DELETE", False); + XA_INCR = XInternAtom (display, "INCR", False); + XA_INSERT_PROPERTY = XInternAtom (display, "INSERT_PROPERTY", False); + XA_INSERT_SELECTION = XInternAtom (display, "INSERT_SELECTION", False); + XA_MANAGER = XInternAtom (display, "MANAGER", False); + XA_MULTIPLE = XInternAtom (display, "MULTIPLE", False); + XA_NULL = XInternAtom (display, "NULL", False); + XA_SAVE_TARGETS = XInternAtom (display, "SAVE_TARGETS", False); + XA_TARGETS = XInternAtom (display, "TARGETS", False); + XA_TIMESTAMP = XInternAtom (display, "TIMESTAMP", False); + + max_request_size = XExtendedMaxRequestSize (display); + if (max_request_size == 0) + max_request_size = XMaxRequestSize (display); + + SELECTION_MAX_SIZE = max_request_size - 100; + if (SELECTION_MAX_SIZE > 262144) + SELECTION_MAX_SIZE = 262144; +} + +typedef struct +{ + Window window; + Atom timestamp_prop_atom; +} TimeStampInfo; + +static Bool +timestamp_predicate (Display *display, + XEvent *xevent, + XPointer arg) +{ + TimeStampInfo *info = (TimeStampInfo *)arg; + + if (xevent->type == PropertyNotify && + xevent->xproperty.window == info->window && + xevent->xproperty.atom == info->timestamp_prop_atom) + return True; + + return False; +} + +Time +get_server_time (Display *display, + Window window) +{ + unsigned char c = 'a'; + XEvent xevent; + TimeStampInfo info; + + info.timestamp_prop_atom = XInternAtom (display, "_TIMESTAMP_PROP", False); + info.window = window; + + XChangeProperty (display, window, + info.timestamp_prop_atom, info.timestamp_prop_atom, + 8, PropModeReplace, &c, 1); + + XIfEvent (display, &xevent, + timestamp_predicate, (XPointer)&info); + + return xevent.xproperty.time; +} + diff --git a/plugins/clipboard/xutils.h b/plugins/clipboard/xutils.h new file mode 100644 index 0000000..143fe44 --- /dev/null +++ b/plugins/clipboard/xutils.h @@ -0,0 +1,50 @@ +/* + * Copyright © 2004 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Red Hat not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Red Hat makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Matthias Clasen, Red Hat, Inc. + */ +#ifndef X_UTILS_H +#define X_UTILS_H + +#include <X11/Xlib.h> + + +extern Atom XA_ATOM_PAIR; +extern Atom XA_CLIPBOARD_MANAGER; +extern Atom XA_CLIPBOARD; +extern Atom XA_DELETE; +extern Atom XA_INCR; +extern Atom XA_INSERT_PROPERTY; +extern Atom XA_INSERT_SELECTION; +extern Atom XA_MANAGER; +extern Atom XA_MULTIPLE; +extern Atom XA_NULL; +extern Atom XA_SAVE_TARGETS; +extern Atom XA_TARGETS; +extern Atom XA_TIMESTAMP; + +extern unsigned long SELECTION_MAX_SIZE; + +void init_atoms (Display *display); + +Time get_server_time (Display *display, + Window window); + +#endif /* X_UTILS_H */ |