| @@ -171,12 +171,6 @@ void win_init(win_t *win) |
| 171 | 171 | | win->bar.fgcol = win_alloc_color(win, BAR_FG_COLOR); |
| 172 | 172 | | win->bar.h = options->hide_bar ? 0 : barheight; |
| 173 | 173 | | |
| 174 | | − | win->sizehints.flags = PWinGravity; |
| 175 | | − | win->sizehints.win_gravity = NorthWestGravity; |
| 176 | | − | if (options->fixed_win) |
| 177 | | − | /* actual min/max values set in win_update_sizehints() */ |
| 178 | | − | win->sizehints.flags |= PMinSize | PMaxSize; |
| 179 | | − | |
| 180 | 174 | | INIT_ATOM_(WM_DELETE_WINDOW); |
| 181 | 175 | | INIT_ATOM_(_NET_WM_NAME); |
| 182 | 176 | | INIT_ATOM_(_NET_WM_ICON_NAME); |
| @@ -188,26 +182,6 @@ void win_init(win_t *win) |
| 188 | 182 | | win_check_wm_support(e->dpy, RootWindow(e->dpy, e->scr)); |
| 189 | 183 | | } |
| 190 | 184 | | |
| 191 | | − | void win_update_sizehints(win_t *win) |
| 192 | | − | { |
| 193 | | − | if (win == NULL || win->xwin == None) |
| 194 | | − | return; |
| 195 | | − | |
| 196 | | − | if ((win->sizehints.flags & USSize) != 0) { |
| 197 | | − | win->sizehints.width = win->w; |
| 198 | | − | win->sizehints.height = win->h + win->bar.h; |
| 199 | | − | } |
| 200 | | − | if ((win->sizehints.flags & USPosition) != 0) { |
| 201 | | − | win->sizehints.x = win->x; |
| 202 | | − | win->sizehints.y = win->y; |
| 203 | | − | } |
| 204 | | − | if (options->fixed_win) { |
| 205 | | − | win->sizehints.min_width = win->sizehints.max_width = win->w; |
| 206 | | − | win->sizehints.min_height = win->sizehints.max_height = win->h + win->bar.h; |
| 207 | | − | } |
| 208 | | − | XSetWMNormalHints(win->env.dpy, win->xwin, &win->sizehints); |
| 209 | | − | } |
| 210 | | − | |
| 211 | 185 | | void win_open(win_t *win) |
| 212 | 186 | | { |
| 213 | 187 | | int c, i, j, n; |
| @@ -220,12 +194,16 @@ void win_open(win_t *win) |
| 220 | 194 | | char none_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 221 | 195 | | Pixmap none; |
| 222 | 196 | | int gmask; |
| 197 | + | XSizeHints sizehints; |
| 223 | 198 | | |
| 224 | 199 | | if (win == NULL) |
| 225 | 200 | | return; |
| 226 | 201 | | |
| 227 | 202 | | e = &win->env; |
| 228 | 203 | | |
| 204 | + | sizehints.flags = PWinGravity; |
| 205 | + | sizehints.win_gravity = NorthWestGravity; |
| 206 | + | |
| 229 | 207 | | /* determine window offsets, width & height */ |
| 230 | 208 | | if (options->geometry == NULL) |
| 231 | 209 | | gmask = 0; |
| @@ -233,31 +211,29 @@ void win_open(win_t *win) |
| 233 | 211 | | gmask = XParseGeometry(options->geometry, &win->x, &win->y, |
| 234 | 212 | | &win->w, &win->h); |
| 235 | 213 | | if ((gmask & WidthValue) != 0) |
| 236 | | − | win->sizehints.flags |= USSize; |
| 214 | + | sizehints.flags |= USSize; |
| 237 | 215 | | else |
| 238 | 216 | | win->w = WIN_WIDTH; |
| 239 | 217 | | if ((gmask & HeightValue) != 0) |
| 240 | | − | win->sizehints.flags |= USSize; |
| 218 | + | sizehints.flags |= USSize; |
| 241 | 219 | | else |
| 242 | 220 | | win->h = WIN_HEIGHT; |
| 243 | 221 | | if ((gmask & XValue) != 0) { |
| 244 | 222 | | if ((gmask & XNegative) != 0) { |
| 245 | 223 | | win->x += e->scrw - win->w; |
| 246 | | − | win->sizehints.win_gravity = NorthEastGravity; |
| 224 | + | sizehints.win_gravity = NorthEastGravity; |
| 247 | 225 | | } |
| 248 | | − | win->sizehints.flags |= USPosition; |
| 226 | + | sizehints.flags |= USPosition; |
| 249 | 227 | | } else { |
| 250 | 228 | | win->x = (e->scrw - win->w) / 2; |
| 251 | 229 | | } |
| 252 | 230 | | if ((gmask & YValue) != 0) { |
| 253 | 231 | | if ((gmask & YNegative) != 0) { |
| 254 | 232 | | win->y += e->scrh - win->h; |
| 255 | | − | if (win->sizehints.win_gravity == NorthEastGravity) |
| 256 | | − | win->sizehints.win_gravity = SouthEastGravity; |
| 257 | | − | else |
| 258 | | − | win->sizehints.win_gravity = SouthWestGravity; |
| 233 | + | sizehints.win_gravity = sizehints.win_gravity == NorthEastGravity |
| 234 | + | ? SouthEastGravity : SouthWestGravity; |
| 259 | 235 | | } |
| 260 | | − | win->sizehints.flags |= USPosition; |
| 236 | + | sizehints.flags |= USPosition; |
| 261 | 237 | | } else { |
| 262 | 238 | | win->y = (e->scrh - win->h) / 2; |
| 263 | 239 | | } |
| @@ -316,8 +292,13 @@ void win_open(win_t *win) |
| 316 | 292 | | |
| 317 | 293 | | XSetWMProtocols(e->dpy, win->xwin, &atoms[ATOM_WM_DELETE_WINDOW], 1); |
| 318 | 294 | | |
| 295 | + | sizehints.width = win->w; |
| 296 | + | sizehints.height = win->h; |
| 297 | + | sizehints.x = win->x; |
| 298 | + | sizehints.y = win->y; |
| 299 | + | XSetWMNormalHints(win->env.dpy, win->xwin, &sizehints); |
| 300 | + | |
| 319 | 301 | | win->h -= win->bar.h; |
| 320 | | − | win_update_sizehints(win); |
| 321 | 302 | | |
| 322 | 303 | | XMapWindow(e->dpy, win->xwin); |
| 323 | 304 | | XFlush(e->dpy); |