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>
34 #include "layouts/floating.h"
37 extern AwesomeConf globalconf
;
39 /** Load windows properties, restoring client's tag
40 * and floating state before awesome was restarted if any
41 * \todo this may bug if number of tags is != than before
43 * \param screen Screen ID
44 * \return true if client had property
47 client_loadprops(Client
* c
, int screen
)
54 for(tag
= globalconf
.screens
[screen
].tags
; tag
; tag
= tag
->next
)
57 prop
= p_new(char, ntags
+ 2);
59 if(xgettextprop(c
->win
,
60 XInternAtom(globalconf
.display
, "_AWESOME_PROPERTIES", False
),
63 for(i
= 0, tag
= globalconf
.screens
[screen
].tags
; tag
&& i
< ntags
&& prop
[i
]; i
++, tag
= tag
->next
)
72 if(i
<= ntags
&& prop
[i
])
73 client_setfloating(c
, prop
[i
] == '1');
81 /** Check if client supports protocol WM_DELETE_WINDOW
82 * \param disp the display
83 * \param win the Window
84 * \return True if client has WM_DELETE_WINDOW
87 isprotodel(Display
*disp
, Window win
)
93 if(XGetWMProtocols(disp
, win
, &protocols
, &n
))
95 for(i
= 0; !ret
&& i
< n
; i
++)
96 if(protocols
[i
] == XInternAtom(disp
, "WM_DELETE_WINDOW", False
))
103 /** Get a Client by its window
104 * \param list Client list to look info
105 * \param w Client window to find
109 get_client_bywin(Client
*list
, Window w
)
113 for(c
= list
; c
&& c
->win
!= w
; c
= c
->next
);
117 /** Get a client by its name
118 * \param list Client list
119 * \param name name to search
120 * \return first matching client
123 get_client_byname(Client
*list
, char *name
)
127 for(c
= list
; c
; c
= c
->next
)
128 if(strstr(c
->name
, name
))
134 /** Update client name attribute with its title
135 * \param c the client
138 client_updatetitle(Client
*c
)
140 if(!xgettextprop(c
->win
, XInternAtom(globalconf
.display
, "_NET_WM_NAME", False
), c
->name
, sizeof(c
->name
)))
141 xgettextprop(c
->win
, XInternAtom(globalconf
.display
, "WM_NAME", False
), c
->name
, sizeof(c
->name
));
143 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
147 client_unfocus(Client
*c
)
149 XSetWindowBorder(globalconf
.display
, c
->win
,
150 globalconf
.screens
[c
->screen
].colors_normal
[ColBorder
].pixel
);
151 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
152 focus_add_client(NULL
);
155 /** Ban client and unmap it
156 * \param c the client
159 client_ban(Client
*c
)
161 if(globalconf
.focus
->client
== c
)
163 XUnmapWindow(globalconf
.display
, c
->win
);
164 window_setstate(c
->win
, IconicState
);
167 /** Give focus to client, or to first client if c is NULL
169 * \param screen Screen ID
172 focus(Client
*c
, int screen
, Bool from_mouse
)
174 int phys_screen
= get_phys_screen(screen
);
176 /* if c is NULL or invisible, take next client in the focus history */
177 if(!c
|| (c
&& !client_isvisible(c
, screen
)))
179 c
= focus_get_current_client(screen
);
180 /* if c is still NULL take next client in the stack */
182 for(c
= globalconf
.clients
; c
&& (c
->skip
|| !client_isvisible(c
, screen
)); c
= c
->next
);
185 /* unfocus current selected client */
186 if(globalconf
.focus
->client
)
187 client_unfocus(globalconf
.focus
->client
);
191 /* save sel in focus history */
193 XSetWindowBorder(globalconf
.display
, c
->win
,
194 globalconf
.screens
[screen
].colors_selected
[ColBorder
].pixel
);
195 XSetInputFocus(globalconf
.display
, c
->win
, RevertToPointerRoot
, CurrentTime
);
197 || !globalconf
.screens
[screen
].sloppy_focus
198 || globalconf
.screens
[screen
].sloppy_focus_raise
)
199 XRaiseWindow(globalconf
.display
, c
->win
);
200 /* since we're dropping EnterWindow events and sometimes the window
201 * will appear under the mouse, grabbuttons */
202 window_grabbuttons(phys_screen
, c
->win
);
205 XSetInputFocus(globalconf
.display
,
206 RootWindow(globalconf
.display
, phys_screen
),
207 RevertToPointerRoot
, CurrentTime
);
209 widget_invalidate_cache(screen
, WIDGET_CACHE_CLIENTS
);
210 ewmh_update_net_active_window(phys_screen
);
211 globalconf
.drop_events
|= EnterWindowMask
;
214 /** Manage a new client
215 * \param w The window
216 * \param wa Window attributes
217 * \param screen Screen ID
220 client_manage(Window w
, XWindowAttributes
*wa
, int screen
)
222 Client
*c
, *t
= NULL
;
229 int phys_screen
= get_phys_screen(screen
);
231 c
= p_new(Client
, 1);
233 c
->screen
= get_screen_bycoord(wa
->x
, wa
->y
);
235 screen_geom
= get_display_area(phys_screen
,
236 globalconf
.screens
[c
->screen
].statusbar
,
237 &globalconf
.screens
[c
->screen
].padding
);
240 c
->geometry
.x
= c
->f_geometry
.x
= c
->m_geometry
.x
= MAX(wa
->x
, screen_geom
.x
);
241 c
->geometry
.y
= c
->f_geometry
.y
= c
->m_geometry
.y
= MAX(wa
->y
, screen_geom
.y
);
242 c
->geometry
.width
= c
->f_geometry
.width
= c
->m_geometry
.width
= wa
->width
;
243 c
->geometry
.height
= c
->f_geometry
.height
= c
->m_geometry
.height
= wa
->height
;
244 c
->oldborder
= wa
->border_width
;
247 c
->border
= globalconf
.screens
[screen
].borderpx
;
249 /* Set windows borders */
250 wc
.border_width
= c
->border
;
251 XConfigureWindow(globalconf
.display
, w
, CWBorderWidth
, &wc
);
252 XSetWindowBorder(globalconf
.display
, w
, globalconf
.screens
[screen
].colors_normal
[ColBorder
].pixel
);
253 /* propagates border_width, if size doesn't change */
254 window_configure(c
->win
, c
->geometry
, c
->border
);
256 /* update window title */
257 client_updatetitle(c
);
260 client_updatesizehints(c
);
261 client_updatewmhints(c
);
263 /* First check clients hints */
264 ewmh_check_client_hints(c
);
266 /* loadprops or apply rules if no props */
267 if(!client_loadprops(c
, screen
))
269 /* Get the client's rule */
270 if((rule
= rule_matching_client(c
)))
272 if(rule
->screen
!= RULE_NOSCREEN
)
273 move_client_to_screen(c
, rule
->screen
, True
);
275 move_client_to_screen(c
, screen
, True
);
276 tag_client_with_rule(c
, rule
);
278 switch(rule
->isfloating
)
283 client_setfloating(c
, True
);
286 client_setfloating(c
, False
);
290 if(rule
->opacity
>= 0.0f
)
291 window_settrans(c
->win
, rule
->opacity
);
294 move_client_to_screen(c
, screen
, True
);
295 /* check for transient and set tags like its parent,
296 * XGetTransientForHint returns 1 on success
298 if((rettrans
= XGetTransientForHint(globalconf
.display
, w
, &trans
))
299 && (t
= get_client_bywin(globalconf
.clients
, trans
)))
300 for(tag
= globalconf
.screens
[c
->screen
].tags
; tag
; tag
= tag
->next
)
301 if(is_client_tagged(t
, tag
))
304 /* should be floating if transsient or fixed */
306 client_setfloating(c
, rettrans
|| c
->isfixed
);
309 XSelectInput(globalconf
.display
, w
, StructureNotifyMask
| PropertyChangeMask
| EnterWindowMask
);
312 if(globalconf
.have_shape
)
314 XShapeSelectInput(globalconf
.display
, w
, ShapeNotifyMask
);
315 window_setshape(phys_screen
, c
->win
);
318 /* attach to the stack */
319 if((rule
= rule_matching_client(c
)) && rule
->not_master
)
320 client_list_append(&globalconf
.clients
, c
);
321 else if(globalconf
.screens
[c
->screen
].new_become_master
)
322 client_list_push(&globalconf
.clients
, c
);
324 client_list_append(&globalconf
.clients
, c
);
326 /* some windows require this */
327 XMoveResizeWindow(globalconf
.display
, c
->win
, c
->geometry
.x
, c
->geometry
.y
,
328 c
->geometry
.width
, c
->geometry
.height
);
330 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
331 ewmh_update_net_client_list(phys_screen
);
334 /** Resize client window
335 * \param c client to resize
336 * \param geometry new window geometry
337 * \param sizehints respect size hints
338 * \param return True if resize has been done
341 client_resize(Client
*c
, Area geometry
, Bool sizehints
)
344 double dx
, dy
, max
, min
, ratio
;
350 if(c
->minay
> 0 && c
->maxay
> 0 && (geometry
.height
- c
->baseh
) > 0
351 && (geometry
.width
- c
->basew
) > 0)
353 dx
= (double) (geometry
.width
- c
->basew
);
354 dy
= (double) (geometry
.height
- c
->baseh
);
355 min
= (double) (c
->minax
) / (double) (c
->minay
);
356 max
= (double) (c
->maxax
) / (double) (c
->maxay
);
358 if(max
> 0 && min
> 0 && ratio
> 0)
362 dy
= (dx
* min
+ dy
) / (min
* min
+ 1);
364 geometry
.width
= (int) dx
+ c
->basew
;
365 geometry
.height
= (int) dy
+ c
->baseh
;
369 dy
= (dx
* min
+ dy
) / (max
* max
+ 1);
371 geometry
.width
= (int) dx
+ c
->basew
;
372 geometry
.height
= (int) dy
+ c
->baseh
;
376 if(c
->minw
&& geometry
.width
< c
->minw
)
377 geometry
.width
= c
->minw
;
378 if(c
->minh
&& geometry
.height
< c
->minh
)
379 geometry
.height
= c
->minh
;
380 if(c
->maxw
&& geometry
.width
> c
->maxw
)
381 geometry
.width
= c
->maxw
;
382 if(c
->maxh
&& geometry
.height
> c
->maxh
)
383 geometry
.height
= c
->maxh
;
385 geometry
.width
-= (geometry
.width
- c
->basew
) % c
->incw
;
387 geometry
.height
-= (geometry
.height
- c
->baseh
) % c
->inch
;
389 if(geometry
.width
<= 0 || geometry
.height
<= 0)
391 /* offscreen appearance fixes */
392 area
= get_display_area(get_phys_screen(c
->screen
),
394 &globalconf
.screens
[c
->screen
].padding
);
395 if(geometry
.x
> area
.width
)
396 geometry
.x
= area
.width
- geometry
.width
- 2 * c
->border
;
397 if(geometry
.y
> area
.height
)
398 geometry
.y
= area
.height
- geometry
.height
- 2 * c
->border
;
399 if(geometry
.x
+ geometry
.width
+ 2 * c
->border
< 0)
401 if(geometry
.y
+ geometry
.height
+ 2 * c
->border
< 0)
404 if(c
->geometry
.x
!= geometry
.x
|| c
->geometry
.y
!= geometry
.y
405 || c
->geometry
.width
!= geometry
.width
|| c
->geometry
.height
!= geometry
.height
)
407 new_screen
= get_screen_bycoord(geometry
.x
, geometry
.y
);
409 c
->geometry
.x
= wc
.x
= geometry
.x
;
410 c
->geometry
.y
= wc
.y
= geometry
.y
;
411 c
->geometry
.width
= wc
.width
= geometry
.width
;
412 c
->geometry
.height
= wc
.height
= geometry
.height
;
413 wc
.border_width
= c
->border
;
415 /* save the floating geometry if the window is floating but not
418 get_current_layout(new_screen
)->arrange
== layout_floating
) && !c
->ismax
)
419 c
->f_geometry
= geometry
;
421 XConfigureWindow(globalconf
.display
, c
->win
,
422 CWX
| CWY
| CWWidth
| CWHeight
| CWBorderWidth
, &wc
);
423 window_configure(c
->win
, geometry
, c
->border
);
425 if(c
->screen
!= new_screen
)
426 move_client_to_screen(c
, new_screen
, False
);
434 client_setfloating(Client
*c
, Bool floating
)
436 if(c
->isfloating
!= floating
)
438 if((c
->isfloating
= floating
))
439 client_resize(c
, c
->f_geometry
, False
);
443 client_resize(c
, c
->m_geometry
, False
);
445 if(client_isvisible(c
, c
->screen
))
446 globalconf
.screens
[c
->screen
].need_arrange
= True
;
447 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
452 /** Save client properties as an X property
456 client_saveprops(Client
*c
)
458 int i
= 0, ntags
= 0;
462 for(tag
= globalconf
.screens
[c
->screen
].tags
; tag
; tag
= tag
->next
)
465 prop
= p_new(char, ntags
+ 2);
467 for(tag
= globalconf
.screens
[c
->screen
].tags
; tag
; tag
= tag
->next
, i
++)
468 prop
[i
] = is_client_tagged(c
, tag
) ? '1' : '0';
471 prop
[i
] = c
->isfloating
? '1' : '0';
475 XChangeProperty(globalconf
.display
, c
->win
,
476 XInternAtom(globalconf
.display
, "_AWESOME_PROPERTIES", False
),
477 XA_STRING
, 8, PropModeReplace
, (unsigned char *) prop
, i
);
483 client_unban(Client
*c
)
485 XMapWindow(globalconf
.display
, c
->win
);
486 window_setstate(c
->win
, NormalState
);
490 client_unmanage(Client
*c
)
495 wc
.border_width
= c
->oldborder
;
497 /* The server grab construct avoids race conditions. */
498 XGrabServer(globalconf
.display
);
500 XConfigureWindow(globalconf
.display
, c
->win
, CWBorderWidth
, &wc
); /* restore border */
502 /* remove client everywhere */
503 client_list_detach(&globalconf
.clients
, c
);
504 focus_delete_client(c
);
505 for(tag
= globalconf
.screens
[c
->screen
].tags
; tag
; tag
= tag
->next
)
506 untag_client(c
, tag
);
508 if(globalconf
.focus
->client
== c
)
509 focus(NULL
, c
->screen
, False
);
511 XUngrabButton(globalconf
.display
, AnyButton
, AnyModifier
, c
->win
);
512 window_setstate(c
->win
, WithdrawnState
);
514 XSync(globalconf
.display
, False
);
515 XUngrabServer(globalconf
.display
);
521 client_updatewmhints(Client
*c
)
525 if((wmh
= XGetWMHints(globalconf
.display
, c
->win
)))
527 if((c
->isurgent
= (wmh
->flags
& XUrgencyHint
)))
528 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
529 if((wmh
->flags
& StateHint
) && wmh
->initial_state
== WithdrawnState
)
539 client_updatesizehints(Client
*c
)
544 if(!XGetWMNormalHints(globalconf
.display
, c
->win
, &size
, &msize
) || !size
.flags
)
546 if(size
.flags
& PBaseSize
)
548 c
->basew
= size
.base_width
;
549 c
->baseh
= size
.base_height
;
551 else if(size
.flags
& PMinSize
)
553 c
->basew
= size
.min_width
;
554 c
->baseh
= size
.min_height
;
557 c
->basew
= c
->baseh
= 0;
558 if(size
.flags
& PResizeInc
)
560 c
->incw
= size
.width_inc
;
561 c
->inch
= size
.height_inc
;
564 c
->incw
= c
->inch
= 0;
566 if(size
.flags
& PMaxSize
)
568 c
->maxw
= size
.max_width
;
569 c
->maxh
= size
.max_height
;
572 c
->maxw
= c
->maxh
= 0;
574 if(size
.flags
& PMinSize
)
576 c
->minw
= size
.min_width
;
577 c
->minh
= size
.min_height
;
579 else if(size
.flags
& PBaseSize
)
581 c
->minw
= size
.base_width
;
582 c
->minh
= size
.base_height
;
585 c
->minw
= c
->minh
= 0;
587 if(size
.flags
& PAspect
)
589 c
->minax
= size
.min_aspect
.x
;
590 c
->maxax
= size
.max_aspect
.x
;
591 c
->minay
= size
.min_aspect
.y
;
592 c
->maxay
= size
.max_aspect
.y
;
595 c
->minax
= c
->maxax
= c
->minay
= c
->maxay
= 0;
597 if(c
->maxw
&& c
->minw
&& c
->maxh
&& c
->minh
598 && c
->maxw
== c
->minw
&& c
->maxh
== c
->minh
)
602 /** Returns True if a client is tagged
603 * with one of the tags
604 * \return True or False
607 client_isvisible(Client
*c
, int screen
)
611 if(!c
|| c
->screen
!= screen
)
614 for(tag
= globalconf
.screens
[screen
].tags
; tag
; tag
= tag
->next
)
615 if(tag
->selected
&& is_client_tagged(c
, tag
))
620 /** Set selected client transparency
621 * \param screen Screen ID
622 * \param arg unused arg
623 * \ingroup ui_callback
626 uicb_client_settrans(int screen
__attribute__ ((unused
)), char *arg
)
628 double delta
= 100.0, current_opacity
= 100.0;
632 unsigned long n
, left
;
633 unsigned int current_opacity_raw
= 0;
635 Client
*sel
= globalconf
.focus
->client
;
640 XGetWindowProperty(globalconf
.display
, sel
->win
,
641 XInternAtom(globalconf
.display
, "_NET_WM_WINDOW_OPACITY", False
),
642 0L, 1L, False
, XA_CARDINAL
, &actual
, &format
, &n
, &left
,
643 (unsigned char **) &data
);
646 memcpy(¤t_opacity_raw
, data
, sizeof(unsigned int));
648 current_opacity
= (current_opacity_raw
* 100.0) / 0xffffffff;
653 delta
= compute_new_value_from_arg(arg
, current_opacity
);
657 else if(delta
> 100.0)
663 if(delta
== 100.0 && !set_prop
)
664 window_settrans(sel
->win
, -1);
666 window_settrans(sel
->win
, delta
);
670 client_find_prev_visible(Client
*sel
)
674 if(!sel
) return NULL
;
676 /* look for previous starting at sel */
677 for(prev
= client_list_prev_cycle(&globalconf
.clients
, sel
);
678 prev
&& (prev
->skip
|| !client_isvisible(prev
, sel
->screen
));
679 prev
= client_list_prev_cycle(&globalconf
.clients
, prev
));
685 client_find_next_visible(Client
*sel
)
689 if(!sel
) return NULL
;
691 for(next
= sel
->next
; next
&& !client_isvisible(next
, sel
->screen
); next
= next
->next
);
693 for(next
= globalconf
.clients
; next
&& !client_isvisible(next
, sel
->screen
); next
= next
->next
);
698 /** Swap current with previous client
699 * \param screen Screen ID
701 * \ingroup ui_callback
704 uicb_client_swapprev(int screen
__attribute__ ((unused
)),
705 char *arg
__attribute__ ((unused
)))
709 if((prev
= client_find_prev_visible(globalconf
.focus
->client
)))
711 client_list_swap(&globalconf
.clients
, prev
, globalconf
.focus
->client
);
712 globalconf
.screens
[prev
->screen
].need_arrange
= True
;
716 /** Swap current with next client
717 * \param screen Screen ID
719 * \ingroup ui_callback
722 uicb_client_swapnext(int screen
__attribute__ ((unused
)),
723 char *arg
__attribute__ ((unused
)))
727 if((next
= client_find_next_visible(globalconf
.focus
->client
)))
729 client_list_swap(&globalconf
.clients
, globalconf
.focus
->client
, next
);
730 globalconf
.screens
[next
->screen
].need_arrange
= True
;
734 /** Move and resize client
735 * \param screen Screen ID
737 * \ingroup ui_callback
740 uicb_client_moveresize(int screen
, char *arg
)
743 char x
[8], y
[8], w
[8], h
[8];
744 int mx
, my
, dx
, dy
, nmx
, nmy
;
748 Client
*sel
= globalconf
.focus
->client
;
749 Tag
**curtags
= get_current_tags(screen
);
751 if(curtags
[0]->layout
->arrange
!= layout_floating
)
752 if(!sel
|| !sel
->isfloating
|| sel
->isfixed
|| !arg
)
758 if(sscanf(arg
, "%s %s %s %s", x
, y
, w
, h
) != 4)
760 area
.x
= (int) compute_new_value_from_arg(x
, sel
->geometry
.x
);
761 area
.y
= (int) compute_new_value_from_arg(y
, sel
->geometry
.y
);
762 area
.width
= (int) compute_new_value_from_arg(w
, sel
->geometry
.width
);
763 area
.height
= (int) compute_new_value_from_arg(h
, sel
->geometry
.height
);
765 ox
= sel
->geometry
.x
;
766 oy
= sel
->geometry
.y
;
767 ow
= sel
->geometry
.width
;
768 oh
= sel
->geometry
.height
;
770 Bool xqp
= XQueryPointer(globalconf
.display
,
771 RootWindow(globalconf
.display
,
772 get_phys_screen(screen
)),
773 &dummy
, &dummy
, &mx
, &my
, &dx
, &dy
, &dui
);
774 client_resize(sel
, area
, globalconf
.screens
[sel
->screen
].resize_hints
);
775 if (xqp
&& ox
<= mx
&& (ox
+ ow
) >= mx
&& oy
<= my
&& (oy
+ oh
) >= my
)
777 nmx
= mx
- ox
+ sel
->geometry
.width
- ow
- 1 < 0 ? 0 : mx
- ox
+ sel
->geometry
.width
- ow
- 1;
778 nmy
= my
- oy
+ sel
->geometry
.height
- oh
- 1 < 0 ? 0 : my
- oy
+ sel
->geometry
.height
- oh
- 1;
779 XWarpPointer(globalconf
.display
,
781 0, 0, 0, 0, nmx
, nmy
);
786 client_kill(Client
*c
)
790 if(isprotodel(globalconf
.display
, c
->win
))
792 ev
.type
= ClientMessage
;
793 ev
.xclient
.window
= c
->win
;
794 ev
.xclient
.message_type
= XInternAtom(globalconf
.display
, "WM_PROTOCOLS", False
);
795 ev
.xclient
.format
= 32;
796 ev
.xclient
.data
.l
[0] = XInternAtom(globalconf
.display
, "WM_DELETE_WINDOW", False
);
797 ev
.xclient
.data
.l
[1] = CurrentTime
;
798 XSendEvent(globalconf
.display
, c
->win
, False
, NoEventMask
, &ev
);
801 XKillClient(globalconf
.display
, c
->win
);
804 /** Kill selected client
805 * \param screen Screen ID
807 * \ingroup ui_callback
810 uicb_client_kill(int screen
__attribute__ ((unused
)), char *arg
__attribute__ ((unused
)))
812 Client
*sel
= globalconf
.focus
->client
;
819 client_maximize(Client
*c
, Area geometry
)
822 if((c
->ismax
= !c
->ismax
))
824 c
->wasfloating
= c
->isfloating
;
825 c
->m_geometry
= c
->geometry
;
826 if(get_current_layout(c
->screen
)->arrange
!= layout_floating
)
827 client_setfloating(c
, True
);
828 client_resize(c
, geometry
, False
);
829 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
831 else if(c
->wasfloating
)
833 client_setfloating(c
, True
);
834 client_resize(c
, c
->m_geometry
, False
);
835 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
837 else if(get_current_layout(c
->screen
)->arrange
== layout_floating
)
839 client_resize(c
, c
->m_geometry
, False
);
840 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
844 client_setfloating(c
, False
);
845 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
849 /** Toggle maximize for client
850 * \param screen Screen ID
852 * \ingroup ui_callback
855 uicb_client_togglemax(int screen
, char *arg
__attribute__ ((unused
)))
857 Client
*sel
= globalconf
.focus
->client
;
858 Area area
= get_screen_area(screen
,
859 globalconf
.screens
[screen
].statusbar
,
860 &globalconf
.screens
[screen
].padding
);
864 area
.width
-= 2 * sel
->border
;
865 area
.height
-= 2 * sel
->border
;
866 client_maximize(sel
, area
);
870 /** Toggle vertical maximize for client
871 * \param screen Screen ID
873 * \ingroup ui_callback
876 uicb_client_toggleverticalmax(int screen
, char *arg
__attribute__ ((unused
)))
878 Client
*sel
= globalconf
.focus
->client
;
879 Area area
= get_screen_area(screen
,
880 globalconf
.screens
[screen
].statusbar
,
881 &globalconf
.screens
[screen
].padding
);
885 area
.x
= sel
->geometry
.x
;
886 area
.width
= sel
->geometry
.width
;
887 area
.height
-= 2 * sel
->border
;
888 client_maximize(sel
, area
);
893 /** Toggle horizontal maximize for client
894 * \param screen Screen ID
896 * \ingroup ui_callback
899 uicb_client_togglehorizontalmax(int screen
, char *arg
__attribute__ ((unused
)))
901 Client
*sel
= globalconf
.focus
->client
;
902 Area area
= get_screen_area(screen
,
903 globalconf
.screens
[screen
].statusbar
,
904 &globalconf
.screens
[screen
].padding
);
908 area
.y
= sel
->geometry
.y
;
909 area
.height
= sel
->geometry
.height
;
910 area
.width
-= 2 * sel
->border
;
911 client_maximize(sel
, area
);
916 * \param screen Screen ID
918 * \ingroup ui_callback
921 uicb_client_zoom(int screen
, char *arg
__attribute__ ((unused
)))
923 Client
*c
, *sel
= globalconf
.focus
->client
;
925 for(c
= globalconf
.clients
; !client_isvisible(c
, screen
); c
= c
->next
);
927 for(sel
= sel
->next
; sel
&& !client_isvisible(sel
, screen
); sel
= sel
->next
);
932 client_list_detach(&globalconf
.clients
, sel
);
933 client_list_push(&globalconf
.clients
, sel
);
934 globalconf
.screens
[screen
].need_arrange
= True
;
937 /** Send focus to next client in stack
938 * \param screen Screen ID
940 * \ingroup ui_callback
943 uicb_client_focusnext(int screen
, char *arg
__attribute__ ((unused
)))
945 Client
*c
, *sel
= globalconf
.focus
->client
;
949 for(c
= sel
->next
; c
&& (c
->skip
|| !client_isvisible(c
, screen
)); c
= c
->next
);
951 for(c
= globalconf
.clients
; c
&& (c
->skip
|| !client_isvisible(c
, screen
)); c
= c
->next
);
953 focus(c
, screen
, False
);
956 /** Send focus to previous client in stack
957 * \param screen Screen ID
959 * \ingroup ui_callback
962 uicb_client_focusprev(int screen
, char *arg
__attribute__ ((unused
)))
966 if((prev
= client_find_prev_visible(globalconf
.focus
->client
)))
967 focus(prev
, screen
, False
);
970 /** Toggle floating state of a client
971 * \param screen Screen ID
973 * \ingroup ui_callback
976 uicb_client_togglefloating(int screen
__attribute__ ((unused
)),
977 char *arg
__attribute__ ((unused
)))
979 if(globalconf
.focus
->client
)
980 client_setfloating(globalconf
.focus
->client
, !globalconf
.focus
->client
->isfloating
);
983 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80