Initialize Tizen 2.3
[framework/uifw/ecore.git] / wearable / src / lib / ecore_x / xlib / ecore_x_mwm.c
1 /*
2  * Various MWM related functions.
3  *
4  * This is ALL the code involving anything MWM related. for both WM and
5  * client.
6  */
7
8 #ifdef HAVE_CONFIG_H
9 # include <config.h>
10 #endif /* ifdef HAVE_CONFIG_H */
11
12 #include <stdlib.h>
13
14 #include "Ecore.h"
15 #include "ecore_x_private.h"
16 #include "Ecore_X.h"
17 #include "Ecore_X_Atoms.h"
18
19 #define ECORE_X_MWM_HINTS_FUNCTIONS   (1 << 0)
20 #define ECORE_X_MWM_HINTS_DECORATIONS (1 << 1)
21 #define ECORE_X_MWM_HINTS_INPUT_MODE  (1 << 2)
22 #define ECORE_X_MWM_HINTS_STATUS      (1 << 3)
23
24 typedef struct _mwmhints
25 {
26    CARD32 flags;
27    CARD32 functions;
28    CARD32 decorations;
29    INT32  inputmode;
30    CARD32 status;
31 }
32 MWMHints;
33
34 EAPI Eina_Bool
35 ecore_x_mwm_hints_get(Ecore_X_Window win,
36                       Ecore_X_MWM_Hint_Func *fhint,
37                       Ecore_X_MWM_Hint_Decor *dhint,
38                       Ecore_X_MWM_Hint_Input *ihint)
39 {
40    unsigned char *p = NULL;
41    MWMHints *mwmhints = NULL;
42    int num;
43    Eina_Bool ret;
44
45    LOGFN(__FILE__, __LINE__, __FUNCTION__);
46    ret = EINA_FALSE;
47    if (!ecore_x_window_prop_property_get(win,
48                                          ECORE_X_ATOM_MOTIF_WM_HINTS,
49                                          ECORE_X_ATOM_MOTIF_WM_HINTS,
50                                          32, &p, &num))
51      return EINA_FALSE;
52
53    mwmhints = (MWMHints *)p;
54    if (mwmhints)
55      {
56         if (num >= 4)
57           {
58              if (dhint)
59                {
60                   if (mwmhints->flags & ECORE_X_MWM_HINTS_DECORATIONS)
61                     *dhint = mwmhints->decorations;
62                   else
63                     *dhint = ECORE_X_MWM_HINT_DECOR_ALL;
64                }
65
66              if (fhint)
67                {
68                   if (mwmhints->flags & ECORE_X_MWM_HINTS_FUNCTIONS)
69                     *fhint = mwmhints->functions;
70                   else
71                     *fhint = ECORE_X_MWM_HINT_FUNC_ALL;
72                }
73
74              if (ihint)
75                {
76                   if (mwmhints->flags & ECORE_X_MWM_HINTS_INPUT_MODE)
77                     *ihint = mwmhints->inputmode;
78                   else
79                     *ihint = ECORE_X_MWM_HINT_INPUT_MODELESS;
80                }
81
82              ret = EINA_TRUE;
83           }
84
85         free(mwmhints);
86      }
87
88    return ret;
89 }
90
91 EAPI void
92 ecore_x_mwm_borderless_set(Ecore_X_Window win,
93                            Eina_Bool borderless)
94 {
95    unsigned int data[5] = {0, 0, 0, 0, 0};
96
97    data[0] = 2; /* just set the decorations hint! */
98    data[2] = !borderless;
99
100    LOGFN(__FILE__, __LINE__, __FUNCTION__);
101    ecore_x_window_prop_property_set(win,
102                                     ECORE_X_ATOM_MOTIF_WM_HINTS,
103                                     ECORE_X_ATOM_MOTIF_WM_HINTS,
104                                     32, (void *)data, 5);
105 }
106