diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2020-11-22 20:30:04 +0000 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2020-11-22 20:33:07 +0000 |
commit | 148aec9d9c79bd1eff54c7f82d404456a2fcd9d8 (patch) | |
tree | 7e2a812d55af22543479e36cd8be966690bbec68 /src | |
parent | 5f8e4dabeae5a04ceadba458a4a87111ef0c2d19 (diff) |
ecore-x - add xresource set/get/load etc.
new ecore-x calls to support the things xrdb does
@feat
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/ecore_x/Ecore_X.h | 5 | ||||
-rw-r--r-- | src/lib/ecore_x/ecore_x.c | 1 | ||||
-rw-r--r-- | src/lib/ecore_x/ecore_x_private.h | 2 | ||||
-rw-r--r-- | src/lib/ecore_x/ecore_x_resource.c | 116 | ||||
-rw-r--r-- | src/lib/ecore_x/meson.build | 1 |
5 files changed, 125 insertions, 0 deletions
diff --git a/src/lib/ecore_x/Ecore_X.h b/src/lib/ecore_x/Ecore_X.h index 4a1ab61472..ae82a549ce 100644 --- a/src/lib/ecore_x/Ecore_X.h +++ b/src/lib/ecore_x/Ecore_X.h | |||
@@ -2802,6 +2802,11 @@ EAPI Eina_Bool ecore_x_window_keygrab_unset(Ecore_X_ | |||
2802 | EAPI void ecore_x_e_keyrouter_set(Ecore_X_Window root, Eina_Bool on); /**< @since 1.15 */ //Key router set keyrouter flag using this | 2802 | EAPI void ecore_x_e_keyrouter_set(Ecore_X_Window root, Eina_Bool on); /**< @since 1.15 */ //Key router set keyrouter flag using this |
2803 | EAPI Eina_Bool ecore_x_e_keyrouter_get(Ecore_X_Window root); /**< @since 1.15 */ //Client check the existence of keyrouter using this | 2803 | EAPI Eina_Bool ecore_x_e_keyrouter_get(Ecore_X_Window root); /**< @since 1.15 */ //Client check the existence of keyrouter using this |
2804 | 2804 | ||
2805 | EAPI void ecore_x_rersource_load(const char *file); /** @since 1.26 */ | ||
2806 | EAPI void ecore_x_resource_db_string_set(const char *key, const char *val); /** @since 1.26 */ | ||
2807 | EAPI const char *ecore_x_resource_db_string_get(const char *key); /** @since 1.26 */ | ||
2808 | EAPI void ecore_x_resource_db_flush(void); /** @since 1.26 */ | ||
2809 | |||
2805 | #ifdef EFL_BETA_API_SUPPORT | 2810 | #ifdef EFL_BETA_API_SUPPORT |
2806 | // XXX: FIXME: re-evaluate this after looking at xdg foreign in wayland | 2811 | // XXX: FIXME: re-evaluate this after looking at xdg foreign in wayland |
2807 | EAPI void ecore_x_e_stack_type_set(Ecore_X_Window win, Ecore_X_Stack_Type stack_type); | 2812 | EAPI void ecore_x_e_stack_type_set(Ecore_X_Window win, Ecore_X_Stack_Type stack_type); |
diff --git a/src/lib/ecore_x/ecore_x.c b/src/lib/ecore_x/ecore_x.c index 0ad3befd22..c78e6adbb1 100644 --- a/src/lib/ecore_x/ecore_x.c +++ b/src/lib/ecore_x/ecore_x.c | |||
@@ -836,6 +836,7 @@ _ecore_x_shutdown(void) | |||
836 | _ecore_x_input_shutdown(); | 836 | _ecore_x_input_shutdown(); |
837 | _ecore_x_selection_shutdown(); | 837 | _ecore_x_selection_shutdown(); |
838 | _ecore_x_dnd_shutdown(); | 838 | _ecore_x_dnd_shutdown(); |
839 | _ecore_x_resource_shutdown(); | ||
839 | ecore_x_netwm_shutdown(); | 840 | ecore_x_netwm_shutdown(); |
840 | 841 | ||
841 | return 0; | 842 | return 0; |
diff --git a/src/lib/ecore_x/ecore_x_private.h b/src/lib/ecore_x/ecore_x_private.h index d0d6a9c168..ec14111b70 100644 --- a/src/lib/ecore_x/ecore_x_private.h +++ b/src/lib/ecore_x/ecore_x_private.h | |||
@@ -383,6 +383,8 @@ Ecore_Event_Mouse_Button *_ecore_mouse_button(int event, | |||
383 | void _ecore_x_modifiers_get(void); | 383 | void _ecore_x_modifiers_get(void); |
384 | KeySym _ecore_x_XKeycodeToKeysym(Display *display, KeyCode keycode, int index); | 384 | KeySym _ecore_x_XKeycodeToKeysym(Display *display, KeyCode keycode, int index); |
385 | 385 | ||
386 | void _ecore_x_resource_shutdown(void); | ||
387 | |||
386 | int _ecore_x_shutdown(void); | 388 | int _ecore_x_shutdown(void); |
387 | //#define LOGFNS 1 | 389 | //#define LOGFNS 1 |
388 | 390 | ||
diff --git a/src/lib/ecore_x/ecore_x_resource.c b/src/lib/ecore_x/ecore_x_resource.c new file mode 100644 index 0000000000..c4b7eed3b1 --- /dev/null +++ b/src/lib/ecore_x/ecore_x_resource.c | |||
@@ -0,0 +1,116 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif /* ifdef HAVE_CONFIG_H */ | ||
4 | |||
5 | #include "ecore_x_private.h" | ||
6 | |||
7 | static Eina_Bool _ecore_x_resource_initted = EINA_FALSE; | ||
8 | static XrmDatabase _ecore_x_resource_db = NULL; | ||
9 | |||
10 | static void | ||
11 | _ecore_x_resource_init(void) | ||
12 | { | ||
13 | if (_ecore_x_resource_initted) return; | ||
14 | XrmInitialize(); | ||
15 | _ecore_x_resource_initted = EINA_TRUE; | ||
16 | } | ||
17 | |||
18 | void | ||
19 | _ecore_x_resource_shutdown(void) | ||
20 | { | ||
21 | if (!_ecore_x_disp) return; | ||
22 | if (!_ecore_x_resource_initted) return; | ||
23 | if (_ecore_x_resource_db) _ecore_x_resource_db = NULL; | ||
24 | _ecore_x_resource_initted = EINA_FALSE; | ||
25 | } | ||
26 | |||
27 | EAPI void | ||
28 | ecore_x_rersource_load(const char *file) | ||
29 | { | ||
30 | XrmDatabase db; | ||
31 | |||
32 | if (!_ecore_x_disp) return; | ||
33 | _ecore_x_resource_init(); | ||
34 | db = XrmGetFileDatabase(file); | ||
35 | if (!db) return; | ||
36 | if (_ecore_x_resource_db) XrmDestroyDatabase(_ecore_x_resource_db); | ||
37 | _ecore_x_resource_db = db; | ||
38 | XrmSetDatabase(_ecore_x_disp, db); | ||
39 | } | ||
40 | |||
41 | EAPI void | ||
42 | ecore_x_resource_db_string_set(const char *key, const char *val) | ||
43 | { | ||
44 | if (!_ecore_x_disp) return; | ||
45 | _ecore_x_resource_init(); | ||
46 | if ((!key) || (!val)) return; | ||
47 | if (!_ecore_x_resource_db) | ||
48 | _ecore_x_resource_db = XrmGetDatabase(_ecore_x_disp); | ||
49 | XrmPutStringResource(&_ecore_x_resource_db, key, val); | ||
50 | } | ||
51 | |||
52 | EAPI const char * | ||
53 | ecore_x_resource_db_string_get(const char *key) | ||
54 | { | ||
55 | char *type = NULL; | ||
56 | XrmValue xval = { 0, NULL }; | ||
57 | |||
58 | if (!_ecore_x_disp) return NULL; | ||
59 | _ecore_x_resource_init(); | ||
60 | if (!_ecore_x_resource_db) | ||
61 | _ecore_x_resource_db = XrmGetDatabase(_ecore_x_disp); | ||
62 | if (XrmGetResource(_ecore_x_resource_db, key, "String", &type, &xval)) | ||
63 | { | ||
64 | if (xval.addr && (!strcmp(type, "String"))) | ||
65 | { | ||
66 | if (xval.size > 0) return xval.addr; | ||
67 | } | ||
68 | } | ||
69 | return NULL; | ||
70 | } | ||
71 | |||
72 | EAPI void | ||
73 | ecore_x_resource_db_flush(void) | ||
74 | { | ||
75 | Ecore_X_Atom atom, type; | ||
76 | Ecore_X_Window *roots; | ||
77 | int i, num, fd; | ||
78 | char *str; | ||
79 | Eina_Tmpstr *path = NULL; | ||
80 | off_t offset; | ||
81 | |||
82 | if (!_ecore_x_disp) return; | ||
83 | _ecore_x_resource_init(); | ||
84 | if (!_ecore_x_resource_db) return; | ||
85 | fd = eina_file_mkstemp("ecore-x-resource-XXXXXX", &path); | ||
86 | if (fd < 0) return; | ||
87 | XrmPutFileDatabase(_ecore_x_resource_db, path); | ||
88 | offset = lseek(fd, 0, SEEK_END); | ||
89 | if (offset > 0) | ||
90 | { | ||
91 | lseek(fd, 0, SEEK_SET); | ||
92 | str = malloc(offset + 1); | ||
93 | if (str) | ||
94 | { | ||
95 | if (read(fd, str, offset) == offset) | ||
96 | { | ||
97 | str[offset] = 0; | ||
98 | atom = XInternAtom(_ecore_x_disp, "RESOURCE_MANAGER", False); | ||
99 | type = ECORE_X_ATOM_STRING; | ||
100 | roots = ecore_x_window_root_list(&num); | ||
101 | if (roots) | ||
102 | { | ||
103 | for (i = 0; i < num; i++) | ||
104 | ecore_x_window_prop_property_set(roots[i], | ||
105 | atom, type, | ||
106 | 8, str, offset); | ||
107 | free(roots); | ||
108 | } | ||
109 | } | ||
110 | free(str); | ||
111 | } | ||
112 | } | ||
113 | eina_tmpstr_del(path); | ||
114 | close(fd); | ||
115 | unlink(path); | ||
116 | } | ||
diff --git a/src/lib/ecore_x/meson.build b/src/lib/ecore_x/meson.build index 608d3cda22..c62ec4df99 100644 --- a/src/lib/ecore_x/meson.build +++ b/src/lib/ecore_x/meson.build | |||
@@ -43,6 +43,7 @@ ecore_x_src = files([ | |||
43 | 'ecore_x_xi2.c', | 43 | 'ecore_x_xi2.c', |
44 | 'ecore_x_vsync.c', | 44 | 'ecore_x_vsync.c', |
45 | 'ecore_x_gesture.c', | 45 | 'ecore_x_gesture.c', |
46 | 'ecore_x_resource.c', | ||
46 | 'ecore_x_private.h' | 47 | 'ecore_x_private.h' |
47 | ]) | 48 | ]) |
48 | 49 | ||