c009c7a038d5a532999d69600749ffe1d8b77c6e
[framework/uifw/ecore.git] / 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 #include "Ecore.h"
8 #include "ecore_x_private.h"
9 #include "Ecore_X.h"
10 #include "Ecore_X_Atoms.h"
11
12 #define ECORE_X_MWM_HINTS_FUNCTIONS           (1 << 0)
13 #define ECORE_X_MWM_HINTS_DECORATIONS         (1 << 1)
14 #define ECORE_X_MWM_HINTS_INPUT_MODE          (1 << 2)
15 #define ECORE_X_MWM_HINTS_STATUS              (1 << 3)
16
17 typedef struct _mwmhints
18 {
19    CARD32              flags;
20    CARD32              functions;
21    CARD32              decorations;
22    INT32               inputmode;
23    CARD32              status;
24 }
25 MWMHints;
26
27 EAPI int
28 ecore_x_mwm_hints_get(Ecore_X_Window win,
29                       Ecore_X_MWM_Hint_Func * fhint,
30                       Ecore_X_MWM_Hint_Decor * dhint,
31                       Ecore_X_MWM_Hint_Input * ihint)
32 {
33    unsigned char      *p = NULL;
34    MWMHints           *mwmhints = NULL;
35    int                 num;
36    int                 ret;
37
38    ret = 0;
39    if (!ecore_x_window_prop_property_get(win,
40                                          ECORE_X_ATOM_MOTIF_WM_HINTS,
41                                          ECORE_X_ATOM_MOTIF_WM_HINTS,
42                                          32, &p, &num))
43       return 0;
44    mwmhints = (MWMHints *) p;
45    if (mwmhints)
46      {
47         if (num >= 4)
48           {
49              if (dhint)
50                {
51                   if (mwmhints->flags & ECORE_X_MWM_HINTS_DECORATIONS)
52                      *dhint = mwmhints->decorations;
53                   else
54                      *dhint = ECORE_X_MWM_HINT_DECOR_ALL;
55                }
56              if (fhint)
57                {
58                   if (mwmhints->flags & ECORE_X_MWM_HINTS_FUNCTIONS)
59                      *fhint = mwmhints->functions;
60                   else
61                      *fhint = ECORE_X_MWM_HINT_FUNC_ALL;
62                }
63              if (ihint)
64                {
65                   if (mwmhints->flags & ECORE_X_MWM_HINTS_INPUT_MODE)
66                      *ihint = mwmhints->inputmode;
67                   else
68                      *ihint = ECORE_X_MWM_HINT_INPUT_MODELESS;
69                }
70              ret = 1;
71           }
72         free(mwmhints);
73      }
74    return ret;
75 }
76
77 EAPI void
78 ecore_x_mwm_borderless_set(Ecore_X_Window win, int borderless)
79 {
80    unsigned int data[5] = {0, 0, 0, 0, 0};
81
82    data[0] = 2; /* just set the decorations hint! */
83    data[2] = !borderless;
84    
85    ecore_x_window_prop_property_set(win, 
86                                     ECORE_X_ATOM_MOTIF_WM_HINTS,
87                                     ECORE_X_ATOM_MOTIF_WM_HINTS,
88                                     32, (void *)data, 5);
89 }
90