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