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>
35 #include "layouts/floating.h"
38 extern AwesomeConf globalconf
;
40 /** Load windows properties, restoring client's tag
41 * and floating state before awesome was restarted if any
42 * \todo this may bug if number of tags is != than before
44 * \param screen Screen ID
45 * \return true if client had property
48 client_loadprops(Client
* c
, int screen
)
55 for(tag
= globalconf
.screens
[screen
].tags
; tag
; tag
= tag
->next
)
58 prop
= p_new(char, ntags
+ 2);
60 if(xgettextprop(c
->win
,
61 XInternAtom(globalconf
.display
, "_AWESOME_PROPERTIES", False
),
64 for(i
= 0, tag
= globalconf
.screens
[screen
].tags
; tag
&& i
< ntags
&& prop
[i
]; i
++, tag
= tag
->next
)
73 if(i
<= ntags
&& prop
[i
])
74 client_setfloating(c
, prop
[i
] == '1');
82 /** Check if client supports protocol WM_DELETE_WINDOW
83 * \param disp the display
84 * \param win the Window
85 * \return True if client has WM_DELETE_WINDOW
88 isprotodel(Display
*disp
, Window win
)
94 if(XGetWMProtocols(disp
, win
, &protocols
, &n
))
96 for(i
= 0; !ret
&& i
< n
; i
++)
97 if(protocols
[i
] == XInternAtom(disp
, "WM_DELETE_WINDOW", False
))
104 /** Get a Client by its window
105 * \param list Client list to look info
106 * \param w Client window to find
110 get_client_bywin(Client
*list
, Window w
)
114 for(c
= list
; c
&& c
->win
!= w
; c
= c
->next
);
118 /** Get a client by its name
119 * \param list Client list
120 * \param name name to search
121 * \return first matching client
124 get_client_byname(Client
*list
, char *name
)
128 for(c
= list
; c
; c
= c
->next
)
129 if(strstr(c
->name
, name
))
135 /** Update client name attribute with its title
136 * \param c the client
139 client_updatetitle(Client
*c
)
141 if(!xgettextprop(c
->win
, XInternAtom(globalconf
.display
, "_NET_WM_NAME", False
), c
->name
, sizeof(c
->name
)))
142 xgettextprop(c
->win
, XInternAtom(globalconf
.display
, "WM_NAME", False
), c
->name
, sizeof(c
->name
));
144 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
148 client_unfocus(Client
*c
)
150 XSetWindowBorder(globalconf
.display
, c
->win
,
151 globalconf
.screens
[c
->screen
].colors_normal
[ColBorder
].pixel
);
152 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
153 focus_add_client(NULL
);
156 /** Ban client and unmap it
157 * \param c the client
160 client_ban(Client
*c
)
162 if(globalconf
.focus
->client
== c
)
164 XUnmapWindow(globalconf
.display
, c
->win
);
165 window_setstate(c
->win
, IconicState
);
168 /** Give focus to client, or to first client if c is NULL
170 * \param screen Screen ID
173 focus(Client
*c
, int screen
, Bool from_mouse
)
175 int phys_screen
= get_phys_screen(screen
);
177 /* if c is NULL or invisible, take next client in the focus history */
178 if(!c
|| (c
&& !client_isvisible(c
, screen
)))
180 c
= focus_get_current_client(screen
);
181 /* if c is still NULL take next client in the stack */
183 for(c
= globalconf
.clients
; c
&& (c
->skip
|| !client_isvisible(c
, screen
)); c
= c
->next
);
186 /* unfocus current selected client */
187 if(globalconf
.focus
->client
)
188 client_unfocus(globalconf
.focus
->client
);
193 /* save sel in focus history */
195 XSetWindowBorder(globalconf
.display
, c
->win
,
196 globalconf
.screens
[screen
].colors_selected
[ColBorder
].pixel
);
197 XSetInputFocus(globalconf
.display
, c
->win
, RevertToPointerRoot
, CurrentTime
);
199 || !globalconf
.screens
[screen
].sloppy_focus
200 || globalconf
.screens
[screen
].sloppy_focus_raise
)
201 XRaiseWindow(globalconf
.display
, c
->win
);
204 XSetInputFocus(globalconf
.display
,
205 RootWindow(globalconf
.display
, phys_screen
),
206 RevertToPointerRoot
, CurrentTime
);
208 widget_invalidate_cache(screen
, WIDGET_CACHE_CLIENTS
);
209 ewmh_update_net_active_window(phys_screen
);
210 globalconf
.drop_events
|= EnterWindowMask
;
213 /** Manage a new client
214 * \param w The window
215 * \param wa Window attributes
216 * \param screen Screen ID
219 client_manage(Window w
, XWindowAttributes
*wa
, int screen
)
221 Client
*c
, *t
= NULL
;
228 int phys_screen
= get_phys_screen(screen
);
230 c
= p_new(Client
, 1);
232 c
->screen
= get_screen_bycoord(wa
->x
, wa
->y
);
234 screen_geom
= get_display_area(phys_screen
,
235 globalconf
.screens
[c
->screen
].statusbar
,
236 &globalconf
.screens
[c
->screen
].padding
);
239 c
->geometry
.x
= c
->f_geometry
.x
= c
->m_geometry
.x
= MAX(wa
->x
, screen_geom
.x
);
240 c
->geometry
.y
= c
->f_geometry
.y
= c
->m_geometry
.y
= MAX(wa
->y
, screen_geom
.y
);
241 c
->geometry
.width
= c
->f_geometry
.width
= c
->m_geometry
.width
= wa
->width
;
242 c
->geometry
.height
= c
->f_geometry
.height
= c
->m_geometry
.height
= wa
->height
;
243 c
->oldborder
= wa
->border_width
;
246 c
->border
= globalconf
.screens
[screen
].borderpx
;
248 /* Set windows borders */
249 wc
.border_width
= c
->border
;
250 XConfigureWindow(globalconf
.display
, w
, CWBorderWidth
, &wc
);
251 XSetWindowBorder(globalconf
.display
, w
, globalconf
.screens
[screen
].colors_normal
[ColBorder
].pixel
);
252 /* propagates border_width, if size doesn't change */
253 window_configure(c
->win
, c
->geometry
, c
->border
);
255 /* update window title */
256 client_updatetitle(c
);
259 client_updatesizehints(c
);
260 client_updatewmhints(c
);
262 /* First check clients hints */
263 ewmh_check_client_hints(c
);
265 /* loadprops or apply rules if no props */
266 if(!client_loadprops(c
, screen
))
268 /* Get the client's rule */
269 if((rule
= rule_matching_client(c
)))
271 if(rule
->screen
!= RULE_NOSCREEN
)
272 move_client_to_screen(c
, rule
->screen
, True
);
274 move_client_to_screen(c
, screen
, True
);
275 tag_client_with_rule(c
, rule
);
277 switch(rule
->isfloating
)
282 client_setfloating(c
, True
);
285 client_setfloating(c
, False
);
289 if(rule
->opacity
>= 0.0f
)
290 window_settrans(c
->win
, rule
->opacity
);
293 move_client_to_screen(c
, screen
, True
);
294 /* check for transient and set tags like its parent,
295 * XGetTransientForHint returns 1 on success
297 if((rettrans
= XGetTransientForHint(globalconf
.display
, w
, &trans
))
298 && (t
= get_client_bywin(globalconf
.clients
, trans
)))
299 for(tag
= globalconf
.screens
[c
->screen
].tags
; tag
; tag
= tag
->next
)
300 if(is_client_tagged(t
, tag
))
303 /* should be floating if transsient or fixed */
305 client_setfloating(c
, rettrans
|| c
->isfixed
);
308 XSelectInput(globalconf
.display
, w
, StructureNotifyMask
| PropertyChangeMask
| EnterWindowMask
);
311 if(globalconf
.have_shape
)
313 XShapeSelectInput(globalconf
.display
, w
, ShapeNotifyMask
);
314 window_setshape(phys_screen
, c
->win
);
317 /* attach to the stack */
318 if((rule
= rule_matching_client(c
)) && rule
->not_master
)
319 client_list_append(&globalconf
.clients
, c
);
320 else if(globalconf
.screens
[c
->screen
].new_become_master
)
321 client_list_push(&globalconf
.clients
, c
);
323 client_list_append(&globalconf
.clients
, c
);
325 /* some windows require this */
326 XMoveResizeWindow(globalconf
.display
, c
->win
, c
->geometry
.x
, c
->geometry
.y
,
327 c
->geometry
.width
, c
->geometry
.height
);
329 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
330 ewmh_update_net_client_list(phys_screen
);
333 /** Resize client window
334 * \param c client to resize
335 * \param geometry new window geometry
336 * \param sizehints respect size hints
337 * \param return True if resize has been done
340 client_resize(Client
*c
, Area geometry
, Bool sizehints
)
343 double dx
, dy
, max
, min
, ratio
;
349 if(c
->minay
> 0 && c
->maxay
> 0 && (geometry
.height
- c
->baseh
) > 0
350 && (geometry
.width
- c
->basew
) > 0)
352 dx
= (double) (geometry
.width
- c
->basew
);
353 dy
= (double) (geometry
.height
- c
->baseh
);
354 min
= (double) (c
->minax
) / (double) (c
->minay
);
355 max
= (double) (c
->maxax
) / (double) (c
->maxay
);
357 if(max
> 0 && min
> 0 && ratio
> 0)
361 dy
= (dx
* min
+ dy
) / (min
* min
+ 1);
363 geometry
.width
= (int) dx
+ c
->basew
;
364 geometry
.height
= (int) dy
+ c
->baseh
;
368 dy
= (dx
* min
+ dy
) / (max
* max
+ 1);
370 geometry
.width
= (int) dx
+ c
->basew
;
371 geometry
.height
= (int) dy
+ c
->baseh
;
375 if(c
->minw
&& geometry
.width
< c
->minw
)
376 geometry
.width
= c
->minw
;
377 if(c
->minh
&& geometry
.height
< c
->minh
)
378 geometry
.height
= c
->minh
;
379 if(c
->maxw
&& geometry
.width
> c
->maxw
)
380 geometry
.width
= c
->maxw
;
381 if(c
->maxh
&& geometry
.height
> c
->maxh
)
382 geometry
.height
= c
->maxh
;
384 geometry
.width
-= (geometry
.width
- c
->basew
) % c
->incw
;
386 geometry
.height
-= (geometry
.height
- c
->baseh
) % c
->inch
;
388 if(geometry
.width
<= 0 || geometry
.height
<= 0)
390 /* offscreen appearance fixes */
391 area
= get_display_area(get_phys_screen(c
->screen
),
393 &globalconf
.screens
[c
->screen
].padding
);
394 if(geometry
.x
> area
.width
)
395 geometry
.x
= area
.width
- geometry
.width
- 2 * c
->border
;
396 if(geometry
.y
> area
.height
)
397 geometry
.y
= area
.height
- geometry
.height
- 2 * c
->border
;
398 if(geometry
.x
+ geometry
.width
+ 2 * c
->border
< 0)
400 if(geometry
.y
+ geometry
.height
+ 2 * c
->border
< 0)
403 if(c
->geometry
.x
!= geometry
.x
|| c
->geometry
.y
!= geometry
.y
404 || c
->geometry
.width
!= geometry
.width
|| c
->geometry
.height
!= geometry
.height
)
406 new_screen
= get_screen_bycoord(geometry
.x
, geometry
.y
);
408 c
->geometry
.x
= wc
.x
= geometry
.x
;
409 c
->geometry
.y
= wc
.y
= geometry
.y
;
410 c
->geometry
.width
= wc
.width
= geometry
.width
;
411 c
->geometry
.height
= wc
.height
= geometry
.height
;
412 wc
.border_width
= c
->border
;
414 /* save the floating geometry if the window is floating but not
417 get_current_layout(new_screen
)->arrange
== layout_floating
) && !c
->ismax
)
418 c
->f_geometry
= geometry
;
420 XConfigureWindow(globalconf
.display
, c
->win
,
421 CWX
| CWY
| CWWidth
| CWHeight
| CWBorderWidth
, &wc
);
422 window_configure(c
->win
, geometry
, c
->border
);
424 if(c
->screen
!= new_screen
)
425 move_client_to_screen(c
, new_screen
, False
);
433 client_setfloating(Client
*c
, Bool floating
)
435 if(c
->isfloating
!= floating
)
437 if((c
->isfloating
= floating
))
438 client_resize(c
, c
->f_geometry
, False
);
442 client_resize(c
, c
->m_geometry
, False
);
444 if(client_isvisible(c
, c
->screen
))
445 globalconf
.screens
[c
->screen
].need_arrange
= True
;
446 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
451 /** Save client properties as an X property
455 client_saveprops(Client
*c
)
457 int i
= 0, ntags
= 0;
461 for(tag
= globalconf
.screens
[c
->screen
].tags
; tag
; tag
= tag
->next
)
464 prop
= p_new(char, ntags
+ 2);
466 for(tag
= globalconf
.screens
[c
->screen
].tags
; tag
; tag
= tag
->next
, i
++)
467 prop
[i
] = is_client_tagged(c
, tag
) ? '1' : '0';
470 prop
[i
] = c
->isfloating
? '1' : '0';
474 XChangeProperty(globalconf
.display
, c
->win
,
475 XInternAtom(globalconf
.display
, "_AWESOME_PROPERTIES", False
),
476 XA_STRING
, 8, PropModeReplace
, (unsigned char *) prop
, i
);
482 client_unban(Client
*c
)
484 XMapWindow(globalconf
.display
, c
->win
);
485 window_setstate(c
->win
, NormalState
);
489 client_unmanage(Client
*c
)
494 wc
.border_width
= c
->oldborder
;
496 /* The server grab construct avoids race conditions. */
497 XGrabServer(globalconf
.display
);
499 XConfigureWindow(globalconf
.display
, c
->win
, CWBorderWidth
, &wc
); /* restore border */
501 /* remove client everywhere */
502 client_list_detach(&globalconf
.clients
, c
);
503 focus_delete_client(c
);
504 for(tag
= globalconf
.screens
[c
->screen
].tags
; tag
; tag
= tag
->next
)
505 untag_client(c
, tag
);
507 if(globalconf
.focus
->client
== c
)
508 focus(NULL
, c
->screen
, False
);
510 XUngrabButton(globalconf
.display
, AnyButton
, AnyModifier
, c
->win
);
511 window_setstate(c
->win
, WithdrawnState
);
513 XSync(globalconf
.display
, False
);
514 XUngrabServer(globalconf
.display
);
520 client_updatewmhints(Client
*c
)
524 if((wmh
= XGetWMHints(globalconf
.display
, c
->win
)))
526 if((c
->isurgent
= (wmh
->flags
& XUrgencyHint
)))
527 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
528 if((wmh
->flags
& StateHint
) && wmh
->initial_state
== WithdrawnState
)
538 client_updatesizehints(Client
*c
)
543 if(!XGetWMNormalHints(globalconf
.display
, c
->win
, &size
, &msize
) || !size
.flags
)
545 if(size
.flags
& PBaseSize
)
547 c
->basew
= size
.base_width
;
548 c
->baseh
= size
.base_height
;
550 else if(size
.flags
& PMinSize
)
552 c
->basew
= size
.min_width
;
553 c
->baseh
= size
.min_height
;
556 c
->basew
= c
->baseh
= 0;
557 if(size
.flags
& PResizeInc
)
559 c
->incw
= size
.width_inc
;
560 c
->inch
= size
.height_inc
;
563 c
->incw
= c
->inch
= 0;
565 if(size
.flags
& PMaxSize
)
567 c
->maxw
= size
.max_width
;
568 c
->maxh
= size
.max_height
;
571 c
->maxw
= c
->maxh
= 0;
573 if(size
.flags
& PMinSize
)
575 c
->minw
= size
.min_width
;
576 c
->minh
= size
.min_height
;
578 else if(size
.flags
& PBaseSize
)
580 c
->minw
= size
.base_width
;
581 c
->minh
= size
.base_height
;
584 c
->minw
= c
->minh
= 0;
586 if(size
.flags
& PAspect
)
588 c
->minax
= size
.min_aspect
.x
;
589 c
->maxax
= size
.max_aspect
.x
;
590 c
->minay
= size
.min_aspect
.y
;
591 c
->maxay
= size
.max_aspect
.y
;
594 c
->minax
= c
->maxax
= c
->minay
= c
->maxay
= 0;
596 if(c
->maxw
&& c
->minw
&& c
->maxh
&& c
->minh
597 && c
->maxw
== c
->minw
&& c
->maxh
== c
->minh
)
601 /** Returns True if a client is tagged
602 * with one of the tags
603 * \return True or False
606 client_isvisible(Client
*c
, int screen
)
610 if(!c
|| c
->screen
!= screen
)
613 for(tag
= globalconf
.screens
[screen
].tags
; tag
; tag
= tag
->next
)
614 if(tag
->selected
&& is_client_tagged(c
, tag
))
619 /** Set selected client transparency
620 * \param screen Screen ID
621 * \param arg unused arg
622 * \ingroup ui_callback
625 uicb_client_settrans(int screen
__attribute__ ((unused
)), char *arg
)
627 double delta
= 100.0, current_opacity
= 100.0;
631 unsigned long n
, left
;
632 unsigned int current_opacity_raw
= 0;
634 Client
*sel
= globalconf
.focus
->client
;
639 XGetWindowProperty(globalconf
.display
, sel
->win
,
640 XInternAtom(globalconf
.display
, "_NET_WM_WINDOW_OPACITY", False
),
641 0L, 1L, False
, XA_CARDINAL
, &actual
, &format
, &n
, &left
,
642 (unsigned char **) &data
);
645 memcpy(¤t_opacity_raw
, data
, sizeof(unsigned int));
647 current_opacity
= (current_opacity_raw
* 100.0) / 0xffffffff;
652 delta
= compute_new_value_from_arg(arg
, current_opacity
);
656 else if(delta
> 100.0)
662 if(delta
== 100.0 && !set_prop
)
663 window_settrans(sel
->win
, -1);
665 window_settrans(sel
->win
, delta
);
669 client_find_prev_visible(Client
*sel
)
673 if(!sel
) return NULL
;
675 /* look for previous starting at sel */
676 for(prev
= client_list_prev_cycle(&globalconf
.clients
, sel
);
677 prev
&& (prev
->skip
|| !client_isvisible(prev
, sel
->screen
));
678 prev
= client_list_prev_cycle(&globalconf
.clients
, prev
));
684 client_find_next_visible(Client
*sel
)
688 if(!sel
) return NULL
;
690 for(next
= sel
->next
; next
&& !client_isvisible(next
, sel
->screen
); next
= next
->next
);
692 for(next
= globalconf
.clients
; next
&& !client_isvisible(next
, sel
->screen
); next
= next
->next
);
697 /** Swap current with previous client
698 * \param screen Screen ID
700 * \ingroup ui_callback
703 uicb_client_swapprev(int screen
__attribute__ ((unused
)),
704 char *arg
__attribute__ ((unused
)))
708 if((prev
= client_find_prev_visible(globalconf
.focus
->client
)))
710 client_list_swap(&globalconf
.clients
, prev
, globalconf
.focus
->client
);
711 globalconf
.screens
[prev
->screen
].need_arrange
= True
;
715 /** Swap current with next client
716 * \param screen Screen ID
718 * \ingroup ui_callback
721 uicb_client_swapnext(int screen
__attribute__ ((unused
)),
722 char *arg
__attribute__ ((unused
)))
726 if((next
= client_find_next_visible(globalconf
.focus
->client
)))
728 client_list_swap(&globalconf
.clients
, globalconf
.focus
->client
, next
);
729 globalconf
.screens
[next
->screen
].need_arrange
= True
;
733 /** Move and resize client
734 * \param screen Screen ID
736 * \ingroup ui_callback
739 uicb_client_moveresize(int screen
, char *arg
)
742 char x
[8], y
[8], w
[8], h
[8];
743 int mx
, my
, dx
, dy
, nmx
, nmy
;
747 Client
*sel
= globalconf
.focus
->client
;
748 Tag
**curtags
= get_current_tags(screen
);
750 if(curtags
[0]->layout
->arrange
!= layout_floating
)
751 if(!sel
|| !sel
->isfloating
|| sel
->isfixed
|| !arg
)
757 if(sscanf(arg
, "%s %s %s %s", x
, y
, w
, h
) != 4)
759 area
.x
= (int) compute_new_value_from_arg(x
, sel
->geometry
.x
);
760 area
.y
= (int) compute_new_value_from_arg(y
, sel
->geometry
.y
);
761 area
.width
= (int) compute_new_value_from_arg(w
, sel
->geometry
.width
);
762 area
.height
= (int) compute_new_value_from_arg(h
, sel
->geometry
.height
);
764 ox
= sel
->geometry
.x
;
765 oy
= sel
->geometry
.y
;
766 ow
= sel
->geometry
.width
;
767 oh
= sel
->geometry
.height
;
769 Bool xqp
= XQueryPointer(globalconf
.display
,
770 RootWindow(globalconf
.display
,
771 get_phys_screen(screen
)),
772 &dummy
, &dummy
, &mx
, &my
, &dx
, &dy
, &dui
);
773 client_resize(sel
, area
, globalconf
.screens
[sel
->screen
].resize_hints
);
774 if (xqp
&& ox
<= mx
&& (ox
+ ow
) >= mx
&& oy
<= my
&& (oy
+ oh
) >= my
)
776 nmx
= mx
- ox
+ sel
->geometry
.width
- ow
- 1 < 0 ? 0 : mx
- ox
+ sel
->geometry
.width
- ow
- 1;
777 nmy
= my
- oy
+ sel
->geometry
.height
- oh
- 1 < 0 ? 0 : my
- oy
+ sel
->geometry
.height
- oh
- 1;
778 XWarpPointer(globalconf
.display
,
780 0, 0, 0, 0, nmx
, nmy
);
785 client_kill(Client
*c
)
789 if(isprotodel(globalconf
.display
, c
->win
))
791 ev
.type
= ClientMessage
;
792 ev
.xclient
.window
= c
->win
;
793 ev
.xclient
.message_type
= XInternAtom(globalconf
.display
, "WM_PROTOCOLS", False
);
794 ev
.xclient
.format
= 32;
795 ev
.xclient
.data
.l
[0] = XInternAtom(globalconf
.display
, "WM_DELETE_WINDOW", False
);
796 ev
.xclient
.data
.l
[1] = CurrentTime
;
797 XSendEvent(globalconf
.display
, c
->win
, False
, NoEventMask
, &ev
);
800 XKillClient(globalconf
.display
, c
->win
);
803 /** Kill selected client
804 * \param screen Screen ID
806 * \ingroup ui_callback
809 uicb_client_kill(int screen
__attribute__ ((unused
)), char *arg
__attribute__ ((unused
)))
811 Client
*sel
= globalconf
.focus
->client
;
818 client_maximize(Client
*c
, Area geometry
)
821 if((c
->ismax
= !c
->ismax
))
823 c
->wasfloating
= c
->isfloating
;
824 c
->m_geometry
= c
->geometry
;
825 if(get_current_layout(c
->screen
)->arrange
!= layout_floating
)
826 client_setfloating(c
, True
);
827 client_resize(c
, geometry
, False
);
828 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
830 else if(c
->wasfloating
)
832 client_setfloating(c
, True
);
833 client_resize(c
, c
->m_geometry
, False
);
834 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
836 else if(get_current_layout(c
->screen
)->arrange
== layout_floating
)
838 client_resize(c
, c
->m_geometry
, False
);
839 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
843 client_setfloating(c
, False
);
844 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
848 /** Toggle maximize for client
849 * \param screen Screen ID
851 * \ingroup ui_callback
854 uicb_client_togglemax(int screen
, char *arg
__attribute__ ((unused
)))
856 Client
*sel
= globalconf
.focus
->client
;
857 Area area
= get_screen_area(screen
,
858 globalconf
.screens
[screen
].statusbar
,
859 &globalconf
.screens
[screen
].padding
);
863 area
.width
-= 2 * sel
->border
;
864 area
.height
-= 2 * sel
->border
;
865 client_maximize(sel
, area
);
869 /** Toggle vertical maximize for client
870 * \param screen Screen ID
872 * \ingroup ui_callback
875 uicb_client_toggleverticalmax(int screen
, char *arg
__attribute__ ((unused
)))
877 Client
*sel
= globalconf
.focus
->client
;
878 Area area
= get_screen_area(screen
,
879 globalconf
.screens
[screen
].statusbar
,
880 &globalconf
.screens
[screen
].padding
);
884 area
.x
= sel
->geometry
.x
;
885 area
.width
= sel
->geometry
.width
;
886 area
.height
-= 2 * sel
->border
;
887 client_maximize(sel
, area
);
892 /** Toggle horizontal maximize for client
893 * \param screen Screen ID
895 * \ingroup ui_callback
898 uicb_client_togglehorizontalmax(int screen
, char *arg
__attribute__ ((unused
)))
900 Client
*sel
= globalconf
.focus
->client
;
901 Area area
= get_screen_area(screen
,
902 globalconf
.screens
[screen
].statusbar
,
903 &globalconf
.screens
[screen
].padding
);
907 area
.y
= sel
->geometry
.y
;
908 area
.height
= sel
->geometry
.height
;
909 area
.width
-= 2 * sel
->border
;
910 client_maximize(sel
, area
);
915 * \param screen Screen ID
917 * \ingroup ui_callback
920 uicb_client_zoom(int screen
, char *arg
__attribute__ ((unused
)))
922 Client
*c
, *sel
= globalconf
.focus
->client
;
924 for(c
= globalconf
.clients
; !client_isvisible(c
, screen
); c
= c
->next
);
926 for(sel
= sel
->next
; sel
&& !client_isvisible(sel
, screen
); sel
= sel
->next
);
931 client_list_detach(&globalconf
.clients
, sel
);
932 client_list_push(&globalconf
.clients
, sel
);
933 globalconf
.screens
[screen
].need_arrange
= True
;
936 /** Send focus to next client in stack
937 * \param screen Screen ID
939 * \ingroup ui_callback
942 uicb_client_focusnext(int screen
, char *arg
__attribute__ ((unused
)))
944 Client
*c
, *sel
= globalconf
.focus
->client
;
948 for(c
= sel
->next
; c
&& (c
->skip
|| !client_isvisible(c
, screen
)); c
= c
->next
);
950 for(c
= globalconf
.clients
; c
&& (c
->skip
|| !client_isvisible(c
, screen
)); c
= c
->next
);
952 focus(c
, screen
, False
);
955 /** Send focus to previous client in stack
956 * \param screen Screen ID
958 * \ingroup ui_callback
961 uicb_client_focusprev(int screen
, char *arg
__attribute__ ((unused
)))
965 if((prev
= client_find_prev_visible(globalconf
.focus
->client
)))
966 focus(prev
, screen
, False
);
969 /** Toggle floating state of a client
970 * \param screen Screen ID
972 * \ingroup ui_callback
975 uicb_client_togglefloating(int screen
__attribute__ ((unused
)),
976 char *arg
__attribute__ ((unused
)))
978 if(globalconf
.focus
->client
)
979 client_setfloating(globalconf
.focus
->client
, !globalconf
.focus
->client
->isfloating
);
982 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80