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
);
192 /* save sel in focus history */
194 XSetWindowBorder(globalconf
.display
, c
->win
,
195 globalconf
.screens
[screen
].colors_selected
[ColBorder
].pixel
);
196 XSetInputFocus(globalconf
.display
, c
->win
, RevertToPointerRoot
, CurrentTime
);
198 || !globalconf
.screens
[screen
].sloppy_focus
199 || globalconf
.screens
[screen
].sloppy_focus_raise
)
200 XRaiseWindow(globalconf
.display
, c
->win
);
201 /* since we're dropping EnterWindow events and sometimes the window
202 * will appear under the mouse, grabbuttons */
203 window_grabbuttons(phys_screen
, c
->win
);
206 XSetInputFocus(globalconf
.display
,
207 RootWindow(globalconf
.display
, phys_screen
),
208 RevertToPointerRoot
, CurrentTime
);
210 widget_invalidate_cache(screen
, WIDGET_CACHE_CLIENTS
);
211 ewmh_update_net_active_window(phys_screen
);
212 globalconf
.drop_events
|= EnterWindowMask
;
215 /** Manage a new client
216 * \param w The window
217 * \param wa Window attributes
218 * \param screen Screen ID
221 client_manage(Window w
, XWindowAttributes
*wa
, int screen
)
223 Client
*c
, *t
= NULL
;
230 int phys_screen
= get_phys_screen(screen
);
232 c
= p_new(Client
, 1);
234 c
->screen
= get_screen_bycoord(wa
->x
, wa
->y
);
236 screen_geom
= get_display_area(phys_screen
,
237 globalconf
.screens
[c
->screen
].statusbar
,
238 &globalconf
.screens
[c
->screen
].padding
);
241 c
->geometry
.x
= c
->f_geometry
.x
= c
->m_geometry
.x
= MAX(wa
->x
, screen_geom
.x
);
242 c
->geometry
.y
= c
->f_geometry
.y
= c
->m_geometry
.y
= MAX(wa
->y
, screen_geom
.y
);
243 c
->geometry
.width
= c
->f_geometry
.width
= c
->m_geometry
.width
= wa
->width
;
244 c
->geometry
.height
= c
->f_geometry
.height
= c
->m_geometry
.height
= wa
->height
;
245 c
->oldborder
= wa
->border_width
;
248 c
->border
= globalconf
.screens
[screen
].borderpx
;
250 /* Set windows borders */
251 wc
.border_width
= c
->border
;
252 XConfigureWindow(globalconf
.display
, w
, CWBorderWidth
, &wc
);
253 XSetWindowBorder(globalconf
.display
, w
, globalconf
.screens
[screen
].colors_normal
[ColBorder
].pixel
);
254 /* propagates border_width, if size doesn't change */
255 window_configure(c
->win
, c
->geometry
, c
->border
);
257 /* update window title */
258 client_updatetitle(c
);
261 client_updatesizehints(c
);
262 client_updatewmhints(c
);
264 /* First check clients hints */
265 ewmh_check_client_hints(c
);
267 /* loadprops or apply rules if no props */
268 if(!client_loadprops(c
, screen
))
270 /* Get the client's rule */
271 if((rule
= rule_matching_client(c
)))
273 if(rule
->screen
!= RULE_NOSCREEN
)
274 move_client_to_screen(c
, rule
->screen
, True
);
276 move_client_to_screen(c
, screen
, True
);
277 tag_client_with_rule(c
, rule
);
279 switch(rule
->isfloating
)
284 client_setfloating(c
, True
);
287 client_setfloating(c
, False
);
291 if(rule
->opacity
>= 0.0f
)
292 window_settrans(c
->win
, rule
->opacity
);
295 move_client_to_screen(c
, screen
, True
);
296 /* check for transient and set tags like its parent,
297 * XGetTransientForHint returns 1 on success
299 if((rettrans
= XGetTransientForHint(globalconf
.display
, w
, &trans
))
300 && (t
= get_client_bywin(globalconf
.clients
, trans
)))
301 for(tag
= globalconf
.screens
[c
->screen
].tags
; tag
; tag
= tag
->next
)
302 if(is_client_tagged(t
, tag
))
305 /* should be floating if transsient or fixed */
307 client_setfloating(c
, rettrans
|| c
->isfixed
);
310 XSelectInput(globalconf
.display
, w
, StructureNotifyMask
| PropertyChangeMask
| EnterWindowMask
);
313 if(globalconf
.have_shape
)
315 XShapeSelectInput(globalconf
.display
, w
, ShapeNotifyMask
);
316 window_setshape(phys_screen
, c
->win
);
319 /* attach to the stack */
320 if((rule
= rule_matching_client(c
)) && rule
->not_master
)
321 client_list_append(&globalconf
.clients
, c
);
322 else if(globalconf
.screens
[c
->screen
].new_become_master
)
323 client_list_push(&globalconf
.clients
, c
);
325 client_list_append(&globalconf
.clients
, c
);
327 /* some windows require this */
328 XMoveResizeWindow(globalconf
.display
, c
->win
, c
->geometry
.x
, c
->geometry
.y
,
329 c
->geometry
.width
, c
->geometry
.height
);
331 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
332 ewmh_update_net_client_list(phys_screen
);
335 /** Resize client window
336 * \param c client to resize
337 * \param geometry new window geometry
338 * \param sizehints respect size hints
339 * \param return True if resize has been done
342 client_resize(Client
*c
, Area geometry
, Bool sizehints
)
345 double dx
, dy
, max
, min
, ratio
;
351 if(c
->minay
> 0 && c
->maxay
> 0 && (geometry
.height
- c
->baseh
) > 0
352 && (geometry
.width
- c
->basew
) > 0)
354 dx
= (double) (geometry
.width
- c
->basew
);
355 dy
= (double) (geometry
.height
- c
->baseh
);
356 min
= (double) (c
->minax
) / (double) (c
->minay
);
357 max
= (double) (c
->maxax
) / (double) (c
->maxay
);
359 if(max
> 0 && min
> 0 && ratio
> 0)
363 dy
= (dx
* min
+ dy
) / (min
* min
+ 1);
365 geometry
.width
= (int) dx
+ c
->basew
;
366 geometry
.height
= (int) dy
+ c
->baseh
;
370 dy
= (dx
* min
+ dy
) / (max
* max
+ 1);
372 geometry
.width
= (int) dx
+ c
->basew
;
373 geometry
.height
= (int) dy
+ c
->baseh
;
377 if(c
->minw
&& geometry
.width
< c
->minw
)
378 geometry
.width
= c
->minw
;
379 if(c
->minh
&& geometry
.height
< c
->minh
)
380 geometry
.height
= c
->minh
;
381 if(c
->maxw
&& geometry
.width
> c
->maxw
)
382 geometry
.width
= c
->maxw
;
383 if(c
->maxh
&& geometry
.height
> c
->maxh
)
384 geometry
.height
= c
->maxh
;
386 geometry
.width
-= (geometry
.width
- c
->basew
) % c
->incw
;
388 geometry
.height
-= (geometry
.height
- c
->baseh
) % c
->inch
;
390 if(geometry
.width
<= 0 || geometry
.height
<= 0)
392 /* offscreen appearance fixes */
393 area
= get_display_area(get_phys_screen(c
->screen
),
395 &globalconf
.screens
[c
->screen
].padding
);
396 if(geometry
.x
> area
.width
)
397 geometry
.x
= area
.width
- geometry
.width
- 2 * c
->border
;
398 if(geometry
.y
> area
.height
)
399 geometry
.y
= area
.height
- geometry
.height
- 2 * c
->border
;
400 if(geometry
.x
+ geometry
.width
+ 2 * c
->border
< 0)
402 if(geometry
.y
+ geometry
.height
+ 2 * c
->border
< 0)
405 if(c
->geometry
.x
!= geometry
.x
|| c
->geometry
.y
!= geometry
.y
406 || c
->geometry
.width
!= geometry
.width
|| c
->geometry
.height
!= geometry
.height
)
408 new_screen
= get_screen_bycoord(geometry
.x
, geometry
.y
);
410 c
->geometry
.x
= wc
.x
= geometry
.x
;
411 c
->geometry
.y
= wc
.y
= geometry
.y
;
412 c
->geometry
.width
= wc
.width
= geometry
.width
;
413 c
->geometry
.height
= wc
.height
= geometry
.height
;
414 wc
.border_width
= c
->border
;
416 /* save the floating geometry if the window is floating but not
419 get_current_layout(new_screen
)->arrange
== layout_floating
) && !c
->ismax
)
420 c
->f_geometry
= geometry
;
422 XConfigureWindow(globalconf
.display
, c
->win
,
423 CWX
| CWY
| CWWidth
| CWHeight
| CWBorderWidth
, &wc
);
424 window_configure(c
->win
, geometry
, c
->border
);
426 if(c
->screen
!= new_screen
)
427 move_client_to_screen(c
, new_screen
, False
);
435 client_setfloating(Client
*c
, Bool floating
)
437 if(c
->isfloating
!= floating
)
439 if((c
->isfloating
= floating
))
440 client_resize(c
, c
->f_geometry
, False
);
444 client_resize(c
, c
->m_geometry
, False
);
446 if(client_isvisible(c
, c
->screen
))
447 globalconf
.screens
[c
->screen
].need_arrange
= True
;
448 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
453 /** Save client properties as an X property
457 client_saveprops(Client
*c
)
459 int i
= 0, ntags
= 0;
463 for(tag
= globalconf
.screens
[c
->screen
].tags
; tag
; tag
= tag
->next
)
466 prop
= p_new(char, ntags
+ 2);
468 for(tag
= globalconf
.screens
[c
->screen
].tags
; tag
; tag
= tag
->next
, i
++)
469 prop
[i
] = is_client_tagged(c
, tag
) ? '1' : '0';
472 prop
[i
] = c
->isfloating
? '1' : '0';
476 XChangeProperty(globalconf
.display
, c
->win
,
477 XInternAtom(globalconf
.display
, "_AWESOME_PROPERTIES", False
),
478 XA_STRING
, 8, PropModeReplace
, (unsigned char *) prop
, i
);
484 client_unban(Client
*c
)
486 XMapWindow(globalconf
.display
, c
->win
);
487 window_setstate(c
->win
, NormalState
);
491 client_unmanage(Client
*c
)
496 wc
.border_width
= c
->oldborder
;
498 /* The server grab construct avoids race conditions. */
499 XGrabServer(globalconf
.display
);
501 XConfigureWindow(globalconf
.display
, c
->win
, CWBorderWidth
, &wc
); /* restore border */
503 /* remove client everywhere */
504 client_list_detach(&globalconf
.clients
, c
);
505 focus_delete_client(c
);
506 for(tag
= globalconf
.screens
[c
->screen
].tags
; tag
; tag
= tag
->next
)
507 untag_client(c
, tag
);
509 if(globalconf
.focus
->client
== c
)
510 focus(NULL
, c
->screen
, False
);
512 XUngrabButton(globalconf
.display
, AnyButton
, AnyModifier
, c
->win
);
513 window_setstate(c
->win
, WithdrawnState
);
515 XSync(globalconf
.display
, False
);
516 XUngrabServer(globalconf
.display
);
522 client_updatewmhints(Client
*c
)
526 if((wmh
= XGetWMHints(globalconf
.display
, c
->win
)))
528 if((c
->isurgent
= (wmh
->flags
& XUrgencyHint
)))
529 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
530 if((wmh
->flags
& StateHint
) && wmh
->initial_state
== WithdrawnState
)
540 client_updatesizehints(Client
*c
)
545 if(!XGetWMNormalHints(globalconf
.display
, c
->win
, &size
, &msize
) || !size
.flags
)
547 if(size
.flags
& PBaseSize
)
549 c
->basew
= size
.base_width
;
550 c
->baseh
= size
.base_height
;
552 else if(size
.flags
& PMinSize
)
554 c
->basew
= size
.min_width
;
555 c
->baseh
= size
.min_height
;
558 c
->basew
= c
->baseh
= 0;
559 if(size
.flags
& PResizeInc
)
561 c
->incw
= size
.width_inc
;
562 c
->inch
= size
.height_inc
;
565 c
->incw
= c
->inch
= 0;
567 if(size
.flags
& PMaxSize
)
569 c
->maxw
= size
.max_width
;
570 c
->maxh
= size
.max_height
;
573 c
->maxw
= c
->maxh
= 0;
575 if(size
.flags
& PMinSize
)
577 c
->minw
= size
.min_width
;
578 c
->minh
= size
.min_height
;
580 else if(size
.flags
& PBaseSize
)
582 c
->minw
= size
.base_width
;
583 c
->minh
= size
.base_height
;
586 c
->minw
= c
->minh
= 0;
588 if(size
.flags
& PAspect
)
590 c
->minax
= size
.min_aspect
.x
;
591 c
->maxax
= size
.max_aspect
.x
;
592 c
->minay
= size
.min_aspect
.y
;
593 c
->maxay
= size
.max_aspect
.y
;
596 c
->minax
= c
->maxax
= c
->minay
= c
->maxay
= 0;
598 if(c
->maxw
&& c
->minw
&& c
->maxh
&& c
->minh
599 && c
->maxw
== c
->minw
&& c
->maxh
== c
->minh
)
603 /** Returns True if a client is tagged
604 * with one of the tags
605 * \return True or False
608 client_isvisible(Client
*c
, int screen
)
612 if(!c
|| c
->screen
!= screen
)
615 for(tag
= globalconf
.screens
[screen
].tags
; tag
; tag
= tag
->next
)
616 if(tag
->selected
&& is_client_tagged(c
, tag
))
621 /** Set selected client transparency
622 * \param screen Screen ID
623 * \param arg unused arg
624 * \ingroup ui_callback
627 uicb_client_settrans(int screen
__attribute__ ((unused
)), char *arg
)
629 double delta
= 100.0, current_opacity
= 100.0;
633 unsigned long n
, left
;
634 unsigned int current_opacity_raw
= 0;
636 Client
*sel
= globalconf
.focus
->client
;
641 XGetWindowProperty(globalconf
.display
, sel
->win
,
642 XInternAtom(globalconf
.display
, "_NET_WM_WINDOW_OPACITY", False
),
643 0L, 1L, False
, XA_CARDINAL
, &actual
, &format
, &n
, &left
,
644 (unsigned char **) &data
);
647 memcpy(¤t_opacity_raw
, data
, sizeof(unsigned int));
649 current_opacity
= (current_opacity_raw
* 100.0) / 0xffffffff;
654 delta
= compute_new_value_from_arg(arg
, current_opacity
);
658 else if(delta
> 100.0)
664 if(delta
== 100.0 && !set_prop
)
665 window_settrans(sel
->win
, -1);
667 window_settrans(sel
->win
, delta
);
671 client_find_prev_visible(Client
*sel
)
675 if(!sel
) return NULL
;
677 /* look for previous starting at sel */
678 for(prev
= client_list_prev_cycle(&globalconf
.clients
, sel
);
679 prev
&& (prev
->skip
|| !client_isvisible(prev
, sel
->screen
));
680 prev
= client_list_prev_cycle(&globalconf
.clients
, prev
));
686 client_find_next_visible(Client
*sel
)
690 if(!sel
) return NULL
;
692 for(next
= sel
->next
; next
&& !client_isvisible(next
, sel
->screen
); next
= next
->next
);
694 for(next
= globalconf
.clients
; next
&& !client_isvisible(next
, sel
->screen
); next
= next
->next
);
699 /** Swap current with previous client
700 * \param screen Screen ID
702 * \ingroup ui_callback
705 uicb_client_swapprev(int screen
__attribute__ ((unused
)),
706 char *arg
__attribute__ ((unused
)))
710 if((prev
= client_find_prev_visible(globalconf
.focus
->client
)))
712 client_list_swap(&globalconf
.clients
, prev
, globalconf
.focus
->client
);
713 globalconf
.screens
[prev
->screen
].need_arrange
= True
;
717 /** Swap current with next client
718 * \param screen Screen ID
720 * \ingroup ui_callback
723 uicb_client_swapnext(int screen
__attribute__ ((unused
)),
724 char *arg
__attribute__ ((unused
)))
728 if((next
= client_find_next_visible(globalconf
.focus
->client
)))
730 client_list_swap(&globalconf
.clients
, globalconf
.focus
->client
, next
);
731 globalconf
.screens
[next
->screen
].need_arrange
= True
;
735 /** Move and resize client
736 * \param screen Screen ID
738 * \ingroup ui_callback
741 uicb_client_moveresize(int screen
, char *arg
)
744 char x
[8], y
[8], w
[8], h
[8];
745 int mx
, my
, dx
, dy
, nmx
, nmy
;
749 Client
*sel
= globalconf
.focus
->client
;
750 Tag
**curtags
= get_current_tags(screen
);
752 if(curtags
[0]->layout
->arrange
!= layout_floating
)
753 if(!sel
|| !sel
->isfloating
|| sel
->isfixed
|| !arg
)
759 if(sscanf(arg
, "%s %s %s %s", x
, y
, w
, h
) != 4)
761 area
.x
= (int) compute_new_value_from_arg(x
, sel
->geometry
.x
);
762 area
.y
= (int) compute_new_value_from_arg(y
, sel
->geometry
.y
);
763 area
.width
= (int) compute_new_value_from_arg(w
, sel
->geometry
.width
);
764 area
.height
= (int) compute_new_value_from_arg(h
, sel
->geometry
.height
);
766 ox
= sel
->geometry
.x
;
767 oy
= sel
->geometry
.y
;
768 ow
= sel
->geometry
.width
;
769 oh
= sel
->geometry
.height
;
771 Bool xqp
= XQueryPointer(globalconf
.display
,
772 RootWindow(globalconf
.display
,
773 get_phys_screen(screen
)),
774 &dummy
, &dummy
, &mx
, &my
, &dx
, &dy
, &dui
);
775 client_resize(sel
, area
, globalconf
.screens
[sel
->screen
].resize_hints
);
776 if (xqp
&& ox
<= mx
&& (ox
+ ow
) >= mx
&& oy
<= my
&& (oy
+ oh
) >= my
)
778 nmx
= mx
- ox
+ sel
->geometry
.width
- ow
- 1 < 0 ? 0 : mx
- ox
+ sel
->geometry
.width
- ow
- 1;
779 nmy
= my
- oy
+ sel
->geometry
.height
- oh
- 1 < 0 ? 0 : my
- oy
+ sel
->geometry
.height
- oh
- 1;
780 XWarpPointer(globalconf
.display
,
782 0, 0, 0, 0, nmx
, nmy
);
787 client_kill(Client
*c
)
791 if(isprotodel(globalconf
.display
, c
->win
))
793 ev
.type
= ClientMessage
;
794 ev
.xclient
.window
= c
->win
;
795 ev
.xclient
.message_type
= XInternAtom(globalconf
.display
, "WM_PROTOCOLS", False
);
796 ev
.xclient
.format
= 32;
797 ev
.xclient
.data
.l
[0] = XInternAtom(globalconf
.display
, "WM_DELETE_WINDOW", False
);
798 ev
.xclient
.data
.l
[1] = CurrentTime
;
799 XSendEvent(globalconf
.display
, c
->win
, False
, NoEventMask
, &ev
);
802 XKillClient(globalconf
.display
, c
->win
);
805 /** Kill selected client
806 * \param screen Screen ID
808 * \ingroup ui_callback
811 uicb_client_kill(int screen
__attribute__ ((unused
)), char *arg
__attribute__ ((unused
)))
813 Client
*sel
= globalconf
.focus
->client
;
820 client_maximize(Client
*c
, Area geometry
)
823 if((c
->ismax
= !c
->ismax
))
825 c
->wasfloating
= c
->isfloating
;
826 c
->m_geometry
= c
->geometry
;
827 if(get_current_layout(c
->screen
)->arrange
!= layout_floating
)
828 client_setfloating(c
, True
);
829 client_resize(c
, geometry
, False
);
830 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
832 else if(c
->wasfloating
)
834 client_setfloating(c
, True
);
835 client_resize(c
, c
->m_geometry
, False
);
836 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
838 else if(get_current_layout(c
->screen
)->arrange
== layout_floating
)
840 client_resize(c
, c
->m_geometry
, False
);
841 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
845 client_setfloating(c
, False
);
846 widget_invalidate_cache(c
->screen
, WIDGET_CACHE_CLIENTS
);
850 /** Toggle maximize for client
851 * \param screen Screen ID
853 * \ingroup ui_callback
856 uicb_client_togglemax(int screen
, char *arg
__attribute__ ((unused
)))
858 Client
*sel
= globalconf
.focus
->client
;
859 Area area
= get_screen_area(screen
,
860 globalconf
.screens
[screen
].statusbar
,
861 &globalconf
.screens
[screen
].padding
);
865 area
.width
-= 2 * sel
->border
;
866 area
.height
-= 2 * sel
->border
;
867 client_maximize(sel
, area
);
871 /** Toggle vertical maximize for client
872 * \param screen Screen ID
874 * \ingroup ui_callback
877 uicb_client_toggleverticalmax(int screen
, char *arg
__attribute__ ((unused
)))
879 Client
*sel
= globalconf
.focus
->client
;
880 Area area
= get_screen_area(screen
,
881 globalconf
.screens
[screen
].statusbar
,
882 &globalconf
.screens
[screen
].padding
);
886 area
.x
= sel
->geometry
.x
;
887 area
.width
= sel
->geometry
.width
;
888 area
.height
-= 2 * sel
->border
;
889 client_maximize(sel
, area
);
894 /** Toggle horizontal maximize for client
895 * \param screen Screen ID
897 * \ingroup ui_callback
900 uicb_client_togglehorizontalmax(int screen
, char *arg
__attribute__ ((unused
)))
902 Client
*sel
= globalconf
.focus
->client
;
903 Area area
= get_screen_area(screen
,
904 globalconf
.screens
[screen
].statusbar
,
905 &globalconf
.screens
[screen
].padding
);
909 area
.y
= sel
->geometry
.y
;
910 area
.height
= sel
->geometry
.height
;
911 area
.width
-= 2 * sel
->border
;
912 client_maximize(sel
, area
);
917 * \param screen Screen ID
919 * \ingroup ui_callback
922 uicb_client_zoom(int screen
, char *arg
__attribute__ ((unused
)))
924 Client
*c
, *sel
= globalconf
.focus
->client
;
926 for(c
= globalconf
.clients
; !client_isvisible(c
, screen
); c
= c
->next
);
928 for(sel
= sel
->next
; sel
&& !client_isvisible(sel
, screen
); sel
= sel
->next
);
933 client_list_detach(&globalconf
.clients
, sel
);
934 client_list_push(&globalconf
.clients
, sel
);
935 globalconf
.screens
[screen
].need_arrange
= True
;
938 /** Send focus to next client in stack
939 * \param screen Screen ID
941 * \ingroup ui_callback
944 uicb_client_focusnext(int screen
, char *arg
__attribute__ ((unused
)))
946 Client
*c
, *sel
= globalconf
.focus
->client
;
950 for(c
= sel
->next
; c
&& (c
->skip
|| !client_isvisible(c
, screen
)); c
= c
->next
);
952 for(c
= globalconf
.clients
; c
&& (c
->skip
|| !client_isvisible(c
, screen
)); c
= c
->next
);
954 focus(c
, screen
, False
);
957 /** Send focus to previous client in stack
958 * \param screen Screen ID
960 * \ingroup ui_callback
963 uicb_client_focusprev(int screen
, char *arg
__attribute__ ((unused
)))
967 if((prev
= client_find_prev_visible(globalconf
.focus
->client
)))
968 focus(prev
, screen
, False
);
971 /** Toggle floating state of a client
972 * \param screen Screen ID
974 * \ingroup ui_callback
977 uicb_client_togglefloating(int screen
__attribute__ ((unused
)),
978 char *arg
__attribute__ ((unused
)))
980 if(globalconf
.focus
->client
)
981 client_setfloating(globalconf
.focus
->client
, !globalconf
.focus
->client
->isfloating
);
984 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80