2 * client.c - client management
4 * Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include <X11/Xatom.h>
24 #include <X11/extensions/shape.h>
25 #include <X11/extensions/Xinerama.h>
37 #include "layouts/floating.h"
40 extern AwesomeConf globalconf
;
42 /** Load windows properties, restoring client's tag
43 * and floating state before awesome was restarted if any
44 * \todo this may bug if number of tags is != than before
46 * \param screen Screen ID
49 client_loadprops(Client
* c
, int screen
)
56 for(tag
= globalconf
.screens
[screen
].tags
; tag
; tag
= tag
->next
)
59 prop
= p_new(char, ntags
+ 2);
61 if(xgettextprop(c
->win
,
62 XInternAtom(globalconf
.display
, "_AWESOME_PROPERTIES", False
),
65 for(i
= 0, tag
= globalconf
.screens
[screen
].tags
; tag
&& i
< ntags
&& prop
[i
]; i
++, tag
= tag
->next
)
74 if(i
<= ntags
&& prop
[i
])
75 c
->isfloating
= prop
[i
] == '1';
83 /** Check if client supports protocol WM_DELETE_WINDOW
84 * \param disp the display
85 * \param win the Window
86 * \return True if client has WM_DELETE_WINDOW
89 isprotodel(Display
*disp
, Window win
)
95 if(XGetWMProtocols(disp
, win
, &protocols
, &n
))
97 for(i
= 0; !ret
&& i
< n
; i
++)
98 if(protocols
[i
] == XInternAtom(disp
, "WM_DELETE_WINDOW", False
))
105 /** Swap two client in the linked list clients
106 * \param head pointer ito the client list head
107 * \param c1 first client
108 * \param c2 second client
111 client_swap(Client
**head
, Client
*c1
, Client
*c2
)
117 c2
->next
= (tmp
== c2
? c1
: tmp
);
121 c1
->prev
= (tmp
== c1
? c2
: tmp
);
139 /** Get a Client by its window
140 * \param list Client list to look info
141 * \param w Client window to find
145 get_client_bywin(Client
*list
, Window w
)
149 for(c
= list
; c
&& c
->win
!= w
; c
= c
->next
);
154 /** Get a client by its name
155 * \param list Client list
156 * \param name name to search
157 * \return first matching client
160 get_client_byname(Client
*list
, char *name
)
164 for(c
= list
; c
; c
= c
->next
)
165 if(strstr(c
->name
, name
))
171 /** Update client name attribute with its title
172 * \param c the client
175 client_updatetitle(Client
*c
)
177 if(!xgettextprop(c
->win
, XInternAtom(globalconf
.display
, "_NET_WM_NAME", False
), c
->name
, sizeof(c
->name
)))
178 xgettextprop(c
->win
, XInternAtom(globalconf
.display
, "WM_NAME", False
), c
->name
, sizeof(c
->name
));
180 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
183 /** Ban client and unmap it
184 * \param c the client
187 client_ban(Client
* c
)
189 XUnmapWindow(globalconf
.display
, c
->win
);
190 window_setstate(c
->win
, IconicState
);
195 client_attach_at_end(Client
*c
)
198 for(iter
= globalconf
.clients
; iter
&& iter
->next
; iter
= iter
->next
);
201 globalconf
.clients
= c
;
209 /** Attach client to the beginning of the clients stack
210 * \param c the client
213 client_attach(Client
*c
)
215 if(globalconf
.clients
)
216 (globalconf
.clients
)->prev
= c
;
217 c
->next
= globalconf
.clients
;
218 globalconf
.clients
= c
;
221 /** Detach client from clients list
222 * \param c client to detach
225 client_detach(Client
*c
)
228 c
->prev
->next
= c
->next
;
230 c
->next
->prev
= c
->prev
;
231 if(c
== globalconf
.clients
)
232 globalconf
.clients
= c
->next
;
233 c
->next
= c
->prev
= NULL
;
236 /** Give focus to client, or to first client if c is NULL
238 * \param selscreen True if current screen is selected
239 * \param screen Screen ID
242 focus(Client
*c
, Bool selscreen
, int screen
)
244 int phys_screen
= get_phys_screen(screen
);
246 /* unfocus current selected client */
247 if(globalconf
.focus
->client
)
249 widget_invalidate_cache(globalconf
.focus
->client
->screen
, WIDGET_CACHE_CLIENTS
);
250 window_grabbuttons(get_phys_screen(globalconf
.focus
->client
->screen
),
251 globalconf
.focus
->client
->win
, False
, True
);
252 XSetWindowBorder(globalconf
.display
, globalconf
.focus
->client
->win
,
253 globalconf
.screens
[screen
].colors_normal
[ColBorder
].pixel
);
254 window_settrans(globalconf
.focus
->client
->win
,
255 globalconf
.screens
[screen
].opacity_unfocused
);
259 /* if c is NULL or invisible, take next client in the focus history */
260 if((!c
&& selscreen
) || (c
&& !client_isvisible(c
, screen
)))
262 c
= focus_get_current_client(screen
);
263 /* if c is still NULL take next client in the stack */
265 for(c
= globalconf
.clients
; c
&& (c
->skip
|| !client_isvisible(c
, screen
)); c
= c
->next
);
270 XSetWindowBorder(globalconf
.display
, c
->win
, globalconf
.screens
[screen
].colors_selected
[ColBorder
].pixel
);
271 window_grabbuttons(phys_screen
, c
->win
, True
, True
);
277 /* save sel in focus history */
280 widget_invalidate_cache(screen
, WIDGET_CACHE_CLIENTS
);
282 if(globalconf
.focus
->client
)
284 XSetInputFocus(globalconf
.display
,
285 globalconf
.focus
->client
->win
, RevertToPointerRoot
, CurrentTime
);
286 for(c
= globalconf
.clients
; c
; c
= c
->next
)
287 if(c
!= globalconf
.focus
->client
)
288 window_settrans(globalconf
.focus
->client
->win
,
289 globalconf
.screens
[screen
].opacity_unfocused
);
290 window_settrans(globalconf
.focus
->client
->win
, -1);
293 XSetInputFocus(globalconf
.display
,
294 RootWindow(globalconf
.display
, phys_screen
),
295 RevertToPointerRoot
, CurrentTime
);
297 ewmh_update_net_active_window(phys_screen
);
300 /** Manage a new client
301 * \param w The window
302 * \param wa Window attributes
303 * \param screen Screen ID
306 client_manage(Window w
, XWindowAttributes
*wa
, int screen
)
308 Client
*c
, *t
= NULL
;
315 int phys_screen
= get_phys_screen(screen
);
317 XLowerWindow(globalconf
.display
, w
);
318 area
= get_screen_area(screen
, NULL
, NULL
);
320 c
= p_new(Client
, 1);
323 c
->geometry
.x
= c
->f_geometry
.x
= c
->m_geometry
.x
= wa
->x
;
324 c
->geometry
.y
= c
->f_geometry
.y
= c
->m_geometry
.y
= wa
->y
;
325 c
->geometry
.width
= c
->f_geometry
.width
= c
->m_geometry
.width
= wa
->width
;
326 c
->geometry
.height
= c
->f_geometry
.height
= c
->m_geometry
.height
= wa
->height
;
327 c
->oldborder
= wa
->border_width
;
329 c
->screen
= get_screen_bycoord(c
->geometry
.x
, c
->geometry
.y
);
331 move_client_to_screen(c
, screen
, True
);
333 /* update window title */
334 client_updatetitle(c
);
336 if(c
->geometry
.width
== area
.width
&& c
->geometry
.height
== area
.height
)
337 c
->border
= wa
->border_width
;
339 c
->border
= globalconf
.screens
[screen
].borderpx
;
341 ewmh_check_client_hints(c
);
342 /* loadprops or apply rules if no props */
343 if(!client_loadprops(c
, screen
))
344 tag_client_with_rules(c
);
346 /* if window request fullscreen mode */
347 if(c
->geometry
.width
== area
.width
&& c
->geometry
.height
== area
.height
)
349 c
->geometry
.x
= area
.x
;
350 c
->geometry
.y
= area
.y
;
354 darea
= get_display_area(phys_screen
,
355 globalconf
.screens
[screen
].statusbar
,
356 &globalconf
.screens
[screen
].padding
);
358 if(c
->geometry
.x
+ c
->geometry
.width
+ 2 * c
->border
> darea
.x
+ darea
.width
)
359 c
->geometry
.x
= c
->f_geometry
.x
= darea
.x
+ darea
.width
- c
->geometry
.width
- 2 * c
->border
;
360 if(c
->geometry
.y
+ c
->geometry
.height
+ 2 * c
->border
> darea
.y
+ darea
.height
)
361 c
->geometry
.y
= c
->f_geometry
.y
= darea
.y
+ darea
.height
- c
->geometry
.height
- 2 * c
->border
;
362 if(c
->geometry
.x
< darea
.x
)
363 c
->geometry
.x
= c
->f_geometry
.x
= darea
.x
;
364 if(c
->geometry
.y
< darea
.y
)
365 c
->geometry
.y
= c
->f_geometry
.y
= darea
.y
;
368 /* XXX if this necessary ? */
370 wc
.border_width
= c
->border
;
371 XConfigureWindow(globalconf
.display
, w
, CWBorderWidth
, &wc
);
372 XSetWindowBorder(globalconf
.display
, w
, globalconf
.screens
[screen
].colors_normal
[ColBorder
].pixel
);
373 /* propagates border_width, if size doesn't change */
374 window_configure(c
->win
, c
->geometry
, c
->border
);
377 client_updatesizehints(c
);
378 client_updatewmhints(c
);
380 XSelectInput(globalconf
.display
, w
, StructureNotifyMask
| PropertyChangeMask
| EnterWindowMask
);
383 if(globalconf
.have_shape
)
385 XShapeSelectInput(globalconf
.display
, w
, ShapeNotifyMask
);
386 window_setshape(phys_screen
, c
->win
);
390 window_grabbuttons(phys_screen
, c
->win
, False
, True
);
392 /* check for transient and set tags like its parent,
393 * XGetTransientForHint returns 1 on success
395 if((rettrans
= XGetTransientForHint(globalconf
.display
, w
, &trans
))
396 && (t
= get_client_bywin(globalconf
.clients
, trans
)))
397 for(tag
= globalconf
.screens
[c
->screen
].tags
; tag
; tag
= tag
->next
)
398 if(is_client_tagged(t
, tag
))
401 /* should be floating if transsient or fixed */
403 c
->isfloating
= rettrans
|| c
->isfixed
;
408 /* attach to the stack */
409 for(rule
= globalconf
.rules
; rule
; rule
= rule
->next
)
410 if(rule
->not_master
&& client_match_rule(c
, rule
))
412 client_attach_at_end(c
);
417 if(globalconf
.screens
[c
->screen
].new_become_master
)
420 client_attach_at_end(c
);
423 /* some windows require this */
424 XMoveResizeWindow(globalconf
.display
, c
->win
, c
->geometry
.x
, c
->geometry
.y
,
425 c
->geometry
.width
, c
->geometry
.height
);
427 if(globalconf
.screens
[c
->screen
].new_get_focus
)
428 focus(c
, True
, screen
);
430 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
432 ewmh_update_net_client_list(phys_screen
);
434 /* rearrange to display new window */
438 /** Resize client window
439 * \param c client to resize
444 * \param sizehints respect size hints
445 * \param volatile_coords register coords in rx/ry/rw/rh
446 * \param return True if resize has been done
449 client_resize(Client
*c
, Area geometry
, Bool sizehints
)
452 double dx
, dy
, max
, min
, ratio
;
458 if(c
->minay
> 0 && c
->maxay
> 0 && (geometry
.height
- c
->baseh
) > 0
459 && (geometry
.width
- c
->basew
) > 0)
461 dx
= (double) (geometry
.width
- c
->basew
);
462 dy
= (double) (geometry
.height
- c
->baseh
);
463 min
= (double) (c
->minax
) / (double) (c
->minay
);
464 max
= (double) (c
->maxax
) / (double) (c
->maxay
);
466 if(max
> 0 && min
> 0 && ratio
> 0)
470 dy
= (dx
* min
+ dy
) / (min
* min
+ 1);
472 geometry
.width
= (int) dx
+ c
->basew
;
473 geometry
.height
= (int) dy
+ c
->baseh
;
477 dy
= (dx
* min
+ dy
) / (max
* max
+ 1);
479 geometry
.width
= (int) dx
+ c
->basew
;
480 geometry
.height
= (int) dy
+ c
->baseh
;
484 if(c
->minw
&& geometry
.width
< c
->minw
)
485 geometry
.width
= c
->minw
;
486 if(c
->minh
&& geometry
.height
< c
->minh
)
487 geometry
.height
= c
->minh
;
488 if(c
->maxw
&& geometry
.width
> c
->maxw
)
489 geometry
.width
= c
->maxw
;
490 if(c
->maxh
&& geometry
.height
> c
->maxh
)
491 geometry
.height
= c
->maxh
;
493 geometry
.width
-= (geometry
.width
- c
->basew
) % c
->incw
;
495 geometry
.height
-= (geometry
.height
- c
->baseh
) % c
->inch
;
497 if(geometry
.width
<= 0 || geometry
.height
<= 0)
499 /* offscreen appearance fixes */
500 area
= get_display_area(get_phys_screen(c
->screen
),
502 &globalconf
.screens
[c
->screen
].padding
);
503 if(geometry
.x
> area
.width
)
504 geometry
.x
= area
.width
- geometry
.width
- 2 * c
->border
;
505 if(geometry
.y
> area
.height
)
506 geometry
.y
= area
.height
- geometry
.height
- 2 * c
->border
;
507 if(geometry
.x
+ geometry
.width
+ 2 * c
->border
< 0)
509 if(geometry
.y
+ geometry
.height
+ 2 * c
->border
< 0)
512 if(c
->geometry
.x
!= geometry
.x
|| c
->geometry
.y
!= geometry
.y
513 || c
->geometry
.width
!= geometry
.width
|| c
->geometry
.height
!= geometry
.height
)
515 if(XineramaIsActive(globalconf
.display
))
516 new_screen
= get_screen_bycoord(geometry
.x
, geometry
.y
);
518 new_screen
= c
->screen
;
520 c
->geometry
.x
= wc
.x
= geometry
.x
;
521 c
->geometry
.y
= wc
.y
= geometry
.y
;
522 c
->geometry
.width
= wc
.width
= geometry
.width
;
523 c
->geometry
.height
= wc
.height
= geometry
.height
;
524 wc
.border_width
= c
->border
;
527 get_current_layout(new_screen
)->arrange
== layout_floating
)
528 c
->f_geometry
= geometry
;
530 XConfigureWindow(globalconf
.display
, c
->win
,
531 CWX
| CWY
| CWWidth
| CWHeight
| CWBorderWidth
, &wc
);
532 window_configure(c
->win
, geometry
, c
->border
);
534 if(c
->screen
!= new_screen
)
535 move_client_to_screen(c
, new_screen
, False
);
542 /** Save client properties as an X property
546 client_saveprops(Client
*c
)
548 int i
= 0, ntags
= 0;
552 for(tag
= globalconf
.screens
[c
->screen
].tags
; tag
; tag
= tag
->next
)
555 prop
= p_new(char, ntags
+ 2);
557 for(tag
= globalconf
.screens
[c
->screen
].tags
; tag
; tag
= tag
->next
, i
++)
558 prop
[i
] = is_client_tagged(c
, tag
) ? '1' : '0';
561 prop
[i
] = c
->isfloating
? '1' : '0';
565 XChangeProperty(globalconf
.display
, c
->win
,
566 XInternAtom(globalconf
.display
, "_AWESOME_PROPERTIES", False
),
567 XA_STRING
, 8, PropModeReplace
, (unsigned char *) prop
, i
);
573 client_unban(Client
*c
)
575 XMapWindow(globalconf
.display
, c
->win
);
576 window_setstate(c
->win
, NormalState
);
580 client_unmanage(Client
*c
)
585 wc
.border_width
= c
->oldborder
;
587 /* The server grab construct avoids race conditions. */
588 XGrabServer(globalconf
.display
);
590 XConfigureWindow(globalconf
.display
, c
->win
, CWBorderWidth
, &wc
); /* restore border */
592 /* remove client everywhere */
594 focus_delete_client(c
);
595 for(tag
= globalconf
.screens
[c
->screen
].tags
; tag
; tag
= tag
->next
)
596 untag_client(c
, tag
);
598 if(globalconf
.focus
->client
== c
)
599 focus(NULL
, True
, c
->screen
);
601 XUngrabButton(globalconf
.display
, AnyButton
, AnyModifier
, c
->win
);
602 window_setstate(c
->win
, WithdrawnState
);
604 XSync(globalconf
.display
, False
);
605 XUngrabServer(globalconf
.display
);
612 client_updatewmhints(Client
*c
)
616 if((wmh
= XGetWMHints(globalconf
.display
, c
->win
)))
618 if((c
->isurgent
= (wmh
->flags
& XUrgencyHint
)))
619 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
620 if((wmh
->flags
& StateHint
) && wmh
->initial_state
== WithdrawnState
)
627 client_updatesizehints(Client
*c
)
632 if(!XGetWMNormalHints(globalconf
.display
, c
->win
, &size
, &msize
) || !size
.flags
)
634 if(size
.flags
& PBaseSize
)
636 c
->basew
= size
.base_width
;
637 c
->baseh
= size
.base_height
;
639 else if(size
.flags
& PMinSize
)
641 c
->basew
= size
.min_width
;
642 c
->baseh
= size
.min_height
;
645 c
->basew
= c
->baseh
= 0;
646 if(size
.flags
& PResizeInc
)
648 c
->incw
= size
.width_inc
;
649 c
->inch
= size
.height_inc
;
652 c
->incw
= c
->inch
= 0;
654 if(size
.flags
& PMaxSize
)
656 c
->maxw
= size
.max_width
;
657 c
->maxh
= size
.max_height
;
660 c
->maxw
= c
->maxh
= 0;
662 if(size
.flags
& PMinSize
)
664 c
->minw
= size
.min_width
;
665 c
->minh
= size
.min_height
;
667 else if(size
.flags
& PBaseSize
)
669 c
->minw
= size
.base_width
;
670 c
->minh
= size
.base_height
;
673 c
->minw
= c
->minh
= 0;
675 if(size
.flags
& PAspect
)
677 c
->minax
= size
.min_aspect
.x
;
678 c
->maxax
= size
.max_aspect
.x
;
679 c
->minay
= size
.min_aspect
.y
;
680 c
->maxay
= size
.max_aspect
.y
;
683 c
->minax
= c
->maxax
= c
->minay
= c
->maxay
= 0;
685 if(c
->maxw
&& c
->minw
&& c
->maxh
&& c
->minh
686 && c
->maxw
== c
->minw
&& c
->maxh
== c
->minh
)
690 /** Returns True if a client is tagged
691 * with one of the tags
692 * \return True or False
695 client_isvisible(Client
*c
, int screen
)
699 if(!c
|| c
->screen
!= screen
)
702 for(tag
= globalconf
.screens
[screen
].tags
; tag
; tag
= tag
->next
)
703 if(tag
->selected
&& is_client_tagged(c
, tag
))
708 /** Set selected client transparency
709 * \param screen Screen ID
710 * \param arg unused arg
711 * \ingroup ui_callback
714 uicb_client_settrans(int screen
__attribute__ ((unused
)), char *arg
)
716 double delta
= 100.0, current_opacity
= 100.0;
720 unsigned long n
, left
;
721 unsigned int current_opacity_raw
= 0;
723 Client
*sel
= globalconf
.focus
->client
;
728 XGetWindowProperty(globalconf
.display
, sel
->win
,
729 XInternAtom(globalconf
.display
, "_NET_WM_WINDOW_OPACITY", False
),
730 0L, 1L, False
, XA_CARDINAL
, &actual
, &format
, &n
, &left
,
731 (unsigned char **) &data
);
734 memcpy(¤t_opacity_raw
, data
, sizeof(unsigned int));
736 current_opacity
= (current_opacity_raw
* 100.0) / 0xffffffff;
741 delta
= compute_new_value_from_arg(arg
, current_opacity
);
745 else if(delta
> 100.0)
751 if(delta
== 100.0 && !set_prop
)
752 window_settrans(sel
->win
, -1);
754 window_settrans(sel
->win
, delta
);
757 /** Swap current with next client
758 * \param screen Screen ID
760 * \ingroup ui_callback
763 uicb_client_swapnext(int screen
, char *arg
__attribute__ ((unused
)))
765 Client
*next
, *sel
= globalconf
.focus
->client
;
770 for(next
= sel
->next
; next
&& !client_isvisible(next
, screen
); next
= next
->next
);
773 client_swap(&globalconf
.clients
, sel
, next
);
778 /** Swap current with previous client
779 * \param screen Screen ID
781 * \ingroup ui_callback
784 uicb_client_swapprev(int screen
, char *arg
__attribute__ ((unused
)))
786 Client
*prev
, *sel
= globalconf
.focus
->client
;
791 for(prev
= sel
->prev
; prev
&& !client_isvisible(prev
, screen
); prev
= prev
->prev
);
794 client_swap(&globalconf
.clients
, prev
, sel
);
799 /** Move and resize client
800 * \param screen Screen ID
802 * \ingroup ui_callback
805 uicb_client_moveresize(int screen
, char *arg
)
808 char x
[8], y
[8], w
[8], h
[8];
809 int mx
, my
, dx
, dy
, nmx
, nmy
;
813 Client
*sel
= globalconf
.focus
->client
;
814 Tag
**curtags
= get_current_tags(screen
);
816 if(curtags
[0]->layout
->arrange
!= layout_floating
)
817 if(!sel
|| !sel
->isfloating
|| sel
->isfixed
|| !arg
)
823 if(sscanf(arg
, "%s %s %s %s", x
, y
, w
, h
) != 4)
825 area
.x
= (int) compute_new_value_from_arg(x
, sel
->geometry
.x
);
826 area
.y
= (int) compute_new_value_from_arg(y
, sel
->geometry
.y
);
827 area
.width
= (int) compute_new_value_from_arg(w
, sel
->geometry
.width
);
828 area
.height
= (int) compute_new_value_from_arg(h
, sel
->geometry
.height
);
830 ox
= sel
->geometry
.x
;
831 oy
= sel
->geometry
.y
;
832 ow
= sel
->geometry
.width
;
833 oh
= sel
->geometry
.height
;
835 Bool xqp
= XQueryPointer(globalconf
.display
,
836 RootWindow(globalconf
.display
,
837 get_phys_screen(screen
)),
838 &dummy
, &dummy
, &mx
, &my
, &dx
, &dy
, &dui
);
839 client_resize(sel
, area
, globalconf
.screens
[sel
->screen
].resize_hints
);
840 if (xqp
&& ox
<= mx
&& (ox
+ ow
) >= mx
&& oy
<= my
&& (oy
+ oh
) >= my
)
842 nmx
= mx
- ox
+ sel
->geometry
.width
- ow
- 1 < 0 ? 0 : mx
- ox
+ sel
->geometry
.width
- ow
- 1;
843 nmy
= my
- oy
+ sel
->geometry
.height
- oh
- 1 < 0 ? 0 : my
- oy
+ sel
->geometry
.height
- oh
- 1;
844 XWarpPointer(globalconf
.display
,
846 0, 0, 0, 0, nmx
, nmy
);
852 client_kill(Client
*c
)
856 if(isprotodel(globalconf
.display
, c
->win
))
858 ev
.type
= ClientMessage
;
859 ev
.xclient
.window
= c
->win
;
860 ev
.xclient
.message_type
= XInternAtom(globalconf
.display
, "WM_PROTOCOLS", False
);
861 ev
.xclient
.format
= 32;
862 ev
.xclient
.data
.l
[0] = XInternAtom(globalconf
.display
, "WM_DELETE_WINDOW", False
);
863 ev
.xclient
.data
.l
[1] = CurrentTime
;
864 XSendEvent(globalconf
.display
, c
->win
, False
, NoEventMask
, &ev
);
867 XKillClient(globalconf
.display
, c
->win
);
870 /** Kill selected client
871 * \param screen Screen ID
873 * \ingroup ui_callback
876 uicb_client_kill(int screen
__attribute__ ((unused
)), char *arg
__attribute__ ((unused
)))
878 Client
*sel
= globalconf
.focus
->client
;
885 client_maximize(Client
*c
, Area geometry
)
888 if((c
->ismax
= !c
->ismax
))
890 c
->wasfloating
= c
->isfloating
;
891 c
->m_geometry
= c
->geometry
;
892 client_resize(c
, geometry
, False
);
893 /* set floating after resizing so it won't save
895 c
->isfloating
= True
;
897 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
899 else if(c
->wasfloating
)
901 c
->isfloating
= True
;
902 client_resize(c
, c
->m_geometry
, False
);
904 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
908 c
->isfloating
= False
;
910 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
914 /** Toggle maximize for client
915 * \param screen Screen ID
917 * \ingroup ui_callback
920 uicb_client_togglemax(int screen
, char *arg
__attribute__ ((unused
)))
922 Client
*sel
= globalconf
.focus
->client
;
923 Area area
= get_screen_area(screen
,
924 globalconf
.screens
[screen
].statusbar
,
925 &globalconf
.screens
[screen
].padding
);
929 area
.width
-= 2 * sel
->border
;
930 area
.height
-= 2 * sel
->border
;
931 client_maximize(sel
, area
);
935 /** Toggle vertical maximize for client
936 * \param screen Screen ID
938 * \ingroup ui_callback
941 uicb_client_toggleverticalmax(int screen
, char *arg
__attribute__ ((unused
)))
943 Client
*sel
= globalconf
.focus
->client
;
944 Area area
= get_screen_area(screen
,
945 globalconf
.screens
[screen
].statusbar
,
946 &globalconf
.screens
[screen
].padding
);
950 area
.x
= sel
->geometry
.x
;
951 area
.height
-= 2 * sel
->border
;
952 client_maximize(sel
, area
);
957 /** Toggle horizontal maximize for client
958 * \param screen Screen ID
960 * \ingroup ui_callback
963 uicb_client_togglehorizontalmax(int screen
, char *arg
__attribute__ ((unused
)))
965 Client
*sel
= globalconf
.focus
->client
;
966 Area area
= get_screen_area(screen
,
967 globalconf
.screens
[screen
].statusbar
,
968 &globalconf
.screens
[screen
].padding
);
972 area
.y
= sel
->geometry
.y
;
973 area
.width
-= 2 * sel
->border
;
974 client_maximize(sel
, area
);
979 * \param screen Screen ID
981 * \ingroup ui_callback
984 uicb_client_zoom(int screen
, char *arg
__attribute__ ((unused
)))
986 Client
*c
, *sel
= globalconf
.focus
->client
;
988 for(c
= globalconf
.clients
; !client_isvisible(c
, screen
); c
= c
->next
);
990 for(sel
= sel
->next
; sel
&& !client_isvisible(sel
, screen
); sel
= sel
->next
);
1000 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80