1 #include "e_mod_main.h"
2
3 #ifndef HAVE_WAYLAND_ONLY
4 static Evry_Action *act;
5 static Ecore_Window clipboard_win = 0;
6
7 static int
_action(Evry_Action * action)8 _action(Evry_Action *action)
9 {
10 const Evry_Item *it;
11
12 if (e_comp->comp_type != E_PIXMAP_TYPE_X) return 0;
13 it = action->it1.item;
14 ecore_x_selection_primary_set(clipboard_win, it->label, strlen(it->label));
15 ecore_x_selection_clipboard_set(clipboard_win, it->label, strlen(it->label));
16 return 1;
17 }
18
19 static int
_check_item(Evry_Action * action EINA_UNUSED,const Evry_Item * it)20 _check_item(Evry_Action *action EINA_UNUSED, const Evry_Item *it)
21 {
22 return it && it->label && (strlen(it->label) > 0);
23 }
24 #endif
25 Eina_Bool
evry_plug_clipboard_init(void)26 evry_plug_clipboard_init(void)
27 {
28 #ifndef HAVE_WAYLAND_ONLY
29 Ecore_Window win;
30 #endif
31
32 if (!evry_api_version_check(EVRY_API_VERSION))
33 return EINA_FALSE;
34
35 if (e_comp->comp_type != E_PIXMAP_TYPE_X)
36 return EINA_FALSE;
37 #ifndef HAVE_WAYLAND_ONLY
38 win = ecore_x_window_input_new(0, 0, 0, 1, 1);
39 if (!win) return EINA_FALSE;
40 ecore_x_icccm_name_class_set(win, "evry", "clipboard");
41 e_comp_ignore_win_add(E_PIXMAP_TYPE_X, win);
42
43 //FIXME: Icon name doesn't follow FDO Spec
44 act = EVRY_ACTION_NEW(N_("Copy to Clipboard"),
45 EVRY_TYPE_TEXT, 0,
46 "everything-clipboard",
47 _action, _check_item);
48 act->remember_context = EINA_TRUE;
49 evry_action_register(act, 10);
50
51 clipboard_win = win;
52
53 return EINA_TRUE;
54 #endif
55
56 return EINA_TRUE;
57 }
58
59 void
evry_plug_clipboard_shutdown(void)60 evry_plug_clipboard_shutdown(void)
61 {
62 if (e_comp->comp_type != E_PIXMAP_TYPE_X) return;
63 #ifndef HAVE_WAYLAND_ONLY
64 ecore_x_window_free(clipboard_win);
65 evry_action_free(act);
66 #endif
67 }
68
69