297 resize(sel, sel->x, sel->y, sel->w, sel->h, True); |
305 resize(sel, sel->x, sel->y, sel->w, sel->h, True); |
298 lt->arrange(); |
306 lt->arrange(); |
299 } |
307 } |
300 |
308 |
301 void |
309 void |
302 updatesizehints(Client *c) { |
310 unban(Client *c) { |
303 long msize; |
311 if (!c->isbanned) |
304 XSizeHints size; |
312 return; |
305 |
313 XMoveWindow(dpy, c->win, c->x, c->y); |
306 if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags) |
314 c->isbanned = False; |
307 size.flags = PSize; |
|
308 c->flags = size.flags; |
|
309 if(c->flags & PBaseSize) { |
|
310 c->basew = size.base_width; |
|
311 c->baseh = size.base_height; |
|
312 } |
|
313 else if(c->flags & PMinSize) { |
|
314 c->basew = size.min_width; |
|
315 c->baseh = size.min_height; |
|
316 } |
|
317 else |
|
318 c->basew = c->baseh = 0; |
|
319 if(c->flags & PResizeInc) { |
|
320 c->incw = size.width_inc; |
|
321 c->inch = size.height_inc; |
|
322 } |
|
323 else |
|
324 c->incw = c->inch = 0; |
|
325 if(c->flags & PMaxSize) { |
|
326 c->maxw = size.max_width; |
|
327 c->maxh = size.max_height; |
|
328 } |
|
329 else |
|
330 c->maxw = c->maxh = 0; |
|
331 if(c->flags & PMinSize) { |
|
332 c->minw = size.min_width; |
|
333 c->minh = size.min_height; |
|
334 } |
|
335 else if(c->flags & PBaseSize) { |
|
336 c->minw = size.base_width; |
|
337 c->minh = size.base_height; |
|
338 } |
|
339 else |
|
340 c->minw = c->minh = 0; |
|
341 if(c->flags & PAspect) { |
|
342 c->minax = size.min_aspect.x; |
|
343 c->maxax = size.max_aspect.x; |
|
344 c->minay = size.min_aspect.y; |
|
345 c->maxay = size.max_aspect.y; |
|
346 } |
|
347 else |
|
348 c->minax = c->maxax = c->minay = c->maxay = 0; |
|
349 c->isfixed = (c->maxw && c->minw && c->maxh && c->minh |
|
350 && c->maxw == c->minw && c->maxh == c->minh); |
|
351 } |
|
352 |
|
353 void |
|
354 updatetitle(Client *c) { |
|
355 char **list = NULL; |
|
356 int n; |
|
357 XTextProperty name; |
|
358 |
|
359 name.nitems = 0; |
|
360 c->name[0] = 0; |
|
361 XGetTextProperty(dpy, c->win, &name, netatom[NetWMName]); |
|
362 if(!name.nitems) |
|
363 XGetWMName(dpy, c->win, &name); |
|
364 if(!name.nitems) |
|
365 return; |
|
366 if(name.encoding == XA_STRING) |
|
367 strncpy(c->name, (char *)name.value, sizeof c->name - 1); |
|
368 else { |
|
369 if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success |
|
370 && n > 0 && *list) |
|
371 { |
|
372 strncpy(c->name, *list, sizeof c->name - 1); |
|
373 XFreeStringList(list); |
|
374 } |
|
375 } |
|
376 c->name[sizeof c->name - 1] = '\0'; |
|
377 XFree(name.value); |
|
378 } |
315 } |
379 |
316 |
380 void |
317 void |
381 unmanage(Client *c) { |
318 unmanage(Client *c) { |
382 XWindowChanges wc; |
319 XWindowChanges wc; |
397 XSync(dpy, False); |
334 XSync(dpy, False); |
398 XSetErrorHandler(xerror); |
335 XSetErrorHandler(xerror); |
399 XUngrabServer(dpy); |
336 XUngrabServer(dpy); |
400 lt->arrange(); |
337 lt->arrange(); |
401 } |
338 } |
|
339 |
|
340 void |
|
341 updatesizehints(Client *c) { |
|
342 long msize; |
|
343 XSizeHints size; |
|
344 |
|
345 if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags) |
|
346 size.flags = PSize; |
|
347 c->flags = size.flags; |
|
348 if(c->flags & PBaseSize) { |
|
349 c->basew = size.base_width; |
|
350 c->baseh = size.base_height; |
|
351 } |
|
352 else if(c->flags & PMinSize) { |
|
353 c->basew = size.min_width; |
|
354 c->baseh = size.min_height; |
|
355 } |
|
356 else |
|
357 c->basew = c->baseh = 0; |
|
358 if(c->flags & PResizeInc) { |
|
359 c->incw = size.width_inc; |
|
360 c->inch = size.height_inc; |
|
361 } |
|
362 else |
|
363 c->incw = c->inch = 0; |
|
364 if(c->flags & PMaxSize) { |
|
365 c->maxw = size.max_width; |
|
366 c->maxh = size.max_height; |
|
367 } |
|
368 else |
|
369 c->maxw = c->maxh = 0; |
|
370 if(c->flags & PMinSize) { |
|
371 c->minw = size.min_width; |
|
372 c->minh = size.min_height; |
|
373 } |
|
374 else if(c->flags & PBaseSize) { |
|
375 c->minw = size.base_width; |
|
376 c->minh = size.base_height; |
|
377 } |
|
378 else |
|
379 c->minw = c->minh = 0; |
|
380 if(c->flags & PAspect) { |
|
381 c->minax = size.min_aspect.x; |
|
382 c->maxax = size.max_aspect.x; |
|
383 c->minay = size.min_aspect.y; |
|
384 c->maxay = size.max_aspect.y; |
|
385 } |
|
386 else |
|
387 c->minax = c->maxax = c->minay = c->maxay = 0; |
|
388 c->isfixed = (c->maxw && c->minw && c->maxh && c->minh |
|
389 && c->maxw == c->minw && c->maxh == c->minh); |
|
390 } |
|
391 |
|
392 void |
|
393 updatetitle(Client *c) { |
|
394 char **list = NULL; |
|
395 int n; |
|
396 XTextProperty name; |
|
397 |
|
398 name.nitems = 0; |
|
399 c->name[0] = 0; |
|
400 XGetTextProperty(dpy, c->win, &name, netatom[NetWMName]); |
|
401 if(!name.nitems) |
|
402 XGetWMName(dpy, c->win, &name); |
|
403 if(!name.nitems) |
|
404 return; |
|
405 if(name.encoding == XA_STRING) |
|
406 strncpy(c->name, (char *)name.value, sizeof c->name - 1); |
|
407 else { |
|
408 if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success |
|
409 && n > 0 && *list) |
|
410 { |
|
411 strncpy(c->name, *list, sizeof c->name - 1); |
|
412 XFreeStringList(list); |
|
413 } |
|
414 } |
|
415 c->name[sizeof c->name - 1] = '\0'; |
|
416 XFree(name.value); |
|
417 } |