diff options
Diffstat (limited to 'libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_mwm.c')
-rw-r--r-- | libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_mwm.c | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_mwm.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_mwm.c new file mode 100644 index 0000000..6c95331 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_mwm.c | |||
@@ -0,0 +1,104 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | //#include "Ecore_X_Atoms.h" | ||
3 | |||
4 | #define ECORE_X_MWM_HINTS_FUNCTIONS (1 << 0) | ||
5 | #define ECORE_X_MWM_HINTS_DECORATIONS (1 << 1) | ||
6 | #define ECORE_X_MWM_HINTS_INPUT_MODE (1 << 2) | ||
7 | #define ECORE_X_MWM_HINTS_STATUS (1 << 3) | ||
8 | |||
9 | typedef struct _mwmhints | ||
10 | { | ||
11 | uint32_t flags; | ||
12 | uint32_t functions; | ||
13 | uint32_t decorations; | ||
14 | int32_t inputmode; | ||
15 | uint32_t status; | ||
16 | } MWMHints; | ||
17 | |||
18 | /** | ||
19 | * @defgroup Ecore_X_MWM_Group MWM related functions. | ||
20 | * | ||
21 | * Functions related to MWM. | ||
22 | */ | ||
23 | |||
24 | /** | ||
25 | * Sets the borderless flag of a window using MWM. | ||
26 | * | ||
27 | * @param win The window. | ||
28 | * @param borderless The borderless flag. | ||
29 | * | ||
30 | * @ingroup Ecore_X_MWM_Group | ||
31 | */ | ||
32 | EAPI void | ||
33 | ecore_x_mwm_borderless_set(Ecore_X_Window win, | ||
34 | Eina_Bool borderless) | ||
35 | { | ||
36 | uint32_t data[5] = { 0, 0, 0, 0, 0 }; | ||
37 | |||
38 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
39 | |||
40 | data[0] = 2; | ||
41 | data[2] = !borderless; | ||
42 | |||
43 | ecore_x_window_prop_property_set(win, | ||
44 | ECORE_X_ATOM_MOTIF_WM_HINTS, | ||
45 | ECORE_X_ATOM_MOTIF_WM_HINTS, 32, | ||
46 | (void *)data, 5); | ||
47 | } | ||
48 | |||
49 | EAPI Eina_Bool | ||
50 | ecore_x_mwm_hints_get(Ecore_X_Window win, | ||
51 | Ecore_X_MWM_Hint_Func *fhint, | ||
52 | Ecore_X_MWM_Hint_Decor *dhint, | ||
53 | Ecore_X_MWM_Hint_Input *ihint) | ||
54 | { | ||
55 | xcb_get_property_cookie_t cookie; | ||
56 | xcb_get_property_reply_t *reply; | ||
57 | MWMHints *mwmhints = NULL; | ||
58 | int ret = EINA_FALSE; | ||
59 | |||
60 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
61 | CHECK_XCB_CONN; | ||
62 | |||
63 | cookie = | ||
64 | xcb_get_property_unchecked(_ecore_xcb_conn, 0, win, | ||
65 | ECORE_X_ATOM_MOTIF_WM_HINTS, | ||
66 | ECORE_X_ATOM_MOTIF_WM_HINTS, 0, UINT_MAX); | ||
67 | reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL); | ||
68 | if (!reply) return EINA_FALSE; | ||
69 | if ((reply->format != 32) || (reply->value_len == 0)) | ||
70 | { | ||
71 | free(reply); | ||
72 | return EINA_FALSE; | ||
73 | } | ||
74 | |||
75 | mwmhints = xcb_get_property_value(reply); | ||
76 | if (reply->value_len >= 4) | ||
77 | { | ||
78 | if (dhint) | ||
79 | { | ||
80 | if (mwmhints->flags & ECORE_X_MWM_HINTS_DECORATIONS) | ||
81 | *dhint = mwmhints->decorations; | ||
82 | else | ||
83 | *dhint = ECORE_X_MWM_HINT_DECOR_ALL; | ||
84 | } | ||
85 | if (fhint) | ||
86 | { | ||
87 | if (mwmhints->flags & ECORE_X_MWM_HINTS_FUNCTIONS) | ||
88 | *fhint = mwmhints->functions; | ||
89 | else | ||
90 | *fhint = ECORE_X_MWM_HINT_FUNC_ALL; | ||
91 | } | ||
92 | if (ihint) | ||
93 | { | ||
94 | if (mwmhints->flags & ECORE_X_MWM_HINTS_INPUT_MODE) | ||
95 | *ihint = mwmhints->inputmode; | ||
96 | else | ||
97 | *ihint = ECORE_X_MWM_HINT_INPUT_MODELESS; | ||
98 | } | ||
99 | ret = EINA_TRUE; | ||
100 | } | ||
101 | free(reply); | ||
102 | return ret; | ||
103 | } | ||
104 | |||