<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>i3: src/layout.c Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.2-20100208 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <h1>src/layout.c</h1><a href="a00069.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> * vim:ts=8:expandtab</span> <a name="l00003"></a>00003 <span class="comment"> *</span> <a name="l00004"></a>00004 <span class="comment"> * i3 - an improved dynamic tiling window manager</span> <a name="l00005"></a>00005 <span class="comment"> *</span> <a name="l00006"></a>00006 <span class="comment"> * © 2009-2010 Michael Stapelberg and contributors</span> <a name="l00007"></a>00007 <span class="comment"> *</span> <a name="l00008"></a>00008 <span class="comment"> * See file LICENSE for license information.</span> <a name="l00009"></a>00009 <span class="comment"> *</span> <a name="l00010"></a>00010 <span class="comment"> * layout.c: Functions handling layout/drawing of window decorations</span> <a name="l00011"></a>00011 <span class="comment"> *</span> <a name="l00012"></a>00012 <span class="comment"> */</span> <a name="l00013"></a>00013 <span class="preprocessor">#include <stdio.h></span> <a name="l00014"></a>00014 <span class="preprocessor">#include <string.h></span> <a name="l00015"></a>00015 <span class="preprocessor">#include <stdlib.h></span> <a name="l00016"></a>00016 <span class="preprocessor">#include <xcb/xcb.h></span> <a name="l00017"></a>00017 <span class="preprocessor">#include <assert.h></span> <a name="l00018"></a>00018 <span class="preprocessor">#include <math.h></span> <a name="l00019"></a>00019 <a name="l00020"></a>00020 <span class="preprocessor">#include "<a class="code" href="a00034.html">config.h</a>"</span> <a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="a00041.html">i3.h</a>"</span> <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="a00054.html">xcb.h</a>"</span> <a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="a00051.html">table.h</a>"</span> <a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="a00052.html">util.h</a>"</span> <a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="a00048.html">randr.h</a>"</span> <a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="a00043.html">layout.h</a>"</span> <a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="a00032.html">client.h</a>"</span> <a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="a00039.html">floating.h</a>"</span> <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="a00040.html">handlers.h</a>"</span> <a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="a00053.html">workspace.h</a>"</span> <a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="a00044.html">log.h</a>"</span> <a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="a00035.html">container.h</a>"</span> <a name="l00033"></a>00033 <a name="l00034"></a>00034 <span class="comment">/*</span> <a name="l00035"></a>00035 <span class="comment"> * Gets the unoccupied space (= space which is available for windows which were resized by the user)</span> <a name="l00036"></a>00036 <span class="comment"> * for the given row. This is necessary to render both, customly resized windows and never touched</span> <a name="l00037"></a>00037 <span class="comment"> * windows correctly, meaning that the aspect ratio will be maintained when opening new windows.</span> <a name="l00038"></a>00038 <span class="comment"> *</span> <a name="l00039"></a>00039 <span class="comment"> */</span> <a name="l00040"></a><a class="code" href="a00043.html#a58500d1d5e56285ceb2bd514dbee8a2f">00040</a> <span class="keywordtype">int</span> <a class="code" href="a00069.html#a58500d1d5e56285ceb2bd514dbee8a2f" title="Gets the unoccupied space (= space which is available for windows which were resized...">get_unoccupied_x</a>(<a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *workspace) { <a name="l00041"></a>00041 <span class="keywordtype">double</span> unoccupied = workspace-><a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>; <a name="l00042"></a>00042 <span class="keywordtype">double</span> default_factor = ((float)workspace-><a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> / workspace-><a class="code" href="a00025.html#a1d295f430fa92fc0b91c7f85a4b499b2" title="table dimensions">cols</a>) / workspace-><a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>; <a name="l00043"></a>00043 <a name="l00044"></a>00044 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"get_unoccupied_x(), starting with %f, default_factor = %f\n"</span>, unoccupied, default_factor); <a name="l00045"></a>00045 <a name="l00046"></a>00046 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> cols = 0; cols < workspace-><a class="code" href="a00025.html#a1d295f430fa92fc0b91c7f85a4b499b2" title="table dimensions">cols</a>; cols++) { <a name="l00047"></a>00047 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"width_factor[%d] = %f, unoccupied = %f\n"</span>, cols, workspace-><a class="code" href="a00025.html#a9821dccf3f7541515549feb57527dcb6" title="width_factor and height_factor contain the amount of space (percentage) a column/row...">width_factor</a>[cols], unoccupied); <a name="l00048"></a>00048 <a name="l00049"></a>00049 <span class="keywordflow">if</span> (workspace-><a class="code" href="a00025.html#a9821dccf3f7541515549feb57527dcb6" title="width_factor and height_factor contain the amount of space (percentage) a column/row...">width_factor</a>[cols] == 0) <a name="l00050"></a>00050 unoccupied -= workspace-><a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> * default_factor; <a name="l00051"></a>00051 } <a name="l00052"></a>00052 <a name="l00053"></a>00053 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"unoccupied space: %f\n"</span>, unoccupied); <a name="l00054"></a>00054 <span class="keywordflow">return</span> unoccupied; <a name="l00055"></a>00055 } <a name="l00056"></a>00056 <a name="l00057"></a>00057 <span class="comment">/* See get_unoccupied_x() */</span> <a name="l00058"></a><a class="code" href="a00043.html#a9ca57ef4162045e82bf24e326ec8a936">00058</a> <span class="keywordtype">int</span> <a class="code" href="a00069.html#a9ca57ef4162045e82bf24e326ec8a936" title="See get_unoccupied_x.">get_unoccupied_y</a>(<a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *workspace) { <a name="l00059"></a>00059 <span class="keywordtype">int</span> height = <a class="code" href="a00078.html#af55407f9bc846ec57cf289c87a47dbce">workspace_height</a>(workspace); <a name="l00060"></a>00060 <span class="keywordtype">double</span> unoccupied = height; <a name="l00061"></a>00061 <span class="keywordtype">double</span> default_factor = ((float)height / workspace-><a class="code" href="a00025.html#ae4fee0126eb1ae8484bf7281709c3fdb" title="table dimensions">rows</a>) / height; <a name="l00062"></a>00062 <a name="l00063"></a>00063 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"get_unoccupied_y(), starting with %f, default_factor = %f\n"</span>, unoccupied, default_factor); <a name="l00064"></a>00064 <a name="l00065"></a>00065 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> rows = 0; rows < workspace-><a class="code" href="a00025.html#ae4fee0126eb1ae8484bf7281709c3fdb" title="table dimensions">rows</a>; rows++) { <a name="l00066"></a>00066 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"height_factor[%d] = %f, unoccupied = %f\n"</span>, rows, workspace-><a class="code" href="a00025.html#a88f474bf999c23126a00922de6102822">height_factor</a>[rows], unoccupied); <a name="l00067"></a>00067 <span class="keywordflow">if</span> (workspace-><a class="code" href="a00025.html#a88f474bf999c23126a00922de6102822">height_factor</a>[rows] == 0) <a name="l00068"></a>00068 unoccupied -= height * default_factor; <a name="l00069"></a>00069 } <a name="l00070"></a>00070 <a name="l00071"></a>00071 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"unoccupied space: %f\n"</span>, unoccupied); <a name="l00072"></a>00072 <span class="keywordflow">return</span> unoccupied; <a name="l00073"></a>00073 } <a name="l00074"></a>00074 <a name="l00075"></a>00075 <span class="comment">/*</span> <a name="l00076"></a>00076 <span class="comment"> * Redecorates the given client correctly by checking if it’s in a stacking container and</span> <a name="l00077"></a>00077 <span class="comment"> * re-rendering the stack window or just calling decorate_window if it’s not in a stacking</span> <a name="l00078"></a>00078 <span class="comment"> * container.</span> <a name="l00079"></a>00079 <span class="comment"> *</span> <a name="l00080"></a>00080 <span class="comment"> */</span> <a name="l00081"></a><a class="code" href="a00043.html#ac78b8a4b371d2c4c2800c765f46e5df3">00081</a> <span class="keywordtype">void</span> <a class="code" href="a00069.html#ac78b8a4b371d2c4c2800c765f46e5df3" title="Redecorates the given client correctly by checking if it’s in a stacking container...">redecorate_window</a>(xcb_connection_t *conn, <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client) { <a name="l00082"></a>00082 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a> != NULL && <a name="l00083"></a>00083 (client-><a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>-><a class="code" href="a00013.html#ac094306ab77e360742aba04d7cbd0fe6">mode</a> == MODE_STACK || <a name="l00084"></a>00084 client-><a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>-><a class="code" href="a00013.html#ac094306ab77e360742aba04d7cbd0fe6">mode</a> == MODE_TABBED)) { <a name="l00085"></a>00085 <a class="code" href="a00069.html#a2a1fee0aebdaf2497fb52ea57a1033a4" title="Renders the given container.">render_container</a>(conn, client-><a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>); <a name="l00086"></a>00086 <span class="comment">/* We clear the frame to generate exposure events, because the color used</span> <a name="l00087"></a>00087 <span class="comment"> in drawing may be different */</span> <a name="l00088"></a>00088 xcb_clear_area(conn, <span class="keyword">true</span>, client-><a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, 0, 0, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>); <a name="l00089"></a>00089 } <span class="keywordflow">else</span> <a class="code" href="a00069.html#a1ea737657e6613d21ad663bb45c82dd2" title="(Re-)draws window decorations for a given Client onto the given drawable/graphic...">decorate_window</a>(conn, client, client-><a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, client-><a class="code" href="a00007.html#ab9525d9a134fa0d25a1352f8e58bee2e" title="The titlebar’s graphic context inside the frame.">titlegc</a>, 0, 0); <a name="l00090"></a>00090 xcb_flush(conn); <a name="l00091"></a>00091 } <a name="l00092"></a>00092 <a name="l00093"></a>00093 <span class="comment">/*</span> <a name="l00094"></a>00094 <span class="comment"> * (Re-)draws window decorations for a given Client onto the given drawable/graphic context.</span> <a name="l00095"></a>00095 <span class="comment"> * When in stacking mode, the window decorations are drawn onto an own window.</span> <a name="l00096"></a>00096 <span class="comment"> *</span> <a name="l00097"></a>00097 <span class="comment"> */</span> <a name="l00098"></a><a class="code" href="a00043.html#a1ea737657e6613d21ad663bb45c82dd2">00098</a> <span class="keywordtype">void</span> <a class="code" href="a00069.html#a1ea737657e6613d21ad663bb45c82dd2" title="(Re-)draws window decorations for a given Client onto the given drawable/graphic...">decorate_window</a>(xcb_connection_t *conn, <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client, xcb_drawable_t drawable, <a name="l00099"></a>00099 xcb_gcontext_t gc, <span class="keywordtype">int</span> offset_x, <span class="keywordtype">int</span> offset_y) { <a name="l00100"></a>00100 <a class="code" href="a00015.html" title="Data structure for cached font information:font id in X11 (load it once)font height...">i3Font</a> *font = <a class="code" href="a00054.html#a50c1fc0de5343536d542c8349ab7ab0d" title="Loads a font for usage, getting its height.">load_font</a>(conn, <a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#aff568f0d5ca7a51971f4c3006a842019">font</a>); <a name="l00101"></a>00101 <span class="keywordtype">int</span> decoration_height = font-><a class="code" href="a00015.html#a89ceb86bb4ad2694315d846e69893399" title="The height of the font, built from font_ascent + font_descent.">height</a> + 2 + 2; <a name="l00102"></a>00102 <span class="keyword">struct </span><a class="code" href="a00009.html" title="Part of the struct Config.">Colortriple</a> *color; <a name="l00103"></a>00103 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *last_focused; <a name="l00104"></a>00104 <a name="l00105"></a>00105 <span class="comment">/* Clients without a container (docks) won’t get decorated */</span> <a name="l00106"></a>00106 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a994b0c5a9eb35e42f04a0b845a3166ef" title="If a client is set as a dock, it is placed at the very bottom of the screen and its...">dock</a>) <a name="l00107"></a>00107 <span class="keywordflow">return</span>; <a name="l00108"></a>00108 <a name="l00109"></a>00109 last_focused = <a class="code" href="a00047.html#a91bac7d0d32e3ec56bc579ace45ed8cd">SLIST_FIRST</a>(&(client-><a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a>->focus_stack)); <a name="l00110"></a>00110 <span class="comment">/* Is the window urgent? */</span> <a name="l00111"></a>00111 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#ad169bd46b1c1edf6f7cddf2c0c5306c7" title="True if the client set the urgency flag in its WM_HINTS property.">urgent</a>) <a name="l00112"></a>00112 color = &(<a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#a2cfc8e52ae874b8a76b8103b8da7b520">client</a>.<a class="code" href="a00012.html#aa99761c3565876674356bf2cb5f62856">urgent</a>); <a name="l00113"></a>00113 <span class="keywordflow">else</span> { <a name="l00114"></a>00114 <span class="keywordflow">if</span> (<a class="code" href="a00060.html#a56065826f75013837bc8e125c8dc66c7" title="Returns true if the client is floating.">client_is_floating</a>(client)) { <a name="l00115"></a>00115 <span class="keywordflow">if</span> (last_focused == client) <a name="l00116"></a>00116 color = &(<a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#a2cfc8e52ae874b8a76b8103b8da7b520">client</a>.<a class="code" href="a00012.html#a099c67879c7e681a9679a2215b9a5345">focused</a>); <a name="l00117"></a>00117 <span class="keywordflow">else</span> color = &(<a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#a2cfc8e52ae874b8a76b8103b8da7b520">client</a>.<a class="code" href="a00012.html#a5b24b86010b37d8771adae7df82f4c04">unfocused</a>); <a name="l00118"></a>00118 } <span class="keywordflow">else</span> { <a name="l00119"></a>00119 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>-><a class="code" href="a00013.html#a82d910506b0d788a92ebeeb1d82da75b">currently_focused</a> == client) { <a name="l00120"></a>00120 <span class="comment">/* Distinguish if the window is currently focused… */</span> <a name="l00121"></a>00121 <span class="keywordflow">if</span> (last_focused == client && <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a> == client-><a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a>) <a name="l00122"></a>00122 color = &(<a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#a2cfc8e52ae874b8a76b8103b8da7b520">client</a>.<a class="code" href="a00012.html#a099c67879c7e681a9679a2215b9a5345">focused</a>); <a name="l00123"></a>00123 <span class="comment">/* …or if it is the focused window in a not focused container */</span> <a name="l00124"></a>00124 <span class="keywordflow">else</span> color = &(<a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#a2cfc8e52ae874b8a76b8103b8da7b520">client</a>.<a class="code" href="a00012.html#ac0752caef95470dc6e6bf425ee88134f">focused_inactive</a>); <a name="l00125"></a>00125 } <span class="keywordflow">else</span> color = &(<a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#a2cfc8e52ae874b8a76b8103b8da7b520">client</a>.<a class="code" href="a00012.html#a5b24b86010b37d8771adae7df82f4c04">unfocused</a>); <a name="l00126"></a>00126 } <a name="l00127"></a>00127 } <a name="l00128"></a>00128 <a name="l00129"></a>00129 <span class="comment">/* Our plan is the following:</span> <a name="l00130"></a>00130 <span class="comment"> - Draw a rect around the whole client in color->background</span> <a name="l00131"></a>00131 <span class="comment"> - Draw two lines in a lighter color</span> <a name="l00132"></a>00132 <span class="comment"> - Draw the window’s title</span> <a name="l00133"></a>00133 <span class="comment"> */</span> <a name="l00134"></a>00134 <span class="keywordtype">int</span> mode = <a class="code" href="a00063.html#a613f019bb3d6960b1ff386eca5316158" title="Returns the mode of the given container (or MODE_DEFAULT if a NULL pointer was passed...">container_mode</a>(client-><a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>, <span class="keyword">true</span>); <a name="l00135"></a>00135 <a name="l00136"></a>00136 <span class="comment">/* Draw a rectangle in background color around the window */</span> <a name="l00137"></a>00137 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a5a1078f3b194418aa54c1837ff82351c" title="Contains a bool specifying whether this window should not be drawn with the usual...">borderless</a> && mode == MODE_DEFAULT) <a name="l00138"></a>00138 <a class="code" href="a00079.html#ac20ce6b9cf46f63675e363ac5dc2f24e" title="Changes a single value in the graphic context (so one doesn’t have to define an...">xcb_change_gc_single</a>(conn, gc, XCB_GC_FOREGROUND, <a class="code" href="a00079.html#a0146fe310e31c9509a7a7846aa547c67" title="Returns the colorpixel to use for the given hex color (think of HTML).">get_colorpixel</a>(conn, <span class="stringliteral">"#000000"</span>)); <a name="l00139"></a>00139 <span class="keywordflow">else</span> <a class="code" href="a00079.html#ac20ce6b9cf46f63675e363ac5dc2f24e" title="Changes a single value in the graphic context (so one doesn’t have to define an...">xcb_change_gc_single</a>(conn, gc, XCB_GC_FOREGROUND, color-><a class="code" href="a00009.html#a54065f4c7667110b00ece931b9a45348">background</a>); <a name="l00140"></a>00140 <a name="l00141"></a>00141 <span class="comment">/* In stacking mode, we only render the rect for this specific decoration */</span> <a name="l00142"></a>00142 <span class="keywordflow">if</span> (mode == MODE_STACK || mode == MODE_TABBED) { <a name="l00143"></a>00143 <span class="comment">/* We need to use the container’s width because it is the more recent value - when</span> <a name="l00144"></a>00144 <span class="comment"> in stacking mode, clients get reconfigured only on demand (the not active client</span> <a name="l00145"></a>00145 <span class="comment"> is not reconfigured), so the client’s rect.width would be wrong */</span> <a name="l00146"></a>00146 xcb_rectangle_t rect = {offset_x, offset_y, <a name="l00147"></a>00147 offset_x + client-><a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>-><a class="code" href="a00013.html#af9b566fc3a8a208897503254747ae720">width</a>, <a name="l00148"></a>00148 offset_y + decoration_height }; <a name="l00149"></a>00149 xcb_poly_fill_rectangle(conn, drawable, gc, 1, &rect); <a name="l00150"></a>00150 } <span class="keywordflow">else</span> { <a name="l00151"></a>00151 xcb_rectangle_t rect = {0, 0, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>}; <a name="l00152"></a>00152 xcb_poly_fill_rectangle(conn, drawable, gc, 1, &rect); <a name="l00153"></a>00153 <a name="l00154"></a>00154 <span class="comment">/* Draw the inner background to have a black frame around clients (such as mplayer)</span> <a name="l00155"></a>00155 <span class="comment"> which cannot be resized exactly in our frames and therefore are centered */</span> <a name="l00156"></a>00156 <a class="code" href="a00079.html#ac20ce6b9cf46f63675e363ac5dc2f24e" title="Changes a single value in the graphic context (so one doesn’t have to define an...">xcb_change_gc_single</a>(conn, client-><a class="code" href="a00007.html#ab9525d9a134fa0d25a1352f8e58bee2e" title="The titlebar’s graphic context inside the frame.">titlegc</a>, XCB_GC_FOREGROUND, <a class="code" href="a00079.html#a0146fe310e31c9509a7a7846aa547c67" title="Returns the colorpixel to use for the given hex color (think of HTML).">get_colorpixel</a>(conn, <span class="stringliteral">"#000000"</span>)); <a name="l00157"></a>00157 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a990cfbc44d87127fd05d8f6a5293d2fd" title="Ensure TITLEBAR_TOP maps to 0 because we use calloc for initialization later.">titlebar_position</a> == TITLEBAR_OFF && client-><a class="code" href="a00007.html#a5a1078f3b194418aa54c1837ff82351c" title="Contains a bool specifying whether this window should not be drawn with the usual...">borderless</a>) { <a name="l00158"></a>00158 xcb_rectangle_t crect = {0, 0, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>}; <a name="l00159"></a>00159 xcb_poly_fill_rectangle(conn, client-><a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, client-><a class="code" href="a00007.html#ab9525d9a134fa0d25a1352f8e58bee2e" title="The titlebar’s graphic context inside the frame.">titlegc</a>, 1, &crect); <a name="l00160"></a>00160 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a990cfbc44d87127fd05d8f6a5293d2fd" title="Ensure TITLEBAR_TOP maps to 0 because we use calloc for initialization later.">titlebar_position</a> == TITLEBAR_OFF && !client-><a class="code" href="a00007.html#a5a1078f3b194418aa54c1837ff82351c" title="Contains a bool specifying whether this window should not be drawn with the usual...">borderless</a>) { <a name="l00161"></a>00161 xcb_rectangle_t crect = {1, 1, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> - (1 + 1), client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> - (1 + 1)}; <a name="l00162"></a>00162 xcb_poly_fill_rectangle(conn, client-><a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, client-><a class="code" href="a00007.html#ab9525d9a134fa0d25a1352f8e58bee2e" title="The titlebar’s graphic context inside the frame.">titlegc</a>, 1, &crect); <a name="l00163"></a>00163 } <span class="keywordflow">else</span> { <a name="l00164"></a>00164 xcb_rectangle_t crect = {2, decoration_height, <a name="l00165"></a>00165 client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> - (2 + 2), client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> - 2 - decoration_height}; <a name="l00166"></a>00166 xcb_poly_fill_rectangle(conn, client-><a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, client-><a class="code" href="a00007.html#ab9525d9a134fa0d25a1352f8e58bee2e" title="The titlebar’s graphic context inside the frame.">titlegc</a>, 1, &crect); <a name="l00167"></a>00167 } <a name="l00168"></a>00168 } <a name="l00169"></a>00169 <a name="l00170"></a>00170 mode = <a class="code" href="a00063.html#a613f019bb3d6960b1ff386eca5316158" title="Returns the mode of the given container (or MODE_DEFAULT if a NULL pointer was passed...">container_mode</a>(client-><a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>, <span class="keyword">false</span>); <a name="l00171"></a>00171 <a name="l00172"></a>00172 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a990cfbc44d87127fd05d8f6a5293d2fd" title="Ensure TITLEBAR_TOP maps to 0 because we use calloc for initialization later.">titlebar_position</a> != TITLEBAR_OFF) { <a name="l00173"></a>00173 <span class="comment">/* Draw the lines */</span> <a name="l00174"></a>00174 <a class="code" href="a00079.html#aceb7b1de1af10ea8def35d48a1b0caad" title="Draws a line from x,y to to_x,to_y using the given color.">xcb_draw_line</a>(conn, drawable, gc, color-><a class="code" href="a00009.html#abc8ad1d75ff1d44e27aeb6c2eb7713a0">border</a>, offset_x, offset_y, offset_x + client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, offset_y); <a name="l00175"></a>00175 <a class="code" href="a00079.html#aceb7b1de1af10ea8def35d48a1b0caad" title="Draws a line from x,y to to_x,to_y using the given color.">xcb_draw_line</a>(conn, drawable, gc, color-><a class="code" href="a00009.html#abc8ad1d75ff1d44e27aeb6c2eb7713a0">border</a>, <a name="l00176"></a>00176 offset_x + 2, <span class="comment">/* x */</span> <a name="l00177"></a>00177 offset_y + font-><a class="code" href="a00015.html#a89ceb86bb4ad2694315d846e69893399" title="The height of the font, built from font_ascent + font_descent.">height</a> + 3, <span class="comment">/* y */</span> <a name="l00178"></a>00178 offset_x + client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> - 3, <span class="comment">/* to_x */</span> <a name="l00179"></a>00179 offset_y + font-><a class="code" href="a00015.html#a89ceb86bb4ad2694315d846e69893399" title="The height of the font, built from font_ascent + font_descent.">height</a> + 3 <span class="comment">/* to_y */</span>); <a name="l00180"></a>00180 } <a name="l00181"></a>00181 <a name="l00182"></a>00182 <span class="comment">/* If the client has a title, we draw it */</span> <a name="l00183"></a>00183 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a14c9eb7f57edfd939ed2fada25e83916" title="Name (= window title).">name</a> != NULL && <a name="l00184"></a>00184 (mode != MODE_DEFAULT || client-><a class="code" href="a00007.html#a990cfbc44d87127fd05d8f6a5293d2fd" title="Ensure TITLEBAR_TOP maps to 0 because we use calloc for initialization later.">titlebar_position</a> != TITLEBAR_OFF)) { <a name="l00185"></a>00185 <span class="comment">/* Draw the font */</span> <a name="l00186"></a>00186 uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT; <a name="l00187"></a>00187 uint32_t values[] = { color-><a class="code" href="a00009.html#ac75bcfcac277782b13996a42ecbe355f">text</a>, color-><a class="code" href="a00009.html#a54065f4c7667110b00ece931b9a45348">background</a>, font-><a class="code" href="a00015.html#a34f00fc78328c10986cdebfc3940ee05" title="The xcb-id for the font.">id</a> }; <a name="l00188"></a>00188 xcb_change_gc(conn, gc, mask, values); <a name="l00189"></a>00189 <a name="l00190"></a>00190 <span class="comment">/* name_len == -1 means this is a legacy application which does not specify _NET_WM_NAME,</span> <a name="l00191"></a>00191 <span class="comment"> and we don’t handle the old window name (COMPOUND_TEXT) but only _NET_WM_NAME, which</span> <a name="l00192"></a>00192 <span class="comment"> is UTF-8 */</span> <a name="l00193"></a>00193 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#aa6a6f0505f2d751ea862bc97343dd6df" title="name_len stores the real string length (glyphs) of the window title if the client...">name_len</a> == -1) <a name="l00194"></a>00194 xcb_image_text_8(conn, strlen(client-><a class="code" href="a00007.html#a14c9eb7f57edfd939ed2fada25e83916" title="Name (= window title).">name</a>), drawable, gc, offset_x + 3 <span class="comment">/* X */</span>, <a name="l00195"></a>00195 offset_y + font-><a class="code" href="a00015.html#a89ceb86bb4ad2694315d846e69893399" title="The height of the font, built from font_ascent + font_descent.">height</a> <span class="comment">/* Y = baseline of font */</span>, client-><a class="code" href="a00007.html#a14c9eb7f57edfd939ed2fada25e83916" title="Name (= window title).">name</a>); <a name="l00196"></a>00196 <span class="keywordflow">else</span> <a name="l00197"></a>00197 xcb_image_text_16(conn, client-><a class="code" href="a00007.html#aa6a6f0505f2d751ea862bc97343dd6df" title="name_len stores the real string length (glyphs) of the window title if the client...">name_len</a>, drawable, gc, offset_x + 3 <span class="comment">/* X */</span>, <a name="l00198"></a>00198 offset_y + font-><a class="code" href="a00015.html#a89ceb86bb4ad2694315d846e69893399" title="The height of the font, built from font_ascent + font_descent.">height</a> <span class="comment">/* Y = baseline of font */</span>, (xcb_char2b_t*)client-><a class="code" href="a00007.html#a14c9eb7f57edfd939ed2fada25e83916" title="Name (= window title).">name</a>); <a name="l00199"></a>00199 } <a name="l00200"></a>00200 } <a name="l00201"></a>00201 <a name="l00202"></a>00202 <span class="comment">/*</span> <a name="l00203"></a>00203 <span class="comment"> * Pushes the client’s x and y coordinates to X11</span> <a name="l00204"></a>00204 <span class="comment"> *</span> <a name="l00205"></a>00205 <span class="comment"> */</span> <a name="l00206"></a><a class="code" href="a00043.html#a1d68fface3cf11ff882c23a5bfa586ab">00206</a> <span class="keywordtype">void</span> <a class="code" href="a00069.html#a1d68fface3cf11ff882c23a5bfa586ab" title="Pushes the client’s x and y coordinates to X11.">reposition_client</a>(xcb_connection_t *conn, <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client) { <a name="l00207"></a>00207 <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output; <a name="l00208"></a>00208 <a name="l00209"></a>00209 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"frame 0x%08x needs to be pushed to %dx%d\n"</span>, client-><a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>); <a name="l00210"></a>00210 <span class="comment">/* Note: We can use a pointer to client->x like an array of uint32_ts</span> <a name="l00211"></a>00211 <span class="comment"> because it is followed by client->y by definition */</span> <a name="l00212"></a>00212 xcb_configure_window(conn, client-><a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, &(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>)); <a name="l00213"></a>00213 <a name="l00214"></a>00214 <span class="keywordflow">if</span> (!<a class="code" href="a00060.html#a56065826f75013837bc8e125c8dc66c7" title="Returns true if the client is floating.">client_is_floating</a>(client)) <a name="l00215"></a>00215 <span class="keywordflow">return</span>; <a name="l00216"></a>00216 <a name="l00217"></a>00217 <span class="comment">/* If the client is floating, we need to check if we moved it to a different workspace */</span> <a name="l00218"></a>00218 output = <a class="code" href="a00073.html#abb7e75366265212195afd09ab85235f6" title="Returns the active (!) output which contains the coordinates x, y or NULL if there...">get_output_containing</a>(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> + (client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> / 2), <a name="l00219"></a>00219 client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> + (client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> / 2)); <a name="l00220"></a>00220 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a>-><a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a> == output) <a name="l00221"></a>00221 <span class="keywordflow">return</span>; <a name="l00222"></a>00222 <a name="l00223"></a>00223 <span class="keywordflow">if</span> (output == NULL) { <a name="l00224"></a>00224 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Boundary checking disabled, no output found for (%d, %d)\n"</span>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>); <a name="l00225"></a>00225 <span class="keywordflow">return</span>; <a name="l00226"></a>00226 } <a name="l00227"></a>00227 <a name="l00228"></a>00228 <span class="keywordflow">if</span> (output-><a class="code" href="a00026.html#a9bcf702b65d8f47f98eafbefff529ffe" title="Current workspace selected on this virtual screen.">current_workspace</a> == NULL) { <a name="l00229"></a>00229 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Boundary checking deferred, no current workspace on output\n"</span>); <a name="l00230"></a>00230 client-><a class="code" href="a00007.html#a873c62703ab51afe96b38df2b30ffa66">force_reconfigure</a> = <span class="keyword">true</span>; <a name="l00231"></a>00231 <span class="keywordflow">return</span>; <a name="l00232"></a>00232 } <a name="l00233"></a>00233 <a name="l00234"></a>00234 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Client is on workspace %p with output %p\n"</span>, client-><a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a>, client-><a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a>-><a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>); <a name="l00235"></a>00235 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"but output at %d, %d is %p\n"</span>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>, output); <a name="l00236"></a>00236 <a class="code" href="a00066.html#a551a7fd238fea8026df7a07b503f1bef" title="Removes the floating client from its workspace and attaches it to the new workspace...">floating_assign_to_workspace</a>(client, output-><a class="code" href="a00026.html#a9bcf702b65d8f47f98eafbefff529ffe" title="Current workspace selected on this virtual screen.">current_workspace</a>); <a name="l00237"></a>00237 <a name="l00238"></a>00238 <a class="code" href="a00077.html#a323dcf30475bb3bf165100e74d225b48" title="Sets the given client as focused by updating the data structures correctly, updating...">set_focus</a>(conn, client, <span class="keyword">true</span>); <a name="l00239"></a>00239 } <a name="l00240"></a>00240 <a name="l00241"></a>00241 <span class="comment">/*</span> <a name="l00242"></a>00242 <span class="comment"> * Pushes the client’s width/height to X11 and resizes the child window. This</span> <a name="l00243"></a>00243 <span class="comment"> * function also updates the client’s position, so if you work on tiling clients</span> <a name="l00244"></a>00244 <span class="comment"> * only, you can use this function instead of separate calls to reposition_client</span> <a name="l00245"></a>00245 <span class="comment"> * and resize_client to reduce flickering.</span> <a name="l00246"></a>00246 <span class="comment"> *</span> <a name="l00247"></a>00247 <span class="comment"> */</span> <a name="l00248"></a><a class="code" href="a00043.html#a83463931ef26f7c3261dc1b804282299">00248</a> <span class="keywordtype">void</span> <a class="code" href="a00069.html#a83463931ef26f7c3261dc1b804282299" title="Pushes the client’s width/height to X11 and resizes the child window.">resize_client</a>(xcb_connection_t *conn, <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client) { <a name="l00249"></a>00249 <a class="code" href="a00015.html" title="Data structure for cached font information:font id in X11 (load it once)font height...">i3Font</a> *font = <a class="code" href="a00054.html#a50c1fc0de5343536d542c8349ab7ab0d" title="Loads a font for usage, getting its height.">load_font</a>(conn, <a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#aff568f0d5ca7a51971f4c3006a842019">font</a>); <a name="l00250"></a>00250 <a name="l00251"></a>00251 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"frame 0x%08x needs to be pushed to %dx%d\n"</span>, client-><a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>); <a name="l00252"></a>00252 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"resizing client 0x%08x to %d x %d\n"</span>, client-><a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>); <a name="l00253"></a>00253 <a class="code" href="a00079.html#a7bbb53cdd77036e67c997f0c93e67cef" title="Configures the given window to have the size/position specified by given rect.">xcb_set_window_rect</a>(conn, client-><a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>); <a name="l00254"></a>00254 <a name="l00255"></a>00255 <span class="comment">/* Adjust the position of the child inside its frame.</span> <a name="l00256"></a>00256 <span class="comment"> * The coordinates of the child are relative to its frame, we</span> <a name="l00257"></a>00257 <span class="comment"> * add a border of 2 pixel to each value */</span> <a name="l00258"></a>00258 <a class="code" href="a00020.html" title="Stores a rectangle, for example the size of a window, the child window etc.">Rect</a> *rect = &(client-><a class="code" href="a00007.html#a694f6f127e048521451f931174a6e140" title="x, y, width, height of the child (relative to its frame)">child_rect</a>); <a name="l00259"></a>00259 <span class="keywordflow">switch</span> (<a class="code" href="a00063.html#a613f019bb3d6960b1ff386eca5316158" title="Returns the mode of the given container (or MODE_DEFAULT if a NULL pointer was passed...">container_mode</a>(client-><a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>, <span class="keyword">true</span>)) { <a name="l00260"></a>00260 <span class="keywordflow">case</span> MODE_STACK: <a name="l00261"></a>00261 <span class="keywordflow">case</span> MODE_TABBED: <a name="l00262"></a>00262 rect-><a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> = 2; <a name="l00263"></a>00263 rect-><a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> = 0; <a name="l00264"></a>00264 rect-><a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> = client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> - (2 + 2); <a name="l00265"></a>00265 rect-><a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> = client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> - 2; <a name="l00266"></a>00266 <span class="keywordflow">break</span>; <a name="l00267"></a>00267 <span class="keywordflow">default</span>: <a name="l00268"></a>00268 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a990cfbc44d87127fd05d8f6a5293d2fd" title="Ensure TITLEBAR_TOP maps to 0 because we use calloc for initialization later.">titlebar_position</a> == TITLEBAR_OFF && client-><a class="code" href="a00007.html#a5a1078f3b194418aa54c1837ff82351c" title="Contains a bool specifying whether this window should not be drawn with the usual...">borderless</a>) { <a name="l00269"></a>00269 rect-><a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> = 0; <a name="l00270"></a>00270 rect-><a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> = 0; <a name="l00271"></a>00271 rect-><a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> = client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>; <a name="l00272"></a>00272 rect-><a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> = client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>; <a name="l00273"></a>00273 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a990cfbc44d87127fd05d8f6a5293d2fd" title="Ensure TITLEBAR_TOP maps to 0 because we use calloc for initialization later.">titlebar_position</a> == TITLEBAR_OFF && !client-><a class="code" href="a00007.html#a5a1078f3b194418aa54c1837ff82351c" title="Contains a bool specifying whether this window should not be drawn with the usual...">borderless</a>) { <a name="l00274"></a>00274 rect-><a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> = 1; <a name="l00275"></a>00275 rect-><a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> = 1; <a name="l00276"></a>00276 rect-><a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> = client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> - 1 - 1; <a name="l00277"></a>00277 rect-><a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> = client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> - 1 - 1; <a name="l00278"></a>00278 } <span class="keywordflow">else</span> { <a name="l00279"></a>00279 rect-><a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> = 2; <a name="l00280"></a>00280 rect-><a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> = font-><a class="code" href="a00015.html#a89ceb86bb4ad2694315d846e69893399" title="The height of the font, built from font_ascent + font_descent.">height</a> + 2 + 2; <a name="l00281"></a>00281 rect-><a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> = client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> - (2 + 2); <a name="l00282"></a>00282 rect-><a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> = client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> - ((font-><a class="code" href="a00015.html#a89ceb86bb4ad2694315d846e69893399" title="The height of the font, built from font_ascent + font_descent.">height</a> + 2 + 2) + 2); <a name="l00283"></a>00283 } <a name="l00284"></a>00284 <span class="keywordflow">break</span>; <a name="l00285"></a>00285 } <a name="l00286"></a>00286 <a name="l00287"></a>00287 rect-><a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> -= (2 * client-><a class="code" href="a00007.html#afa6b690b03609a16c555a22f976a364c" title="The amount of pixels which X will draw around the client.">border_width</a>); <a name="l00288"></a>00288 rect-><a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> -= (2 * client-><a class="code" href="a00007.html#afa6b690b03609a16c555a22f976a364c" title="The amount of pixels which X will draw around the client.">border_width</a>); <a name="l00289"></a>00289 <a name="l00290"></a>00290 <span class="comment">/* Obey the ratio, if any */</span> <a name="l00291"></a>00291 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a4d2a7cf214d7d756d1e87fa99d284741" title="contains the size calculated from the hints set by the window or 0 if the client...">proportional_height</a> != 0 && <a name="l00292"></a>00292 client-><a class="code" href="a00007.html#a2324d36fb1ad3c0d9cae70f975cd3fe4">proportional_width</a> != 0) { <a name="l00293"></a>00293 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"proportional height = %d, width = %d\n"</span>, client-><a class="code" href="a00007.html#a4d2a7cf214d7d756d1e87fa99d284741" title="contains the size calculated from the hints set by the window or 0 if the client...">proportional_height</a>, client-><a class="code" href="a00007.html#a2324d36fb1ad3c0d9cae70f975cd3fe4">proportional_width</a>); <a name="l00294"></a>00294 <span class="keywordtype">double</span> new_height = rect-><a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> + 1; <a name="l00295"></a>00295 <span class="keywordtype">int</span> new_width = rect-><a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>; <a name="l00296"></a>00296 <a name="l00297"></a>00297 <span class="keywordflow">while</span> (new_height > rect-><a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>) { <a name="l00298"></a>00298 new_height = ((double)client-><a class="code" href="a00007.html#a4d2a7cf214d7d756d1e87fa99d284741" title="contains the size calculated from the hints set by the window or 0 if the client...">proportional_height</a> / client-><a class="code" href="a00007.html#a2324d36fb1ad3c0d9cae70f975cd3fe4">proportional_width</a>) * new_width; <a name="l00299"></a>00299 <a name="l00300"></a>00300 <span class="keywordflow">if</span> (new_height > rect-><a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>) <a name="l00301"></a>00301 new_width--; <a name="l00302"></a>00302 } <a name="l00303"></a>00303 <span class="comment">/* Center the window */</span> <a name="l00304"></a>00304 rect-><a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> += ceil(rect-><a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> / 2) - floor(new_height / 2); <a name="l00305"></a>00305 rect-><a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> += ceil(rect-><a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> / 2) - floor(new_width / 2); <a name="l00306"></a>00306 <a name="l00307"></a>00307 rect-><a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> = new_height; <a name="l00308"></a>00308 rect-><a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> = new_width; <a name="l00309"></a>00309 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"new_height = %f, new_width = %d\n"</span>, new_height, new_width); <a name="l00310"></a>00310 } <a name="l00311"></a>00311 <a name="l00312"></a>00312 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#aec47a7c174216266483e8a6a9e51d2f7">height_increment</a> > 1) { <a name="l00313"></a>00313 <span class="keywordtype">int</span> old_height = rect-><a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>; <a name="l00314"></a>00314 rect-><a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> -= (rect-><a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> - client-><a class="code" href="a00007.html#a92916a2b042c07b01eb6e3a4269413cc">base_height</a>) % client-><a class="code" href="a00007.html#aec47a7c174216266483e8a6a9e51d2f7">height_increment</a>; <a name="l00315"></a>00315 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Lost %d pixel due to client's height_increment (%d px, base_height = %d)\n"</span>, <a name="l00316"></a>00316 old_height - rect-><a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>, client-><a class="code" href="a00007.html#aec47a7c174216266483e8a6a9e51d2f7">height_increment</a>, client-><a class="code" href="a00007.html#a92916a2b042c07b01eb6e3a4269413cc">base_height</a>); <a name="l00317"></a>00317 } <a name="l00318"></a>00318 <a name="l00319"></a>00319 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a80130d5f48f9c1db1e9206b578873002" title="contains the minimum increment size as specified for the window (in pixels).">width_increment</a> > 1) { <a name="l00320"></a>00320 <span class="keywordtype">int</span> old_width = rect-><a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>; <a name="l00321"></a>00321 rect-><a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> -= (rect-><a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> - client-><a class="code" href="a00007.html#a51ffa9095f0fba59737c1252cf0031cb">base_width</a>) % client-><a class="code" href="a00007.html#a80130d5f48f9c1db1e9206b578873002" title="contains the minimum increment size as specified for the window (in pixels).">width_increment</a>; <a name="l00322"></a>00322 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Lost %d pixel due to client's width_increment (%d px, base_width = %d)\n"</span>, <a name="l00323"></a>00323 old_width - rect-><a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, client-><a class="code" href="a00007.html#a80130d5f48f9c1db1e9206b578873002" title="contains the minimum increment size as specified for the window (in pixels).">width_increment</a>, client-><a class="code" href="a00007.html#a51ffa9095f0fba59737c1252cf0031cb">base_width</a>); <a name="l00324"></a>00324 } <a name="l00325"></a>00325 <a name="l00326"></a>00326 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"child will be at %dx%d with size %dx%d\n"</span>, rect-><a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, rect-><a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>, rect-><a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, rect-><a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>); <a name="l00327"></a>00327 <a name="l00328"></a>00328 <a class="code" href="a00079.html#a7bbb53cdd77036e67c997f0c93e67cef" title="Configures the given window to have the size/position specified by given rect.">xcb_set_window_rect</a>(conn, client-><a class="code" href="a00007.html#afba312b946fa74727ce619a33f8f28aa" title="The client’s window.">child</a>, *rect); <a name="l00329"></a>00329 <a name="l00330"></a>00330 <span class="comment">/* After configuring a child window we need to fake a configure_notify_event (see ICCCM 4.2.3).</span> <a name="l00331"></a>00331 <span class="comment"> * This is necessary to inform the client of its position relative to the root window,</span> <a name="l00332"></a>00332 <span class="comment"> * not relative to its frame (as done in the configure_notify_event by the x server). */</span> <a name="l00333"></a>00333 <a class="code" href="a00079.html#a66ff853f6bedca4b4c142f3b7561b189" title="Generates a configure_notify_event with absolute coordinates (relative to the X root...">fake_absolute_configure_notify</a>(conn, client); <a name="l00334"></a>00334 <a name="l00335"></a>00335 <span class="comment">/* Force redrawing after resizing the window because any now lost</span> <a name="l00336"></a>00336 <span class="comment"> * pixels could contain old garbage. */</span> <a name="l00337"></a>00337 xcb_expose_event_t generated; <a name="l00338"></a>00338 generated.window = client-><a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>; <a name="l00339"></a>00339 generated.count = 0; <a name="l00340"></a>00340 <a class="code" href="a00067.html#aef74cebc820b8224d196fa6eb9c13ac4" title="Expose event means we should redraw our windows (= title bar).">handle_expose_event</a>(NULL, conn, &generated); <a name="l00341"></a>00341 } <a name="l00342"></a>00342 <a name="l00343"></a>00343 <span class="comment">/*</span> <a name="l00344"></a>00344 <span class="comment"> * Renders the given container. Is called by render_layout() or individually (for example</span> <a name="l00345"></a>00345 <span class="comment"> * when focus changes in a stacking container)</span> <a name="l00346"></a>00346 <span class="comment"> *</span> <a name="l00347"></a>00347 <span class="comment"> */</span> <a name="l00348"></a><a class="code" href="a00043.html#a2a1fee0aebdaf2497fb52ea57a1033a4">00348</a> <span class="keywordtype">void</span> <a class="code" href="a00069.html#a2a1fee0aebdaf2497fb52ea57a1033a4" title="Renders the given container.">render_container</a>(xcb_connection_t *conn, <a class="code" href="a00013.html" title="A container is either in default, stacking or tabbed mode.">Container</a> *container) { <a name="l00349"></a>00349 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client; <a name="l00350"></a>00350 <span class="keywordtype">int</span> num_clients = 0, current_client = 0; <a name="l00351"></a>00351 <a name="l00352"></a>00352 <a class="code" href="a00047.html#ae97f4eb5724477c63699fafea4614b46">CIRCLEQ_FOREACH</a>(client, &(container->clients), clients) <a name="l00353"></a>00353 num_clients++; <a name="l00354"></a>00354 <a name="l00355"></a>00355 <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#ac094306ab77e360742aba04d7cbd0fe6">mode</a> == MODE_DEFAULT) { <a name="l00356"></a>00356 <span class="keywordtype">int</span> height = (container-><a class="code" href="a00013.html#a62e576209b30aeaf8c2fd0121b4f705c">height</a> / <a class="code" href="a00077.html#af082905f7eac6d03e92015146bbc1925">max</a>(1, num_clients)); <a name="l00357"></a>00357 <span class="keywordtype">int</span> rest_pixels = (container-><a class="code" href="a00013.html#a62e576209b30aeaf8c2fd0121b4f705c">height</a> % <a class="code" href="a00077.html#af082905f7eac6d03e92015146bbc1925">max</a>(1, num_clients)); <a name="l00358"></a>00358 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"height per client = %d, rest = %d\n"</span>, height, rest_pixels); <a name="l00359"></a>00359 <a name="l00360"></a>00360 <a class="code" href="a00047.html#ae97f4eb5724477c63699fafea4614b46">CIRCLEQ_FOREACH</a>(client, &(container->clients), clients) { <a name="l00361"></a>00361 <span class="comment">/* If the client is in fullscreen mode, it does not get reconfigured */</span> <a name="l00362"></a>00362 <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#a98ed501e1088ccf2e7c75399ab7e6031">workspace</a>-><a class="code" href="a00025.html#a918ace3a3d2f03c58ec8fa05ac97275e" title="the client who is started in fullscreen mode on this workspace, NULL if there is...">fullscreen_client</a> == client) { <a name="l00363"></a>00363 current_client++; <a name="l00364"></a>00364 <span class="keywordflow">continue</span>; <a name="l00365"></a>00365 } <a name="l00366"></a>00366 <a name="l00367"></a>00367 <span class="comment">/* If we have some pixels left to distribute, add one</span> <a name="l00368"></a>00368 <span class="comment"> * pixel to each client as long as possible. */</span> <a name="l00369"></a>00369 <span class="keywordtype">int</span> this_height = height; <a name="l00370"></a>00370 <span class="keywordflow">if</span> (rest_pixels > 0) { <a name="l00371"></a>00371 height++; <a name="l00372"></a>00372 rest_pixels--; <a name="l00373"></a>00373 } <a name="l00374"></a>00374 <span class="comment">/* Check if we changed client->x or client->y by updating it.</span> <a name="l00375"></a>00375 <span class="comment"> * Note the bitwise OR instead of logical OR to force evaluation of both statements */</span> <a name="l00376"></a>00376 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a873c62703ab51afe96b38df2b30ffa66">force_reconfigure</a> | <a name="l00377"></a>00377 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>), container-><a class="code" href="a00013.html#a4829135d344139fb1c9e25ae5cdf5747">x</a>) | <a name="l00378"></a>00378 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>), container-><a class="code" href="a00013.html#a31cfaffc96b7c938a239bd40c1488230">y</a> + <a name="l00379"></a>00379 (container-><a class="code" href="a00013.html#a62e576209b30aeaf8c2fd0121b4f705c">height</a> / num_clients) * current_client) | <a name="l00380"></a>00380 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>), container-><a class="code" href="a00013.html#af9b566fc3a8a208897503254747ae720">width</a>) | <a name="l00381"></a>00381 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>), this_height)) <a name="l00382"></a>00382 <a class="code" href="a00069.html#a83463931ef26f7c3261dc1b804282299" title="Pushes the client’s width/height to X11 and resizes the child window.">resize_client</a>(conn, client); <a name="l00383"></a>00383 <a name="l00384"></a>00384 <span class="comment">/* TODO: vertical default layout */</span> <a name="l00385"></a>00385 <a name="l00386"></a>00386 client-><a class="code" href="a00007.html#a873c62703ab51afe96b38df2b30ffa66">force_reconfigure</a> = <span class="keyword">false</span>; <a name="l00387"></a>00387 <a name="l00388"></a>00388 current_client++; <a name="l00389"></a>00389 } <a name="l00390"></a>00390 } <span class="keywordflow">else</span> { <a name="l00391"></a>00391 <a class="code" href="a00015.html" title="Data structure for cached font information:font id in X11 (load it once)font height...">i3Font</a> *font = <a class="code" href="a00054.html#a50c1fc0de5343536d542c8349ab7ab0d" title="Loads a font for usage, getting its height.">load_font</a>(conn, <a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#aff568f0d5ca7a51971f4c3006a842019">font</a>); <a name="l00392"></a>00392 <span class="keywordtype">int</span> decoration_height = (font-><a class="code" href="a00015.html#a89ceb86bb4ad2694315d846e69893399" title="The height of the font, built from font_ascent + font_descent.">height</a> + 2 + 2); <a name="l00393"></a>00393 <span class="keyword">struct </span><a class="code" href="a00023.html" title="Contains data for the windows needed to draw the titlebars on in stacking mode.">Stack_Window</a> *stack_win = &(container-><a class="code" href="a00013.html#ad3c94b066b8ddd9a56f33e8bd9f200b2">stack_win</a>); <a name="l00394"></a>00394 <span class="comment">/* The size for each tab (width), necessary as a separate variable</span> <a name="l00395"></a>00395 <span class="comment"> * because num_clients gets fixed to 1 in tabbed mode. */</span> <a name="l00396"></a>00396 <span class="keywordtype">int</span> size_each = (num_clients == 0 ? container-><a class="code" href="a00013.html#af9b566fc3a8a208897503254747ae720">width</a> : container-><a class="code" href="a00013.html#af9b566fc3a8a208897503254747ae720">width</a> / num_clients); <a name="l00397"></a>00397 <span class="keywordtype">int</span> stack_lines = num_clients; <a name="l00398"></a>00398 <a name="l00399"></a>00399 <span class="comment">/* Check if we need to remap our stack title window, it gets unmapped when the container</span> <a name="l00400"></a>00400 <span class="comment"> is empty in src/handlers.c:unmap_notify() */</span> <a name="l00401"></a>00401 <span class="keywordflow">if</span> (stack_win-><a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> == 0 && num_clients > 1) { <a name="l00402"></a>00402 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"remapping stack win\n"</span>); <a name="l00403"></a>00403 xcb_map_window(conn, stack_win-><a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a>); <a name="l00404"></a>00404 } <span class="keywordflow">else</span> <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"not remapping stackwin, height = %d, num_clients = %d\n"</span>, <a name="l00405"></a>00405 stack_win-><a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>, num_clients); <a name="l00406"></a>00406 <a name="l00407"></a>00407 <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#ac094306ab77e360742aba04d7cbd0fe6">mode</a> == MODE_TABBED) { <a name="l00408"></a>00408 <span class="comment">/* By setting num_clients to 1 we force that the stack window will be only one line</span> <a name="l00409"></a>00409 <span class="comment"> * high. The rest of the code is useful in both cases. */</span> <a name="l00410"></a>00410 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"tabbed mode, setting num_clients = 1\n"</span>); <a name="l00411"></a>00411 <span class="keywordflow">if</span> (stack_lines > 1) <a name="l00412"></a>00412 stack_lines = 1; <a name="l00413"></a>00413 } <a name="l00414"></a>00414 <a name="l00415"></a>00415 <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#a8d99003f0507fe6554189568f84505be">stack_limit</a> == STACK_LIMIT_COLS) { <a name="l00416"></a>00416 stack_lines = ceil((<span class="keywordtype">float</span>)num_clients / container-><a class="code" href="a00013.html#ad0e9b50a01da48b57f9ecbe97bc00582">stack_limit_value</a>); <a name="l00417"></a>00417 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#a8d99003f0507fe6554189568f84505be">stack_limit</a> == STACK_LIMIT_ROWS) { <a name="l00418"></a>00418 stack_lines = <a class="code" href="a00077.html#abd8bbcfabb3ddef2ccaafb9928a37b95">min</a>(num_clients, container-><a class="code" href="a00013.html#ad0e9b50a01da48b57f9ecbe97bc00582">stack_limit_value</a>); <a name="l00419"></a>00419 } <a name="l00420"></a>00420 <a name="l00421"></a>00421 <span class="keywordtype">int</span> height = decoration_height * stack_lines; <a name="l00422"></a>00422 <span class="keywordflow">if</span> (num_clients == 1) { <a name="l00423"></a>00423 height = 0; <a name="l00424"></a>00424 stack_win-><a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> = 0; <a name="l00425"></a>00425 xcb_unmap_window(conn, stack_win-><a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a>); <a name="l00426"></a>00426 <a name="l00427"></a>00427 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Just one client, setting height to %d\n"</span>, height); <a name="l00428"></a>00428 } <a name="l00429"></a>00429 <a name="l00430"></a>00430 <span class="comment">/* Check if we need to reconfigure our stack title window */</span> <a name="l00431"></a>00431 <span class="keywordflow">if</span> (height > 0 && ( <a name="l00432"></a>00432 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(stack_win-><a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>), container-><a class="code" href="a00013.html#a4829135d344139fb1c9e25ae5cdf5747">x</a>) | <a name="l00433"></a>00433 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(stack_win-><a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>), container-><a class="code" href="a00013.html#a31cfaffc96b7c938a239bd40c1488230">y</a>) | <a name="l00434"></a>00434 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(stack_win-><a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>), container-><a class="code" href="a00013.html#af9b566fc3a8a208897503254747ae720">width</a>) | <a name="l00435"></a>00435 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(stack_win-><a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>), height))) { <a name="l00436"></a>00436 <a name="l00437"></a>00437 <span class="comment">/* Configuration can happen in two slightly different ways:</span> <a name="l00438"></a>00438 <span class="comment"></span> <a name="l00439"></a>00439 <span class="comment"> If there is no client in fullscreen mode, 5 parameters are passed</span> <a name="l00440"></a>00440 <span class="comment"> (x, y, width, height, stack mode is set to above which means top-most position).</span> <a name="l00441"></a>00441 <span class="comment"></span> <a name="l00442"></a>00442 <span class="comment"> If there is a fullscreen client, the fourth parameter is set to to the</span> <a name="l00443"></a>00443 <span class="comment"> fullscreen window as sibling and the stack mode is set to below, which means</span> <a name="l00444"></a>00444 <span class="comment"> that the stack_window will be placed just below the sibling, that is, under</span> <a name="l00445"></a>00445 <span class="comment"> the fullscreen window.</span> <a name="l00446"></a>00446 <span class="comment"> */</span> <a name="l00447"></a>00447 uint32_t values[] = { stack_win-><a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, stack_win-><a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>, <a name="l00448"></a>00448 stack_win-><a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, stack_win-><a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>, <a name="l00449"></a>00449 XCB_STACK_MODE_ABOVE, XCB_STACK_MODE_BELOW }; <a name="l00450"></a>00450 uint32_t mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | <a name="l00451"></a>00451 XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | <a name="l00452"></a>00452 XCB_CONFIG_WINDOW_STACK_MODE; <a name="l00453"></a>00453 <a name="l00454"></a>00454 <span class="comment">/* Raise the stack window, but keep it below the first floating client</span> <a name="l00455"></a>00455 <span class="comment"> * and below the fullscreen client (if any) */</span> <a name="l00456"></a>00456 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *first_floating = <a class="code" href="a00047.html#a7d6894360bd1c41e0e6f6d84998c1362">TAILQ_FIRST</a>(&(container-><a class="code" href="a00013.html#a98ed501e1088ccf2e7c75399ab7e6031">workspace</a>->floating_clients)); <a name="l00457"></a>00457 <span class="keywordflow">if</span> (first_floating != <a class="code" href="a00047.html#a4322b8461a6ab7632435ff4f57bb3a2e">TAILQ_END</a>(&(container-><a class="code" href="a00013.html#a98ed501e1088ccf2e7c75399ab7e6031">workspace</a>->floating_clients))) { <a name="l00458"></a>00458 mask |= XCB_CONFIG_WINDOW_SIBLING; <a name="l00459"></a>00459 values[4] = first_floating-><a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>; <a name="l00460"></a>00460 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#a98ed501e1088ccf2e7c75399ab7e6031">workspace</a>-><a class="code" href="a00025.html#a918ace3a3d2f03c58ec8fa05ac97275e" title="the client who is started in fullscreen mode on this workspace, NULL if there is...">fullscreen_client</a> != NULL) { <a name="l00461"></a>00461 mask |= XCB_CONFIG_WINDOW_SIBLING; <a name="l00462"></a>00462 values[4] = container-><a class="code" href="a00013.html#a98ed501e1088ccf2e7c75399ab7e6031">workspace</a>-><a class="code" href="a00025.html#a918ace3a3d2f03c58ec8fa05ac97275e" title="the client who is started in fullscreen mode on this workspace, NULL if there is...">fullscreen_client</a>-><a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>; <a name="l00463"></a>00463 } <a name="l00464"></a>00464 <a name="l00465"></a>00465 xcb_configure_window(conn, stack_win-><a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a>, mask, values); <a name="l00466"></a>00466 } <a name="l00467"></a>00467 <a name="l00468"></a>00468 <span class="comment">/* Prepare the pixmap for usage */</span> <a name="l00469"></a>00469 <span class="keywordflow">if</span> (num_clients > 1) <a name="l00470"></a>00470 <a class="code" href="a00079.html#a22762f8bf69c7dcfdafac47e5e39695a" title="Prepares the given Cached_Pixmap for usage (checks whether the size of the object...">cached_pixmap_prepare</a>(conn, &(stack_win-><a class="code" href="a00023.html#aaa74ae431448b315a0a89cc8cb4e83fc">pixmap</a>)); <a name="l00471"></a>00471 <a name="l00472"></a>00472 <span class="keywordtype">int</span> <a class="code" href="a00076.html#a40ba377d6a3a574ff03b859bc7cdd4b0">current_row</a> = 0, <a class="code" href="a00076.html#a5f839b3ac61c0771c9f8fbef974afe76">current_col</a> = 0; <a name="l00473"></a>00473 <span class="keywordtype">int</span> wrap = 0; <a name="l00474"></a>00474 <a name="l00475"></a>00475 <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#a8d99003f0507fe6554189568f84505be">stack_limit</a> == STACK_LIMIT_COLS) { <a name="l00476"></a>00476 <span class="comment">/* wrap stores the number of rows after which we will</span> <a name="l00477"></a>00477 <span class="comment"> * wrap to a new column. */</span> <a name="l00478"></a>00478 wrap = ceil((<span class="keywordtype">float</span>)num_clients / container-><a class="code" href="a00013.html#ad0e9b50a01da48b57f9ecbe97bc00582">stack_limit_value</a>); <a name="l00479"></a>00479 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#a8d99003f0507fe6554189568f84505be">stack_limit</a> == STACK_LIMIT_ROWS) { <a name="l00480"></a>00480 <span class="comment">/* When limiting rows, the wrap variable serves a</span> <a name="l00481"></a>00481 <span class="comment"> * slightly different purpose: it holds the number of</span> <a name="l00482"></a>00482 <span class="comment"> * pixels which each client will get. This is constant</span> <a name="l00483"></a>00483 <span class="comment"> * during the following loop, so it saves us some</span> <a name="l00484"></a>00484 <span class="comment"> * divisions and ceil()ing. */</span> <a name="l00485"></a>00485 wrap = (stack_win-><a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> / ceil((<span class="keywordtype">float</span>)num_clients / container-><a class="code" href="a00013.html#ad0e9b50a01da48b57f9ecbe97bc00582">stack_limit_value</a>)); <a name="l00486"></a>00486 } <a name="l00487"></a>00487 <a name="l00488"></a>00488 <span class="comment">/* Render the decorations of all clients */</span> <a name="l00489"></a>00489 <a class="code" href="a00047.html#ae97f4eb5724477c63699fafea4614b46">CIRCLEQ_FOREACH</a>(client, &(container->clients), clients) { <a name="l00490"></a>00490 <span class="comment">/* If the client is in fullscreen mode, it does not get reconfigured */</span> <a name="l00491"></a>00491 <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#a98ed501e1088ccf2e7c75399ab7e6031">workspace</a>-><a class="code" href="a00025.html#a918ace3a3d2f03c58ec8fa05ac97275e" title="the client who is started in fullscreen mode on this workspace, NULL if there is...">fullscreen_client</a> == client) { <a name="l00492"></a>00492 current_client++; <a name="l00493"></a>00493 <span class="keywordflow">continue</span>; <a name="l00494"></a>00494 } <a name="l00495"></a>00495 <a name="l00496"></a>00496 <span class="comment">/* Check if we changed client->x or client->y by updating it.</span> <a name="l00497"></a>00497 <span class="comment"> * Note the bitwise OR instead of logical OR to force evaluation of all statements */</span> <a name="l00498"></a>00498 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a873c62703ab51afe96b38df2b30ffa66">force_reconfigure</a> | <a name="l00499"></a>00499 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>), container-><a class="code" href="a00013.html#a4829135d344139fb1c9e25ae5cdf5747">x</a>) | <a name="l00500"></a>00500 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>), container-><a class="code" href="a00013.html#a31cfaffc96b7c938a239bd40c1488230">y</a> + height) | <a name="l00501"></a>00501 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>), container-><a class="code" href="a00013.html#af9b566fc3a8a208897503254747ae720">width</a>) | <a name="l00502"></a>00502 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>), container-><a class="code" href="a00013.html#a62e576209b30aeaf8c2fd0121b4f705c">height</a> - height)) <a name="l00503"></a>00503 <a class="code" href="a00069.html#a83463931ef26f7c3261dc1b804282299" title="Pushes the client’s width/height to X11 and resizes the child window.">resize_client</a>(conn, client); <a name="l00504"></a>00504 <a name="l00505"></a>00505 client-><a class="code" href="a00007.html#a873c62703ab51afe96b38df2b30ffa66">force_reconfigure</a> = <span class="keyword">false</span>; <a name="l00506"></a>00506 <a name="l00507"></a>00507 <span class="keywordtype">int</span> offset_x = 0; <a name="l00508"></a>00508 <span class="keywordtype">int</span> offset_y = 0; <a name="l00509"></a>00509 <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#ac094306ab77e360742aba04d7cbd0fe6">mode</a> == MODE_STACK || <a name="l00510"></a>00510 (container-><a class="code" href="a00013.html#ac094306ab77e360742aba04d7cbd0fe6">mode</a> == MODE_TABBED && <a name="l00511"></a>00511 container-><a class="code" href="a00013.html#a8d99003f0507fe6554189568f84505be">stack_limit</a> == STACK_LIMIT_COLS)) { <a name="l00512"></a>00512 <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#a8d99003f0507fe6554189568f84505be">stack_limit</a> == STACK_LIMIT_COLS) { <a name="l00513"></a>00513 offset_x = <a class="code" href="a00076.html#a5f839b3ac61c0771c9f8fbef974afe76">current_col</a> * (stack_win-><a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> / container-><a class="code" href="a00013.html#ad0e9b50a01da48b57f9ecbe97bc00582">stack_limit_value</a>); <a name="l00514"></a>00514 offset_y = current_row * decoration_height; <a name="l00515"></a>00515 current_row++; <a name="l00516"></a>00516 <span class="keywordflow">if</span> ((current_row % wrap) == 0) { <a name="l00517"></a>00517 <a class="code" href="a00076.html#a5f839b3ac61c0771c9f8fbef974afe76">current_col</a>++; <a name="l00518"></a>00518 current_row = 0; <a name="l00519"></a>00519 } <a name="l00520"></a>00520 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#a8d99003f0507fe6554189568f84505be">stack_limit</a> == STACK_LIMIT_ROWS) { <a name="l00521"></a>00521 offset_x = <a class="code" href="a00076.html#a5f839b3ac61c0771c9f8fbef974afe76">current_col</a> * wrap; <a name="l00522"></a>00522 offset_y = current_row * decoration_height; <a name="l00523"></a>00523 current_row++; <a name="l00524"></a>00524 <span class="keywordflow">if</span> ((current_row % container-><a class="code" href="a00013.html#ad0e9b50a01da48b57f9ecbe97bc00582">stack_limit_value</a>) == 0) { <a name="l00525"></a>00525 <a class="code" href="a00076.html#a5f839b3ac61c0771c9f8fbef974afe76">current_col</a>++; <a name="l00526"></a>00526 current_row = 0; <a name="l00527"></a>00527 } <a name="l00528"></a>00528 } <span class="keywordflow">else</span> { <a name="l00529"></a>00529 offset_y = current_client * decoration_height; <a name="l00530"></a>00530 } <a name="l00531"></a>00531 current_client++; <a name="l00532"></a>00532 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#ac094306ab77e360742aba04d7cbd0fe6">mode</a> == MODE_TABBED) { <a name="l00533"></a>00533 <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#a8d99003f0507fe6554189568f84505be">stack_limit</a> == STACK_LIMIT_ROWS) { <a name="l00534"></a>00534 <a class="code" href="a00044.html#a388edf12256bf73c3a8ee9734c3bd841" title="#__VA_ARGS__ means: leave out __VA_ARGS__ completely if it is empty, that is, delete...">LOG</a>(<span class="stringliteral">"You limited a tabbed container in its rows. "</span> <a name="l00535"></a>00535 <span class="stringliteral">"This makes no sense in tabbing mode.\n"</span>); <a name="l00536"></a>00536 } <a name="l00537"></a>00537 offset_x = current_client++ * size_each; <a name="l00538"></a>00538 } <a name="l00539"></a>00539 <span class="keywordflow">if</span> (stack_win-><a class="code" href="a00023.html#aaa74ae431448b315a0a89cc8cb4e83fc">pixmap</a>.<a class="code" href="a00004.html#a75c370b918b9f963d6430ba07e7c56bf">id</a> == XCB_NONE) <a name="l00540"></a>00540 <span class="keywordflow">continue</span>; <a name="l00541"></a>00541 <a class="code" href="a00069.html#a1ea737657e6613d21ad663bb45c82dd2" title="(Re-)draws window decorations for a given Client onto the given drawable/graphic...">decorate_window</a>(conn, client, stack_win-><a class="code" href="a00023.html#aaa74ae431448b315a0a89cc8cb4e83fc">pixmap</a>.<a class="code" href="a00004.html#a75c370b918b9f963d6430ba07e7c56bf">id</a>, <a name="l00542"></a>00542 stack_win-><a class="code" href="a00023.html#aaa74ae431448b315a0a89cc8cb4e83fc">pixmap</a>.<a class="code" href="a00004.html#a1930bbf9d5570906ace6d8aaeea0cbf1">gc</a>, offset_x, offset_y); <a name="l00543"></a>00543 } <a name="l00544"></a>00544 <a name="l00545"></a>00545 <span class="comment">/* Check if we need to fill one column because of an uneven</span> <a name="l00546"></a>00546 <span class="comment"> * amount of windows */</span> <a name="l00547"></a>00547 <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#ac094306ab77e360742aba04d7cbd0fe6">mode</a> == MODE_STACK) { <a name="l00548"></a>00548 <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#a8d99003f0507fe6554189568f84505be">stack_limit</a> == STACK_LIMIT_COLS && (<a class="code" href="a00076.html#a5f839b3ac61c0771c9f8fbef974afe76">current_col</a> % 2) != 0) { <a name="l00549"></a>00549 <a class="code" href="a00079.html#ac20ce6b9cf46f63675e363ac5dc2f24e" title="Changes a single value in the graphic context (so one doesn’t have to define an...">xcb_change_gc_single</a>(conn, stack_win-><a class="code" href="a00023.html#aaa74ae431448b315a0a89cc8cb4e83fc">pixmap</a>.<a class="code" href="a00004.html#a1930bbf9d5570906ace6d8aaeea0cbf1">gc</a>, XCB_GC_FOREGROUND, <a class="code" href="a00079.html#a0146fe310e31c9509a7a7846aa547c67" title="Returns the colorpixel to use for the given hex color (think of HTML).">get_colorpixel</a>(conn, <span class="stringliteral">"#000000"</span>)); <a name="l00550"></a>00550 <a name="l00551"></a>00551 <span class="keywordtype">int</span> offset_x = <a class="code" href="a00076.html#a5f839b3ac61c0771c9f8fbef974afe76">current_col</a> * (stack_win-><a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> / container-><a class="code" href="a00013.html#ad0e9b50a01da48b57f9ecbe97bc00582">stack_limit_value</a>); <a name="l00552"></a>00552 <span class="keywordtype">int</span> offset_y = current_row * decoration_height; <a name="l00553"></a>00553 xcb_rectangle_t <a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a> = {offset_x, offset_y, <a name="l00554"></a>00554 offset_x + container-><a class="code" href="a00013.html#af9b566fc3a8a208897503254747ae720">width</a>, <a name="l00555"></a>00555 offset_y + decoration_height }; <a name="l00556"></a>00556 xcb_poly_fill_rectangle(conn, stack_win-><a class="code" href="a00023.html#aaa74ae431448b315a0a89cc8cb4e83fc">pixmap</a>.<a class="code" href="a00004.html#a75c370b918b9f963d6430ba07e7c56bf">id</a>, stack_win-><a class="code" href="a00023.html#aaa74ae431448b315a0a89cc8cb4e83fc">pixmap</a>.<a class="code" href="a00004.html#a1930bbf9d5570906ace6d8aaeea0cbf1">gc</a>, 1, &rect); <a name="l00557"></a>00557 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (container-><a class="code" href="a00013.html#a8d99003f0507fe6554189568f84505be">stack_limit</a> == STACK_LIMIT_ROWS && (current_row % 2) != 0) { <a name="l00558"></a>00558 <a class="code" href="a00079.html#ac20ce6b9cf46f63675e363ac5dc2f24e" title="Changes a single value in the graphic context (so one doesn’t have to define an...">xcb_change_gc_single</a>(conn, stack_win-><a class="code" href="a00023.html#aaa74ae431448b315a0a89cc8cb4e83fc">pixmap</a>.<a class="code" href="a00004.html#a1930bbf9d5570906ace6d8aaeea0cbf1">gc</a>, XCB_GC_FOREGROUND, <a class="code" href="a00079.html#a0146fe310e31c9509a7a7846aa547c67" title="Returns the colorpixel to use for the given hex color (think of HTML).">get_colorpixel</a>(conn, <span class="stringliteral">"#000000"</span>)); <a name="l00559"></a>00559 <a name="l00560"></a>00560 <span class="keywordtype">int</span> offset_x = <a class="code" href="a00076.html#a5f839b3ac61c0771c9f8fbef974afe76">current_col</a> * wrap; <a name="l00561"></a>00561 <span class="keywordtype">int</span> offset_y = current_row * decoration_height; <a name="l00562"></a>00562 xcb_rectangle_t <a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a> = {offset_x, offset_y, <a name="l00563"></a>00563 offset_x + container-><a class="code" href="a00013.html#af9b566fc3a8a208897503254747ae720">width</a>, <a name="l00564"></a>00564 offset_y + decoration_height }; <a name="l00565"></a>00565 xcb_poly_fill_rectangle(conn, stack_win-><a class="code" href="a00023.html#aaa74ae431448b315a0a89cc8cb4e83fc">pixmap</a>.<a class="code" href="a00004.html#a75c370b918b9f963d6430ba07e7c56bf">id</a>, stack_win-><a class="code" href="a00023.html#aaa74ae431448b315a0a89cc8cb4e83fc">pixmap</a>.<a class="code" href="a00004.html#a1930bbf9d5570906ace6d8aaeea0cbf1">gc</a>, 1, &rect); <a name="l00566"></a>00566 } <a name="l00567"></a>00567 } <a name="l00568"></a>00568 <a name="l00569"></a>00569 <span class="keywordflow">if</span> (stack_win-><a class="code" href="a00023.html#aaa74ae431448b315a0a89cc8cb4e83fc">pixmap</a>.<a class="code" href="a00004.html#a75c370b918b9f963d6430ba07e7c56bf">id</a> == XCB_NONE) <a name="l00570"></a>00570 <span class="keywordflow">return</span>; <a name="l00571"></a>00571 xcb_copy_area(conn, stack_win-><a class="code" href="a00023.html#aaa74ae431448b315a0a89cc8cb4e83fc">pixmap</a>.<a class="code" href="a00004.html#a75c370b918b9f963d6430ba07e7c56bf">id</a>, stack_win-><a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a>, stack_win-><a class="code" href="a00023.html#aaa74ae431448b315a0a89cc8cb4e83fc">pixmap</a>.<a class="code" href="a00004.html#a1930bbf9d5570906ace6d8aaeea0cbf1">gc</a>, <a name="l00572"></a>00572 0, 0, 0, 0, stack_win-><a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, stack_win-><a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>); <a name="l00573"></a>00573 } <a name="l00574"></a>00574 } <a name="l00575"></a>00575 <a name="l00576"></a><a class="code" href="a00069.html#a54f8071e93b6c95fc2834df8efd5c134">00576</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="a00069.html#a54f8071e93b6c95fc2834df8efd5c134">render_bars</a>(xcb_connection_t *conn, <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *r_ws, <span class="keywordtype">int</span> width, <span class="keywordtype">int</span> *height) { <a name="l00577"></a>00577 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client; <a name="l00578"></a>00578 <a class="code" href="a00047.html#a05db87878125c27e3060dd641aa3b0f4">SLIST_FOREACH</a>(client, &(r_ws-><a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>->dock_clients), dock_clients) { <a name="l00579"></a>00579 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"client is at %d, should be at %d\n"</span>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>, *height); <a name="l00580"></a>00580 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a873c62703ab51afe96b38df2b30ffa66">force_reconfigure</a> | <a name="l00581"></a>00581 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>), r_ws-><a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>) | <a name="l00582"></a>00582 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>), *height)) <a name="l00583"></a>00583 <a class="code" href="a00069.html#a1d68fface3cf11ff882c23a5bfa586ab" title="Pushes the client’s x and y coordinates to X11.">reposition_client</a>(conn, client); <a name="l00584"></a>00584 <a name="l00585"></a>00585 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a873c62703ab51afe96b38df2b30ffa66">force_reconfigure</a> | <a name="l00586"></a>00586 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>), width) | <a name="l00587"></a>00587 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>), client-><a class="code" href="a00007.html#a101bf3d37c729260e8a8e3ef808799de" title="Height which was determined by reading the _NET_WM_STRUT_PARTIAL top/bottom of the...">desired_height</a>)) <a name="l00588"></a>00588 <a class="code" href="a00069.html#a83463931ef26f7c3261dc1b804282299" title="Pushes the client’s width/height to X11 and resizes the child window.">resize_client</a>(conn, client); <a name="l00589"></a>00589 <a name="l00590"></a>00590 client-><a class="code" href="a00007.html#a873c62703ab51afe96b38df2b30ffa66">force_reconfigure</a> = <span class="keyword">false</span>; <a name="l00591"></a>00591 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"desired_height = %d\n"</span>, client-><a class="code" href="a00007.html#a101bf3d37c729260e8a8e3ef808799de" title="Height which was determined by reading the _NET_WM_STRUT_PARTIAL top/bottom of the...">desired_height</a>); <a name="l00592"></a>00592 *height += client-><a class="code" href="a00007.html#a101bf3d37c729260e8a8e3ef808799de" title="Height which was determined by reading the _NET_WM_STRUT_PARTIAL top/bottom of the...">desired_height</a>; <a name="l00593"></a>00593 } <a name="l00594"></a>00594 } <a name="l00595"></a>00595 <a name="l00596"></a><a class="code" href="a00069.html#aeb93d4db13919083e64cc90059f1c79c">00596</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="a00069.html#aeb93d4db13919083e64cc90059f1c79c">render_internal_bar</a>(xcb_connection_t *conn, <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *r_ws, <span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height) { <a name="l00597"></a>00597 <a class="code" href="a00015.html" title="Data structure for cached font information:font id in X11 (load it once)font height...">i3Font</a> *font = <a class="code" href="a00054.html#a50c1fc0de5343536d542c8349ab7ab0d" title="Loads a font for usage, getting its height.">load_font</a>(conn, <a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#aff568f0d5ca7a51971f4c3006a842019">font</a>); <a name="l00598"></a>00598 <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output = r_ws-><a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>; <a name="l00599"></a>00599 <span class="keyword">enum</span> { SET_NORMAL = 0, SET_FOCUSED = 1 }; <a name="l00600"></a>00600 <a name="l00601"></a>00601 <span class="comment">/* Fill the whole bar in black */</span> <a name="l00602"></a>00602 <a class="code" href="a00079.html#ac20ce6b9cf46f63675e363ac5dc2f24e" title="Changes a single value in the graphic context (so one doesn’t have to define an...">xcb_change_gc_single</a>(conn, output-><a class="code" href="a00026.html#a1463701491a3a9454f7a3a6efdabf566">bargc</a>, XCB_GC_FOREGROUND, <a class="code" href="a00079.html#a0146fe310e31c9509a7a7846aa547c67" title="Returns the colorpixel to use for the given hex color (think of HTML).">get_colorpixel</a>(conn, <span class="stringliteral">"#000000"</span>)); <a name="l00603"></a>00603 xcb_rectangle_t <a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a> = {0, 0, width, height}; <a name="l00604"></a>00604 xcb_poly_fill_rectangle(conn, output-><a class="code" href="a00026.html#a479cef7d03401926d37ee89a6ee37aed" title="The bar window.">bar</a>, output-><a class="code" href="a00026.html#a1463701491a3a9454f7a3a6efdabf566">bargc</a>, 1, &rect); <a name="l00605"></a>00605 <a name="l00606"></a>00606 <span class="comment">/* Set font */</span> <a name="l00607"></a>00607 <a class="code" href="a00079.html#ac20ce6b9cf46f63675e363ac5dc2f24e" title="Changes a single value in the graphic context (so one doesn’t have to define an...">xcb_change_gc_single</a>(conn, output-><a class="code" href="a00026.html#a1463701491a3a9454f7a3a6efdabf566">bargc</a>, XCB_GC_FONT, font-><a class="code" href="a00015.html#a34f00fc78328c10986cdebfc3940ee05" title="The xcb-id for the font.">id</a>); <a name="l00608"></a>00608 <a name="l00609"></a>00609 <span class="keywordtype">int</span> drawn = 0; <a name="l00610"></a>00610 <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws; <a name="l00611"></a>00611 <a class="code" href="a00047.html#a16e5fc168e7f3494d4b1df54447d871e">TAILQ_FOREACH</a>(ws, <a class="code" href="a00076.html#afb45f3a3a9c66c3e3a5e4d372ae24da7">workspaces</a>, <a class="code" href="a00076.html#afb45f3a3a9c66c3e3a5e4d372ae24da7">workspaces</a>) { <a name="l00612"></a>00612 <span class="keywordflow">if</span> (ws-><a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a> != output) <a name="l00613"></a>00613 <span class="keywordflow">continue</span>; <a name="l00614"></a>00614 <a name="l00615"></a>00615 <span class="keyword">struct </span><a class="code" href="a00009.html" title="Part of the struct Config.">Colortriple</a> *color; <a name="l00616"></a>00616 <a name="l00617"></a>00617 <span class="keywordflow">if</span> (output-><a class="code" href="a00026.html#a9bcf702b65d8f47f98eafbefff529ffe" title="Current workspace selected on this virtual screen.">current_workspace</a> == ws) <a name="l00618"></a>00618 color = &(<a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#a87797dfb71243a11161231d2fdf3ecdb">bar</a>.<a class="code" href="a00011.html#a53350b6b2d0d985dadf8bbade54237e7">focused</a>); <a name="l00619"></a>00619 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ws-><a class="code" href="a00025.html#ae43262c5fb60e7d7a93da1041835eeb2" title="True if any client on this workspace has its urgent flag set.">urgent</a>) <a name="l00620"></a>00620 color = &(<a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#a87797dfb71243a11161231d2fdf3ecdb">bar</a>.<a class="code" href="a00011.html#acec0f35d252f351505156ead6757f6bb">urgent</a>); <a name="l00621"></a>00621 <span class="keywordflow">else</span> color = &(<a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#a87797dfb71243a11161231d2fdf3ecdb">bar</a>.<a class="code" href="a00011.html#a99f68b3648d5b17e92e02f29c5eab9ca">unfocused</a>); <a name="l00622"></a>00622 <a name="l00623"></a>00623 <span class="comment">/* Draw the outer rect */</span> <a name="l00624"></a>00624 <a class="code" href="a00079.html#ac2b163cc3d76bdec224a1ce5c7ac9c6d" title="Draws a rectangle from x,y with width,height using the given color.">xcb_draw_rect</a>(conn, output-><a class="code" href="a00026.html#a479cef7d03401926d37ee89a6ee37aed" title="The bar window.">bar</a>, output-><a class="code" href="a00026.html#a1463701491a3a9454f7a3a6efdabf566">bargc</a>, color-><a class="code" href="a00009.html#abc8ad1d75ff1d44e27aeb6c2eb7713a0">border</a>, <a name="l00625"></a>00625 drawn, <span class="comment">/* x */</span> <a name="l00626"></a>00626 1, <span class="comment">/* y */</span> <a name="l00627"></a>00627 ws-><a class="code" href="a00025.html#ad7c51613ba7339af44071f450af5f37d" title="Width of the workspace’s name (in pixels) rendered in config.font.">text_width</a> + 5 + 5, <span class="comment">/* width = text width + 5 px left + 5px right */</span> <a name="l00628"></a>00628 height - 2 <span class="comment">/* height = max. height - 1 px upper and 1 px bottom border */</span>); <a name="l00629"></a>00629 <a name="l00630"></a>00630 <span class="comment">/* Draw the background of this rect */</span> <a name="l00631"></a>00631 <a class="code" href="a00079.html#ac2b163cc3d76bdec224a1ce5c7ac9c6d" title="Draws a rectangle from x,y with width,height using the given color.">xcb_draw_rect</a>(conn, output-><a class="code" href="a00026.html#a479cef7d03401926d37ee89a6ee37aed" title="The bar window.">bar</a>, output-><a class="code" href="a00026.html#a1463701491a3a9454f7a3a6efdabf566">bargc</a>, color-><a class="code" href="a00009.html#a54065f4c7667110b00ece931b9a45348">background</a>, <a name="l00632"></a>00632 drawn + 1, <a name="l00633"></a>00633 2, <a name="l00634"></a>00634 ws-><a class="code" href="a00025.html#ad7c51613ba7339af44071f450af5f37d" title="Width of the workspace’s name (in pixels) rendered in config.font.">text_width</a> + 4 + 4, <a name="l00635"></a>00635 height - 4); <a name="l00636"></a>00636 <a name="l00637"></a>00637 <a class="code" href="a00079.html#ac20ce6b9cf46f63675e363ac5dc2f24e" title="Changes a single value in the graphic context (so one doesn’t have to define an...">xcb_change_gc_single</a>(conn, output-><a class="code" href="a00026.html#a1463701491a3a9454f7a3a6efdabf566">bargc</a>, XCB_GC_FOREGROUND, color-><a class="code" href="a00009.html#ac75bcfcac277782b13996a42ecbe355f">text</a>); <a name="l00638"></a>00638 <a class="code" href="a00079.html#ac20ce6b9cf46f63675e363ac5dc2f24e" title="Changes a single value in the graphic context (so one doesn’t have to define an...">xcb_change_gc_single</a>(conn, output-><a class="code" href="a00026.html#a1463701491a3a9454f7a3a6efdabf566">bargc</a>, XCB_GC_BACKGROUND, color-><a class="code" href="a00009.html#a54065f4c7667110b00ece931b9a45348">background</a>); <a name="l00639"></a>00639 xcb_image_text_16(conn, ws-><a class="code" href="a00025.html#a190c6f4026f0bff8b0d49340823fc1e1" title="Length of the workspace’s name (in glyphs).">name_len</a>, output-><a class="code" href="a00026.html#a479cef7d03401926d37ee89a6ee37aed" title="The bar window.">bar</a>, output-><a class="code" href="a00026.html#a1463701491a3a9454f7a3a6efdabf566">bargc</a>, drawn + 5 <span class="comment">/* X */</span>, <a name="l00640"></a>00640 font-><a class="code" href="a00015.html#a89ceb86bb4ad2694315d846e69893399" title="The height of the font, built from font_ascent + font_descent.">height</a> + 1 <span class="comment">/* Y = baseline of font */</span>, <a name="l00641"></a>00641 (xcb_char2b_t*)ws-><a class="code" href="a00025.html#a2db20d0a3a8866278611898710445017" title="Name of the workspace (in UCS-2).">name</a>); <a name="l00642"></a>00642 drawn += ws-><a class="code" href="a00025.html#ad7c51613ba7339af44071f450af5f37d" title="Width of the workspace’s name (in pixels) rendered in config.font.">text_width</a> + 12; <a name="l00643"></a>00643 } <a name="l00644"></a>00644 } <a name="l00645"></a>00645 <a name="l00646"></a>00646 <span class="comment">/*</span> <a name="l00647"></a>00647 <span class="comment"> * Modifies the event mask of all clients on the given workspace to either ignore or to handle</span> <a name="l00648"></a>00648 <span class="comment"> * enter notifies. It is handy to ignore notifies because they will be sent when a window is mapped</span> <a name="l00649"></a>00649 <span class="comment"> * under the cursor, thus when the user didn’t enter the window actively at all.</span> <a name="l00650"></a>00650 <span class="comment"> *</span> <a name="l00651"></a>00651 <span class="comment"> */</span> <a name="l00652"></a><a class="code" href="a00043.html#a8a6aa6f7ea9bdaae274ff67183940dce">00652</a> <span class="keywordtype">void</span> <a class="code" href="a00069.html#a8a6aa6f7ea9bdaae274ff67183940dce" title="Modifies the event mask of all clients on the given workspace to either ignore or...">ignore_enter_notify_forall</a>(xcb_connection_t *conn, <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *workspace, <span class="keywordtype">bool</span> ignore_enter_notify) { <a name="l00653"></a>00653 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client; <a name="l00654"></a>00654 uint32_t values[1]; <a name="l00655"></a>00655 <a name="l00656"></a>00656 <a class="code" href="a00052.html#a7da994865329c8424d49403dec5fef5e">FOR_TABLE</a>(workspace) { <a name="l00657"></a>00657 <span class="keywordflow">if</span> (workspace-><a class="code" href="a00025.html#a26cf35518dcf31aa97deda261548e719" title="This is a two-dimensional dynamic array of Container-pointers.">table</a>[cols][rows] == NULL) <a name="l00658"></a>00658 <span class="keywordflow">continue</span>; <a name="l00659"></a>00659 <a name="l00660"></a>00660 <a class="code" href="a00047.html#ae97f4eb5724477c63699fafea4614b46">CIRCLEQ_FOREACH</a>(client, &(workspace-><a class="code" href="a00025.html#a26cf35518dcf31aa97deda261548e719" title="This is a two-dimensional dynamic array of Container-pointers.">table</a>[cols][rows]->clients), clients) { <a name="l00661"></a>00661 <span class="comment">/* Change event mask for the decorations */</span> <a name="l00662"></a>00662 values[0] = <a class="code" href="a00054.html#aed223c0ebc389529a1b1e74c6f4d2df8" title="The XCB_CW_EVENT_MASK for its frame.">FRAME_EVENT_MASK</a>; <a name="l00663"></a>00663 <span class="keywordflow">if</span> (ignore_enter_notify) <a name="l00664"></a>00664 values[0] &= ~(XCB_EVENT_MASK_ENTER_WINDOW); <a name="l00665"></a>00665 xcb_change_window_attributes(conn, client-><a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, XCB_CW_EVENT_MASK, values); <a name="l00666"></a>00666 <a name="l00667"></a>00667 <span class="comment">/* Change event mask for the child itself */</span> <a name="l00668"></a>00668 values[0] = <a class="code" href="a00054.html#a943b53f85455fd0587d1b010cd9e4114" title="The XCB_CW_EVENT_MASK for the child (= real window).">CHILD_EVENT_MASK</a>; <a name="l00669"></a>00669 <span class="keywordflow">if</span> (ignore_enter_notify) <a name="l00670"></a>00670 values[0] &= ~(XCB_EVENT_MASK_ENTER_WINDOW); <a name="l00671"></a>00671 xcb_change_window_attributes(conn, client-><a class="code" href="a00007.html#afba312b946fa74727ce619a33f8f28aa" title="The client’s window.">child</a>, XCB_CW_EVENT_MASK, values); <a name="l00672"></a>00672 } <a name="l00673"></a>00673 } <a name="l00674"></a>00674 } <a name="l00675"></a>00675 <a name="l00676"></a>00676 <span class="comment">/*</span> <a name="l00677"></a>00677 <span class="comment"> * Renders the given workspace on the given screen</span> <a name="l00678"></a>00678 <span class="comment"> *</span> <a name="l00679"></a>00679 <span class="comment"> */</span> <a name="l00680"></a><a class="code" href="a00043.html#ab3e248d886080e290648c0d791a40b64">00680</a> <span class="keywordtype">void</span> <a class="code" href="a00069.html#ab3e248d886080e290648c0d791a40b64" title="Renders the given workspace on the given screen.">render_workspace</a>(xcb_connection_t *conn, <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output, <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *r_ws) { <a name="l00681"></a>00681 <a class="code" href="a00015.html" title="Data structure for cached font information:font id in X11 (load it once)font height...">i3Font</a> *font = <a class="code" href="a00054.html#a50c1fc0de5343536d542c8349ab7ab0d" title="Loads a font for usage, getting its height.">load_font</a>(conn, <a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#aff568f0d5ca7a51971f4c3006a842019">font</a>); <a name="l00682"></a>00682 <span class="keywordtype">int</span> width = r_ws-><a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>; <a name="l00683"></a>00683 <span class="keywordtype">int</span> height = r_ws-><a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>; <a name="l00684"></a>00684 <a name="l00685"></a>00685 <span class="comment">/* Reserve space for dock clients */</span> <a name="l00686"></a>00686 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client; <a name="l00687"></a>00687 <a class="code" href="a00047.html#a05db87878125c27e3060dd641aa3b0f4">SLIST_FOREACH</a>(client, &(output->dock_clients), dock_clients) <a name="l00688"></a>00688 height -= client-><a class="code" href="a00007.html#a101bf3d37c729260e8a8e3ef808799de" title="Height which was determined by reading the _NET_WM_STRUT_PARTIAL top/bottom of the...">desired_height</a>; <a name="l00689"></a>00689 <a name="l00690"></a>00690 <span class="comment">/* Space for the internal bar */</span> <a name="l00691"></a>00691 <span class="keywordflow">if</span> (!<a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#ae4e1660269cdac461dac45368e592b4c" title="By default, a workspace bar is drawn at the bottom of the screen.">disable_workspace_bar</a>) <a name="l00692"></a>00692 height -= (font-><a class="code" href="a00015.html#a89ceb86bb4ad2694315d846e69893399" title="The height of the font, built from font_ascent + font_descent.">height</a> + 6); <a name="l00693"></a>00693 <a name="l00694"></a>00694 <span class="keywordtype">int</span> xoffset[r_ws-><a class="code" href="a00025.html#ae4fee0126eb1ae8484bf7281709c3fdb" title="table dimensions">rows</a>]; <a name="l00695"></a>00695 <span class="keywordtype">int</span> yoffset[r_ws-><a class="code" href="a00025.html#a1d295f430fa92fc0b91c7f85a4b499b2" title="table dimensions">cols</a>]; <a name="l00696"></a>00696 <span class="comment">/* Initialize offsets */</span> <a name="l00697"></a>00697 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> cols = 0; cols < r_ws-><a class="code" href="a00025.html#a1d295f430fa92fc0b91c7f85a4b499b2" title="table dimensions">cols</a>; cols++) <a name="l00698"></a>00698 yoffset[cols] = r_ws-><a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>; <a name="l00699"></a>00699 for (<span class="keywordtype">int</span> rows = 0; rows < r_ws-><a class="code" href="a00025.html#ae4fee0126eb1ae8484bf7281709c3fdb" title="table dimensions">rows</a>; rows++) <a name="l00700"></a>00700 xoffset[rows] = r_ws-><a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>; <a name="l00701"></a>00701 <a name="l00702"></a>00702 <a class="code" href="a00069.html#a8a6aa6f7ea9bdaae274ff67183940dce" title="Modifies the event mask of all clients on the given workspace to either ignore or...">ignore_enter_notify_forall</a>(conn, r_ws, <span class="keyword">true</span>); <a name="l00703"></a>00703 <a name="l00704"></a>00704 <span class="comment">/* Go through the whole table and render what’s necessary */</span> <a name="l00705"></a>00705 <a class="code" href="a00052.html#a7da994865329c8424d49403dec5fef5e">FOR_TABLE</a>(r_ws) { <a name="l00706"></a>00706 <a class="code" href="a00013.html" title="A container is either in default, stacking or tabbed mode.">Container</a> *container = r_ws-><a class="code" href="a00025.html#a26cf35518dcf31aa97deda261548e719" title="This is a two-dimensional dynamic array of Container-pointers.">table</a>[cols][rows]; <a name="l00707"></a>00707 <span class="keywordflow">if</span> (container == NULL) <a name="l00708"></a>00708 <span class="keywordflow">continue</span>; <a name="l00709"></a>00709 <span class="keywordtype">int</span> single_width = -1, single_height = -1; <a name="l00710"></a>00710 <span class="comment">/* Update position of the container */</span> <a name="l00711"></a>00711 container-><a class="code" href="a00013.html#a4fefa5b1b97f096cbee9cd24cc3d6c34">row</a> = rows; <a name="l00712"></a>00712 container-><a class="code" href="a00013.html#ad20f57a89cdcc15b1e656c67d7b4861a">col</a> = cols; <a name="l00713"></a>00713 container-><a class="code" href="a00013.html#a4829135d344139fb1c9e25ae5cdf5747">x</a> = xoffset[rows]; <a name="l00714"></a>00714 container-><a class="code" href="a00013.html#a31cfaffc96b7c938a239bd40c1488230">y</a> = yoffset[cols]; <a name="l00715"></a>00715 container-><a class="code" href="a00013.html#af9b566fc3a8a208897503254747ae720">width</a> = 0; <a name="l00716"></a>00716 <a name="l00717"></a>00717 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> c = 0; c < container-><a class="code" href="a00013.html#abb706ed35dd8c6303633d4c45c97d855">colspan</a>; c++) { <a name="l00718"></a>00718 <span class="keywordflow">if</span> (r_ws-><a class="code" href="a00025.html#a9821dccf3f7541515549feb57527dcb6" title="width_factor and height_factor contain the amount of space (percentage) a column/row...">width_factor</a>[cols+c] == 0) <a name="l00719"></a>00719 container-><a class="code" href="a00013.html#af9b566fc3a8a208897503254747ae720">width</a> += (width / r_ws-><a class="code" href="a00025.html#a1d295f430fa92fc0b91c7f85a4b499b2" title="table dimensions">cols</a>); <a name="l00720"></a>00720 <span class="keywordflow">else</span> container-><a class="code" href="a00013.html#af9b566fc3a8a208897503254747ae720">width</a> += <a class="code" href="a00069.html#a58500d1d5e56285ceb2bd514dbee8a2f" title="Gets the unoccupied space (= space which is available for windows which were resized...">get_unoccupied_x</a>(r_ws) * r_ws-><a class="code" href="a00025.html#a9821dccf3f7541515549feb57527dcb6" title="width_factor and height_factor contain the amount of space (percentage) a column/row...">width_factor</a>[cols+c]; <a name="l00721"></a>00721 <a name="l00722"></a>00722 <span class="keywordflow">if</span> (single_width == -1) <a name="l00723"></a>00723 single_width = container-><a class="code" href="a00013.html#af9b566fc3a8a208897503254747ae720">width</a>; <a name="l00724"></a>00724 } <a name="l00725"></a>00725 <a name="l00726"></a>00726 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"height is %d\n"</span>, height); <a name="l00727"></a>00727 <a name="l00728"></a>00728 container-><a class="code" href="a00013.html#a62e576209b30aeaf8c2fd0121b4f705c">height</a> = 0; <a name="l00729"></a>00729 <a name="l00730"></a>00730 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> c = 0; c < container-><a class="code" href="a00013.html#ac87ec920de798c8f06a131af45af1fa6">rowspan</a>; c++) { <a name="l00731"></a>00731 <span class="keywordflow">if</span> (r_ws-><a class="code" href="a00025.html#a88f474bf999c23126a00922de6102822">height_factor</a>[rows+c] == 0) <a name="l00732"></a>00732 container-><a class="code" href="a00013.html#a62e576209b30aeaf8c2fd0121b4f705c">height</a> += (height / r_ws-><a class="code" href="a00025.html#ae4fee0126eb1ae8484bf7281709c3fdb" title="table dimensions">rows</a>); <a name="l00733"></a>00733 <span class="keywordflow">else</span> container-><a class="code" href="a00013.html#a62e576209b30aeaf8c2fd0121b4f705c">height</a> += <a class="code" href="a00069.html#a9ca57ef4162045e82bf24e326ec8a936" title="See get_unoccupied_x.">get_unoccupied_y</a>(r_ws) * r_ws-><a class="code" href="a00025.html#a88f474bf999c23126a00922de6102822">height_factor</a>[rows+c]; <a name="l00734"></a>00734 <a name="l00735"></a>00735 <span class="keywordflow">if</span> (single_height == -1) <a name="l00736"></a>00736 single_height = container-><a class="code" href="a00013.html#a62e576209b30aeaf8c2fd0121b4f705c">height</a>; <a name="l00737"></a>00737 } <a name="l00738"></a>00738 <a name="l00739"></a>00739 <span class="comment">/* Render the container if it is not empty */</span> <a name="l00740"></a>00740 <a class="code" href="a00069.html#a2a1fee0aebdaf2497fb52ea57a1033a4" title="Renders the given container.">render_container</a>(conn, container); <a name="l00741"></a>00741 <a name="l00742"></a>00742 xoffset[rows] += single_width; <a name="l00743"></a>00743 yoffset[cols] += single_height; <a name="l00744"></a>00744 } <a name="l00745"></a>00745 <a name="l00746"></a>00746 <span class="comment">/* Reposition all floating clients with force_reconfigure == true */</span> <a name="l00747"></a>00747 <a class="code" href="a00047.html#a16e5fc168e7f3494d4b1df54447d871e">TAILQ_FOREACH</a>(client, &(r_ws->floating_clients), floating_clients) { <a name="l00748"></a>00748 <span class="keywordflow">if</span> (!client-><a class="code" href="a00007.html#a873c62703ab51afe96b38df2b30ffa66">force_reconfigure</a>) <a name="l00749"></a>00749 <span class="keywordflow">continue</span>; <a name="l00750"></a>00750 <a name="l00751"></a>00751 client-><a class="code" href="a00007.html#a873c62703ab51afe96b38df2b30ffa66">force_reconfigure</a> = <span class="keyword">false</span>; <a name="l00752"></a>00752 <a class="code" href="a00069.html#a1d68fface3cf11ff882c23a5bfa586ab" title="Pushes the client’s x and y coordinates to X11.">reposition_client</a>(conn, client); <a name="l00753"></a>00753 <a class="code" href="a00069.html#a83463931ef26f7c3261dc1b804282299" title="Pushes the client’s width/height to X11 and resizes the child window.">resize_client</a>(conn, client); <a name="l00754"></a>00754 } <a name="l00755"></a>00755 <a name="l00756"></a>00756 <a class="code" href="a00069.html#a8a6aa6f7ea9bdaae274ff67183940dce" title="Modifies the event mask of all clients on the given workspace to either ignore or...">ignore_enter_notify_forall</a>(conn, r_ws, <span class="keyword">false</span>); <a name="l00757"></a>00757 <a name="l00758"></a>00758 <a class="code" href="a00069.html#a54f8071e93b6c95fc2834df8efd5c134">render_bars</a>(conn, r_ws, width, &height); <a name="l00759"></a>00759 <span class="keywordflow">if</span> (!<a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#ae4e1660269cdac461dac45368e592b4c" title="By default, a workspace bar is drawn at the bottom of the screen.">disable_workspace_bar</a>) <a name="l00760"></a>00760 <a class="code" href="a00069.html#aeb93d4db13919083e64cc90059f1c79c">render_internal_bar</a>(conn, r_ws, width, font-><a class="code" href="a00015.html#a89ceb86bb4ad2694315d846e69893399" title="The height of the font, built from font_ascent + font_descent.">height</a> + 6); <a name="l00761"></a>00761 } <a name="l00762"></a>00762 <a name="l00763"></a>00763 <span class="comment">/*</span> <a name="l00764"></a>00764 <span class="comment"> * Renders the whole layout, that is: Go through each screen, each workspace, each container</span> <a name="l00765"></a>00765 <span class="comment"> * and render each client. This also renders the bars.</span> <a name="l00766"></a>00766 <span class="comment"> *</span> <a name="l00767"></a>00767 <span class="comment"> * If you don’t need to render *everything*, you should call render_container on the container</span> <a name="l00768"></a>00768 <span class="comment"> * you want to refresh.</span> <a name="l00769"></a>00769 <span class="comment"> *</span> <a name="l00770"></a>00770 <span class="comment"> */</span> <a name="l00771"></a><a class="code" href="a00043.html#a47ffef7db851301198762179187ac997">00771</a> <span class="keywordtype">void</span> <a class="code" href="a00069.html#a47ffef7db851301198762179187ac997" title="Renders the whole layout, that is: Go through each screen, each workspace, each container...">render_layout</a>(xcb_connection_t *conn) { <a name="l00772"></a>00772 <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output; <a name="l00773"></a>00773 <a name="l00774"></a>00774 <a class="code" href="a00047.html#a16e5fc168e7f3494d4b1df54447d871e">TAILQ_FOREACH</a>(output, &<a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>, <a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>) <a name="l00775"></a>00775 <span class="keywordflow">if</span> (output-><a class="code" href="a00026.html#a9bcf702b65d8f47f98eafbefff529ffe" title="Current workspace selected on this virtual screen.">current_workspace</a> != NULL) <a name="l00776"></a>00776 <a class="code" href="a00069.html#ab3e248d886080e290648c0d791a40b64" title="Renders the given workspace on the given screen.">render_workspace</a>(conn, output, output-><a class="code" href="a00026.html#a9bcf702b65d8f47f98eafbefff529ffe" title="Current workspace selected on this virtual screen.">current_workspace</a>); <a name="l00777"></a>00777 <a name="l00778"></a>00778 xcb_flush(conn); <a name="l00779"></a>00779 } </pre></div></div> <hr class="footer"/><address style="text-align: right;"><small>Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.2-20100208 </small></address> </body> </html>