1 /*
2 hints.c
3
4 Mike Hufnagel & Bill Kendrick
5 Last modified: 11/18/95
6 */
7
8 #include <X11/Xlib.h>
9 #include <X11/Xutil.h>
10 #include "hints.h"
11
12 /* Local prototypes */
13
14 void SetClassHints(Display *display, Window window, char *res_name,
15 char *res_class);
16 void FillSizeHints(int x, int y, int width, int height, XSizeHints *sizehints);
17 void SetWMHints(Display *display, Window window, int initial_state);
18
19 /* Local Definations */
20
SetClassHints(Display * display,Window window,char * res_name,char * res_class)21 void SetClassHints(Display *display, Window window, char *res_name,
22 char *res_class)
23 /*
24 Sets a windows class hints.
25 */
26 {
27 XClassHint class_hints;
28
29 class_hints.res_class = res_class;
30 class_hints.res_name = res_name;
31
32 XSetClassHint(display, window, &class_hints);
33 }
34
FillSizeHints(int x,int y,int width,int height,XSizeHints * sizehints)35 void FillSizeHints(int x, int y, int width, int height, XSizeHints *sizehints)
36 /*
37 Fills in an XSizeHints struct
38 */
39 {
40 /* set size hints */
41 sizehints->x = x; /* obsolete */
42 sizehints->y = y; /* obsolete */
43 sizehints->height = height; /* obsolete */
44 sizehints->width = width; /* obsolete */
45 sizehints->min_height = height;
46 sizehints->min_width = width;
47 sizehints->flags = USPosition | USSize | PMinSize;
48
49 /* if R4, we can set base stuff, too... */
50 #ifdef X11R4
51 sizehints->base_height = height;
52 sizehints->base_width = width;
53 sizehints->flags = sizehints->flags | PBaseSize;
54 #endif
55 }
56
SetWMHints(Display * display,Window window,int initial_state)57 void SetWMHints(Display *display, Window window, int initial_state)
58 /*
59 Sets the window manager hints. "initial_state" can be:
60 Withdrawn (0), Normal (1) or Iconic (3).
61 */
62 {
63 XWMHints wm_hints;
64
65 wm_hints.flags = InputHint | StateHint;
66 wm_hints.initial_state = initial_state;
67 wm_hints.input = True;
68
69 XSetWMHints(display,window,&wm_hints);
70 }
71
72 /* Global Definations */
73
SetSizeHints(Display * display,Window window,int x,int y,int width,int height)74 void SetSizeHints(Display *display, Window window, int x, int y, int width,
75 int height)
76 {
77 XSizeHints sizehints;
78
79 /* get hint values */
80 FillSizeHints(x,y,width,height,&sizehints);
81
82 /* test for R4 - adds XSetWMNormalHints */
83 #ifdef X11R4
84 XSetWMNormalHints(display,window,&sizehints);
85 #else
86 XSetNormalHints(display,window,&sizehints);
87 #endif
88 }
89
SetStandardHints(Display * display,Window window,char * app_name,char * wind_name,int x,int y,int width,int height)90 void SetStandardHints(Display *display, Window window, char* app_name,
91 char* wind_name, int x, int y, int width, int height)
92 {
93 SetSizeHints(display,window,x,y,width,height);
94 SetWindowName(display,window,wind_name);
95 SetClassHints(display,window,app_name,APPL_CLASS);
96 SetWMHints(display,window,NormalState);
97 }
98
SetWindowName(Display * display,Window window,char * name)99 void SetWindowName(Display *display, Window window, char* name)
100 {
101 XStoreName(display, window, name);
102 }
103
104
105
106
107
108
109
110
111
112
113
114