6
6
static void update_size_hints (struct pane * , XWindowAttributes * , Display * );
7
7
static void update_hints (struct pane * , Display * );
8
8
9
+ struct pane *
10
+ create_empty_pane (struct layout * l , int x )
11
+ {
12
+ struct pane * p ;
13
+ static unsigned long n_panes ;
14
+ XGCValues v ;
15
+ XSetWindowAttributes sa ;
16
+ int y , w , h , bw , depth , class , mask ;
17
+ Visual * visual ;
18
+ Display * dpy = l -> display ;
19
+ Window parent ;
20
+ struct column * column ;
21
+
22
+ p = calloc (1 , sizeof (struct pane ));
23
+ if (p == NULL )
24
+ err (1 , "creating pane" );
25
+
26
+ p -> name = "(empty pane)" ;
27
+ p -> flags |= PF_EMPTY ;
28
+ p -> number = ++ n_panes ;
29
+ column = find_column (l -> head , x );
30
+
31
+ XGetGCValues (l -> display , l -> normal_gc , GCBackground , & v );
32
+
33
+ /*
34
+ * Create frame.
35
+ */
36
+ parent = DefaultRootWindow (dpy );
37
+ x = column -> x ;
38
+ y = 0 ;
39
+ w = column -> width ;
40
+ h = l -> titlebar_height_px ;
41
+ bw = 0 ;
42
+ depth = CopyFromParent ;
43
+ class = InputOutput ;
44
+ visual = CopyFromParent ;
45
+ mask = CWEventMask | CWBackPixel ;
46
+ sa .event_mask = ButtonPressMask | ButtonReleaseMask | ExposureMask ;
47
+ sa .background_pixel = v .background ;
48
+
49
+ p -> frame = XCreateWindow (
50
+ dpy , parent , x , y , w , h , bw , depth , class , visual , mask , & sa );
51
+ p -> height = h + 10 ;
52
+
53
+ prompt_init (& p -> prompt , p , l );
54
+
55
+ /*
56
+ * Create close button.
57
+ */
58
+ parent = p -> frame ;
59
+ x = column -> width - l -> font_height_px ;
60
+ w = l -> font_height_px ;
61
+ mask |= CWWinGravity ;
62
+ sa .win_gravity = NorthEastGravity ;
63
+
64
+ p -> close_button = XCreateWindow (
65
+ dpy , parent , x , y , w , h , bw , depth , class , visual , mask , & sa );
66
+
67
+ /*
68
+ * Create keep open button.
69
+ */
70
+ x -= l -> font_height_px ;
71
+
72
+ p -> maximize_button = XCreateWindow (
73
+ dpy , parent , x , y , w , h , bw , depth , class , visual , mask , & sa );
74
+
75
+ /*
76
+ * Set names for debugging.
77
+ */
78
+ XStoreName (dpy , p -> frame , "cocowm frame" );
79
+ XStoreName (dpy , p -> close_button , "cocowm close button" );
80
+ XStoreName (dpy , p -> maximize_button , "cocowm keep open button" );
81
+
82
+ /*
83
+ * Set associations.
84
+ */
85
+ XSaveContext (dpy , p -> frame , l -> context , (XPointer ) p );
86
+ XSaveContext (dpy , p -> maximize_button , l -> context , (XPointer ) p );
87
+ XSaveContext (dpy , p -> close_button , l -> context , (XPointer ) p );
88
+
89
+ XSync (dpy , False );
90
+ return p ;
91
+ }
92
+
9
93
/*
10
94
* Creates a managed window (a pane in our terminology) by reparenting
11
95
* an unmanaged window (w) with a frame that allows control of the
@@ -23,23 +107,17 @@ static void update_hints(struct pane *, Display *);
23
107
struct pane *
24
108
create_pane (Window w , struct layout * l )
25
109
{
26
- static unsigned long n_panes ;
27
110
struct pane * p ;
28
111
XWindowAttributes a ;
29
112
int rheight ;
30
- XGCValues v ;
31
113
XSetWindowAttributes sa ;
32
- char s [256 ];
33
114
34
115
assert (l != NULL );
35
116
36
117
/* TODO: Take these values from CreateNotify */
37
118
if (XGetWindowAttributes (l -> display , w , & a ) == 0 )
38
119
assert (0 );
39
120
40
- if ((p = calloc (1 , sizeof (struct pane ))) == NULL )
41
- err (1 , "managing new window" );
42
-
43
121
/*
44
122
* When starting the window manager, we check for
45
123
* override_redirect and IsUnmapped but create_pane() is
@@ -59,6 +137,9 @@ create_pane(Window w, struct layout *l)
59
137
return NULL ;
60
138
}
61
139
140
+ p = create_empty_pane (l , a .x );
141
+ p -> flags &= ~PF_EMPTY ;
142
+
62
143
/* TODO: Get this from createnotify or something */
63
144
XFetchName (l -> display , w , & p -> name );
64
145
@@ -69,15 +150,12 @@ create_pane(Window w, struct layout *l)
69
150
XSetWindowBorderWidth (l -> display , w , 10 );
70
151
#endif
71
152
72
- p -> number = ++ n_panes ;
73
153
p -> window = w ;
74
154
75
155
TRACE ("create: Original window size: %d,%d" , a .width , a .height );
76
156
77
157
update_hints (p , l -> display );
78
-
79
158
update_size_hints (p , & a , l -> display );
80
-
81
159
read_pane_protocols (p , l -> display );
82
160
83
161
if (p -> flags & PF_MINIMIZED )
@@ -95,90 +173,14 @@ create_pane(Window w, struct layout *l)
95
173
96
174
TRACE ("create: p->height is: %d" , p -> height );
97
175
98
- /* TODO: Is this necessary for moving pane to a nice place? */
99
- #if 0
100
- a .x = x ;
101
- #endif
102
-
103
- XGetGCValues (l -> display , l -> normal_gc , GCBackground , & v );
104
-
105
- sa .event_mask = ButtonPressMask | ButtonReleaseMask | ExposureMask ;
106
- sa .background_pixel = v .background ;
107
- p -> frame = XCreateWindow (l -> display , DefaultRootWindow (l -> display ),
108
- a .x , a .y , l -> column -> width , p -> height ,
109
- 0 , CopyFromParent , InputOutput ,
110
- CopyFromParent , CWEventMask | CWBackPixel ,
111
- & sa );
112
-
113
- prompt_init (& p -> prompt , p , l );
114
-
115
- snprintf (s , sizeof (s ), "cocowm frame for 0x%lx (%s)" , w , p -> name );
116
- XStoreName (l -> display , p -> frame , s );
117
-
118
- TRACE ("create: create pane frame is %lx" , p -> frame );
119
- XSync (l -> display , False );
120
- sa .win_gravity = NorthEastGravity ;
121
- p -> close_button = XCreateWindow (l -> display , p -> frame ,
122
- l -> column -> width - l -> font_height_px , 0 ,
123
- l -> font_height_px , (l -> titlebar_height_px ),
124
- 0 , CopyFromParent , InputOutput ,
125
- CopyFromParent ,
126
- CWEventMask | CWBackPixel | CWWinGravity , & sa );
127
- TRACE ("create: create pane close is %lx" , p -> close_button );
128
-
129
- snprintf (s , sizeof (s ), "cocowm close_button for 0x%lx (%s)" , w , p -> name );
130
- XStoreName (l -> display , p -> close_button , s );
131
-
132
- XSync (l -> display , False );
133
- p -> maximize_button = XCreateWindow (l -> display , p -> frame ,
134
- l -> column -> width - (l -> font_height_px * 2 ),
135
- 0 , l -> font_height_px , (l -> titlebar_height_px ),
136
- 0 , CopyFromParent , InputOutput ,
137
- CopyFromParent ,
138
- CWEventMask | CWBackPixel | CWWinGravity , & sa );
139
-
140
- snprintf (s , sizeof (s ), "cocowm maximize_button for 0x%lx (%s)" , w , p -> name );
141
- XStoreName (l -> display , p -> maximize_button , s );
142
-
143
- TRACE ("create: create pane maximize is %lx" , p -> maximize_button );
144
- XSync (l -> display , False );
145
-
146
- XGetGCValues (l -> display , l -> column_gc , GCForeground , & v );
147
- #if 0
148
- sa .background_pixel = v .foreground ;
149
- p -> column_button = XCreateWindow (l -> display , p -> frame ,
150
- 0 , 0 , 20 , 20 ,
151
- 0 , CopyFromParent , InputOutput ,
152
- CopyFromParent ,
153
- CWBackPixel , & sa );
154
- #endif
155
-
156
176
XGetIconName (l -> display , w , & p -> icon_name );
157
177
158
178
XSaveContext (l -> display , w , l -> context , (XPointer ) p );
159
- XSaveContext (l -> display , p -> frame , l -> context , (XPointer ) p );
160
- XSaveContext (l -> display , p -> maximize_button , l -> context , (XPointer ) p );
161
- XSaveContext (l -> display , p -> close_button , l -> context , (XPointer ) p );
162
-
163
- #if 0
164
- XSelectInput (l -> display , w , PropertyChangeMask );
165
- #endif
166
-
167
179
XAddToSaveSet (l -> display , w );
168
180
169
181
XMapWindow (l -> display , p -> frame );
170
182
XMapSubwindows (l -> display , p -> frame );
171
183
172
- #if 0
173
- XReparentWindow (l -> display , w , p -> frame , 0 , (l -> titlebar_height_px ));
174
-
175
- /* TODO: Or move these to Reparent window event? */
176
- if (!(p -> flags & PF_MINIMIZED ))
177
- XMapWindow (l -> display , w );
178
-
179
- XMapSubwindows (l -> display , p -> frame );
180
- #endif
181
-
182
184
/*
183
185
* Required for click-to-focus.
184
186
*/
0 commit comments