Revert "efl_ui_win: resize window properly after rotation"
[platform/upstream/efl.git] / src / lib / ecore_x / 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;
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      {
52         if (p) free(p);
53         return EINA_FALSE;
54      }
55
56    mwmhints = (MWMHints *)p;
57    if (mwmhints)
58      {
59         if (num >= 4)
60           {
61              if (dhint)
62                {
63                   if (mwmhints->flags & ECORE_X_MWM_HINTS_DECORATIONS)
64                     *dhint = mwmhints->decorations;
65                   else
66                     *dhint = ECORE_X_MWM_HINT_DECOR_ALL;
67                }
68
69              if (fhint)
70                {
71                   if (mwmhints->flags & ECORE_X_MWM_HINTS_FUNCTIONS)
72                     *fhint = mwmhints->functions;
73                   else
74                     *fhint = ECORE_X_MWM_HINT_FUNC_ALL;
75                }
76
77              if (ihint)
78                {
79                   if (mwmhints->flags & ECORE_X_MWM_HINTS_INPUT_MODE)
80                     *ihint = mwmhints->inputmode;
81                   else
82                     *ihint = ECORE_X_MWM_HINT_INPUT_MODELESS;
83                }
84
85              ret = EINA_TRUE;
86           }
87
88         free(mwmhints);
89      }
90
91    return ret;
92 }
93
94 EAPI void
95 ecore_x_mwm_borderless_set(Ecore_X_Window win,
96                            Eina_Bool borderless)
97 {
98    unsigned int data[5] = {0, 0, 0, 0, 0};
99
100    data[0] = 2; /* just set the decorations hint! */
101    data[2] = !borderless;
102
103    LOGFN;
104    ecore_x_window_prop_property_set(win,
105                                     ECORE_X_ATOM_MOTIF_WM_HINTS,
106                                     ECORE_X_ATOM_MOTIF_WM_HINTS,
107                                     32, (void *)data, 5);
108 }
109