<!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/floating.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/floating.c</h1><a href="a00066.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"> * src/floating.c: contains all functions for handling floating clients</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 <stdlib.h></span> <a name="l00014"></a>00014 <span class="preprocessor">#include <string.h></span> <a name="l00015"></a>00015 <span class="preprocessor">#include <assert.h></span> <a name="l00016"></a>00016 <a name="l00017"></a>00017 <span class="preprocessor">#include <xcb/xcb.h></span> <a name="l00018"></a>00018 <span class="preprocessor">#include <xcb/xcb_event.h></span> <a name="l00019"></a>00019 <a name="l00020"></a>00020 <span class="preprocessor">#include "<a class="code" href="a00041.html">i3.h</a>"</span> <a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="a00034.html">config.h</a>"</span> <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="a00036.html">data.h</a>"</span> <a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="a00052.html">util.h</a>"</span> <a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="a00054.html">xcb.h</a>"</span> <a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="a00037.html">debug.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="a00053.html">workspace.h</a>"</span> <a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="a00044.html">log.h</a>"</span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="comment">/*</span> <a name="l00033"></a>00033 <span class="comment"> * Toggles floating mode for the given client.</span> <a name="l00034"></a>00034 <span class="comment"> * Correctly takes care of the position/size (separately stored for tiling/floating mode)</span> <a name="l00035"></a>00035 <span class="comment"> * and repositions/resizes/redecorates the client.</span> <a name="l00036"></a>00036 <span class="comment"> *</span> <a name="l00037"></a>00037 <span class="comment"> * If the automatic flag is set to true, this was an automatic update by a change of the</span> <a name="l00038"></a>00038 <span class="comment"> * window class from the application which can be overwritten by the user.</span> <a name="l00039"></a>00039 <span class="comment"> *</span> <a name="l00040"></a>00040 <span class="comment"> */</span> <a name="l00041"></a><a class="code" href="a00039.html#aa8af48aadcf7753f5efc97b65a4cfd91">00041</a> <span class="keywordtype">void</span> <a class="code" href="a00066.html#aa8af48aadcf7753f5efc97b65a4cfd91" title="Enters floating mode for the given client.">toggle_floating_mode</a>(xcb_connection_t *conn, <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client, <span class="keywordtype">bool</span> automatic) { <a name="l00042"></a>00042 <a class="code" href="a00013.html" title="A container is either in default, stacking or tabbed mode.">Container</a> *con = client-><a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>; <a name="l00043"></a>00043 <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="l00044"></a>00044 <a name="l00045"></a>00045 <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="l00046"></a>00046 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Not putting dock client into floating mode\n"</span>); <a name="l00047"></a>00047 <span class="keywordflow">return</span>; <a name="l00048"></a>00048 } <a name="l00049"></a>00049 <a name="l00050"></a>00050 <span class="keywordflow">if</span> (con == NULL) { <a name="l00051"></a>00051 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"This client is already in floating (container == NULL), re-inserting\n"</span>); <a name="l00052"></a>00052 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *next_tiling; <a name="l00053"></a>00053 <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws = 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="l00054"></a>00054 <a class="code" href="a00047.html#a05db87878125c27e3060dd641aa3b0f4">SLIST_FOREACH</a>(next_tiling, &(ws->focus_stack), focus_clients) <a name="l00055"></a>00055 <span class="keywordflow">if</span> (!<a class="code" href="a00060.html#a56065826f75013837bc8e125c8dc66c7" title="Returns true if the client is floating.">client_is_floating</a>(next_tiling)) <a name="l00056"></a>00056 <span class="keywordflow">break</span>; <a name="l00057"></a>00057 <span class="comment">/* If there are no tiling clients on this workspace, there can only be one</span> <a name="l00058"></a>00058 <span class="comment"> * container: the first one */</span> <a name="l00059"></a>00059 <span class="keywordflow">if</span> (next_tiling == <a class="code" href="a00047.html#a4322b8461a6ab7632435ff4f57bb3a2e">TAILQ_END</a>(&(ws->focus_stack))) <a name="l00060"></a>00060 con = ws-><a class="code" href="a00025.html#a26cf35518dcf31aa97deda261548e719" title="This is a two-dimensional dynamic array of Container-pointers.">table</a>[0][0]; <a name="l00061"></a>00061 <span class="keywordflow">else</span> con = next_tiling-><a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>; <a name="l00062"></a>00062 <a name="l00063"></a>00063 <span class="comment">/* Remove the client from the list of floating clients */</span> <a name="l00064"></a>00064 <a class="code" href="a00047.html#aaae87ca18c28066e1a96221e762d1209">TAILQ_REMOVE</a>(&(ws->floating_clients), client, floating_clients); <a name="l00065"></a>00065 <a name="l00066"></a>00066 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"destination container = %p\n"</span>, con); <a name="l00067"></a>00067 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *old_focused = con-><a class="code" href="a00013.html#a82d910506b0d788a92ebeeb1d82da75b">currently_focused</a>; <a name="l00068"></a>00068 <span class="comment">/* Preserve position/size */</span> <a name="l00069"></a>00069 memcpy(&(client-><a class="code" href="a00007.html#a7af57ac287f68a6e55b9279b720d7491" title="Position in floating mode and in tiling mode are saved separately.">floating_rect</a>), &(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>), <span class="keyword">sizeof</span>(<a class="code" href="a00020.html" title="Stores a rectangle, for example the size of a window, the child window etc.">Rect</a>)); <a name="l00070"></a>00070 <a name="l00071"></a>00071 client-><a class="code" href="a00007.html#ad5e886955e668cc51fbb17acb2871cea" title="floating? (= not in tiling layout) This cannot be simply a bool because we want to...">floating</a> = FLOATING_USER_OFF; <a name="l00072"></a>00072 client-><a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a> = con; <a name="l00073"></a>00073 <a name="l00074"></a>00074 <span class="keywordflow">if</span> (old_focused != NULL && !old_focused-><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="l00075"></a>00075 <a class="code" href="a00047.html#a108b36ff00cbf59efbbf185baac770b4">CIRCLEQ_INSERT_AFTER</a>(&(con->clients), old_focused, client, clients); <a name="l00076"></a>00076 <span class="keywordflow">else</span> <a class="code" href="a00047.html#aa2b767125267fa26ca10e21fa358008c">CIRCLEQ_INSERT_TAIL</a>(&(con->clients), client, clients); <a name="l00077"></a>00077 <a name="l00078"></a>00078 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Re-inserted the window.\n"</span>); <a name="l00079"></a>00079 con-><a class="code" href="a00013.html#a82d910506b0d788a92ebeeb1d82da75b">currently_focused</a> = client; <a name="l00080"></a>00080 <a name="l00081"></a>00081 <a class="code" href="a00060.html#a20c5492b1cd5c30793e9fae4b7902686" title="Sets the position of the given client in the X stack to the highest (tiling layer...">client_set_below_floating</a>(conn, client); <a name="l00082"></a>00082 <a name="l00083"></a>00083 <a class="code" href="a00069.html#a2a1fee0aebdaf2497fb52ea57a1033a4" title="Renders the given container.">render_container</a>(conn, con); <a name="l00084"></a>00084 xcb_flush(conn); <a name="l00085"></a>00085 <a name="l00086"></a>00086 <span class="keywordflow">return</span>; <a name="l00087"></a>00087 } <a name="l00088"></a>00088 <a name="l00089"></a>00089 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Entering floating for client %08x\n"</span>, client-><a class="code" href="a00007.html#afba312b946fa74727ce619a33f8f28aa" title="The client’s window.">child</a>); <a name="l00090"></a>00090 <a name="l00091"></a>00091 <span class="comment">/* Remove the client of its container */</span> <a name="l00092"></a>00092 <a class="code" href="a00060.html#a795be4a8912ac14d7657257953a91cd1" title="Removes the given client from the container, either because it will be inserted into...">client_remove_from_container</a>(conn, client, con, <span class="keyword">false</span>); <a name="l00093"></a>00093 client-><a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a> = NULL; <a name="l00094"></a>00094 <a name="l00095"></a>00095 <span class="comment">/* Add the client to the list of floating clients for its workspace */</span> <a name="l00096"></a>00096 <a class="code" href="a00047.html#a512bee16b46f601078c96c776d2648c3">TAILQ_INSERT_TAIL</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>->floating_clients), client, floating_clients); <a name="l00097"></a>00097 <a name="l00098"></a>00098 <span class="keywordflow">if</span> (con-><a class="code" href="a00013.html#a82d910506b0d788a92ebeeb1d82da75b">currently_focused</a> == client) { <a name="l00099"></a>00099 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Need to re-adjust currently_focused\n"</span>); <a name="l00100"></a>00100 <span class="comment">/* Get the next client in the focus stack for this particular container */</span> <a name="l00101"></a>00101 con-><a class="code" href="a00013.html#a82d910506b0d788a92ebeeb1d82da75b">currently_focused</a> = <a class="code" href="a00077.html#ad5a21e1f5f7065c1997717c13559907a" title="Returns the client which comes next in focus stack (= was selected before) for the...">get_last_focused_client</a>(conn, con, NULL); <a name="l00102"></a>00102 } <a name="l00103"></a>00103 <a name="l00104"></a>00104 <span class="keywordflow">if</span> (automatic) <a name="l00105"></a>00105 client-><a class="code" href="a00007.html#ad5e886955e668cc51fbb17acb2871cea" title="floating? (= not in tiling layout) This cannot be simply a bool because we want to...">floating</a> = FLOATING_AUTO_ON; <a name="l00106"></a>00106 <span class="keywordflow">else</span> client-><a class="code" href="a00007.html#ad5e886955e668cc51fbb17acb2871cea" title="floating? (= not in tiling layout) This cannot be simply a bool because we want to...">floating</a> = FLOATING_USER_ON; <a name="l00107"></a>00107 <a name="l00108"></a>00108 <span class="comment">/* Initialize the floating position from the position in tiling mode, if this</span> <a name="l00109"></a>00109 <span class="comment"> * client never was floating (x == -1) */</span> <a name="l00110"></a>00110 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a7af57ac287f68a6e55b9279b720d7491" title="Position in floating mode and in tiling mode are saved separately.">floating_rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> == -1) { <a name="l00111"></a>00111 <span class="comment">/* Copy over the position */</span> <a name="l00112"></a>00112 client-><a class="code" href="a00007.html#a7af57ac287f68a6e55b9279b720d7491" title="Position in floating mode and in tiling mode are saved separately.">floating_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#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>; <a name="l00113"></a>00113 client-><a class="code" href="a00007.html#a7af57ac287f68a6e55b9279b720d7491" title="Position in floating mode and in tiling mode are saved separately.">floating_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#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>; <a name="l00114"></a>00114 <a name="l00115"></a>00115 <span class="comment">/* Copy size the other direction */</span> <a name="l00116"></a>00116 client-><a class="code" href="a00007.html#a694f6f127e048521451f931174a6e140" title="x, y, width, height of the child (relative to its frame)">child_rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> = client-><a class="code" href="a00007.html#a7af57ac287f68a6e55b9279b720d7491" title="Position in floating mode and in tiling mode are saved separately.">floating_rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>; <a name="l00117"></a>00117 client-><a class="code" href="a00007.html#a694f6f127e048521451f931174a6e140" title="x, y, width, height of the child (relative to its frame)">child_rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> = client-><a class="code" href="a00007.html#a7af57ac287f68a6e55b9279b720d7491" title="Position in floating mode and in tiling mode are saved separately.">floating_rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>; <a name="l00118"></a>00118 <a name="l00119"></a>00119 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#a694f6f127e048521451f931174a6e140" title="x, y, width, height of the child (relative to its frame)">child_rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> + 2 + 2; <a name="l00120"></a>00120 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#a694f6f127e048521451f931174a6e140" title="x, y, width, height of the child (relative to its frame)">child_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="l00121"></a>00121 <a name="l00122"></a>00122 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"copying size from tiling (%d, %d) size (%d, %d)\n"</span>, client-><a class="code" href="a00007.html#a7af57ac287f68a6e55b9279b720d7491" title="Position in floating mode and in tiling mode are saved separately.">floating_rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, client-><a class="code" href="a00007.html#a7af57ac287f68a6e55b9279b720d7491" title="Position in floating mode and in tiling mode are saved separately.">floating_rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>, <a name="l00123"></a>00123 client-><a class="code" href="a00007.html#a7af57ac287f68a6e55b9279b720d7491" title="Position in floating mode and in tiling mode are saved separately.">floating_rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, client-><a class="code" href="a00007.html#a7af57ac287f68a6e55b9279b720d7491" title="Position in floating mode and in tiling mode are saved separately.">floating_rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>); <a name="l00124"></a>00124 } <span class="keywordflow">else</span> { <a name="l00125"></a>00125 <span class="comment">/* If the client was already in floating before we restore the old position / size */</span> <a name="l00126"></a>00126 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"using: (%d, %d) size (%d, %d)\n"</span>, client-><a class="code" href="a00007.html#a7af57ac287f68a6e55b9279b720d7491" title="Position in floating mode and in tiling mode are saved separately.">floating_rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, client-><a class="code" href="a00007.html#a7af57ac287f68a6e55b9279b720d7491" title="Position in floating mode and in tiling mode are saved separately.">floating_rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>, <a name="l00127"></a>00127 client-><a class="code" href="a00007.html#a7af57ac287f68a6e55b9279b720d7491" title="Position in floating mode and in tiling mode are saved separately.">floating_rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, client-><a class="code" href="a00007.html#a7af57ac287f68a6e55b9279b720d7491" title="Position in floating mode and in tiling mode are saved separately.">floating_rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>); <a name="l00128"></a>00128 memcpy(&(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>), &(client-><a class="code" href="a00007.html#a7af57ac287f68a6e55b9279b720d7491" title="Position in floating mode and in tiling mode are saved separately.">floating_rect</a>), <span class="keyword">sizeof</span>(<a class="code" href="a00020.html" title="Stores a rectangle, for example the size of a window, the child window etc.">Rect</a>)); <a name="l00129"></a>00129 } <a name="l00130"></a>00130 <a name="l00131"></a>00131 <span class="comment">/* Raise the client */</span> <a name="l00132"></a>00132 <a class="code" href="a00079.html#a6ea5ab6082e87ce76340a38034f7b513" title="Raises the given window (typically client-&gt;frame) above all other windows.">xcb_raise_window</a>(conn, client-><a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>); <a name="l00133"></a>00133 <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="l00134"></a>00134 <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="l00135"></a>00135 <span class="comment">/* redecorate_window flushes */</span> <a name="l00136"></a>00136 <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>(conn, client); <a name="l00137"></a>00137 <a name="l00138"></a>00138 <span class="comment">/* Re-render the tiling layout of this container */</span> <a name="l00139"></a>00139 <a class="code" href="a00069.html#a2a1fee0aebdaf2497fb52ea57a1033a4" title="Renders the given container.">render_container</a>(conn, con); <a name="l00140"></a>00140 xcb_flush(conn); <a name="l00141"></a>00141 } <a name="l00142"></a>00142 <a name="l00143"></a>00143 <span class="comment">/*</span> <a name="l00144"></a>00144 <span class="comment"> * Removes the floating client from its workspace and attaches it to the new workspace.</span> <a name="l00145"></a>00145 <span class="comment"> * This is centralized here because it may happen if you move it via keyboard and</span> <a name="l00146"></a>00146 <span class="comment"> * if you move it using your mouse.</span> <a name="l00147"></a>00147 <span class="comment"> *</span> <a name="l00148"></a>00148 <span class="comment"> */</span> <a name="l00149"></a><a class="code" href="a00039.html#a551a7fd238fea8026df7a07b503f1bef">00149</a> <span class="keywordtype">void</span> <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>(<a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client, <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *new_workspace) { <a name="l00150"></a>00150 <span class="comment">/* Remove from focus stack and list of floating clients */</span> <a name="l00151"></a>00151 <a class="code" href="a00047.html#a9c7950d61593ab9198524fca81b17ab0">SLIST_REMOVE</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), client, <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a>, focus_clients); <a name="l00152"></a>00152 <a class="code" href="a00047.html#aaae87ca18c28066e1a96221e762d1209">TAILQ_REMOVE</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>->floating_clients), client, floating_clients); <a name="l00153"></a>00153 <a name="l00154"></a>00154 <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#a918ace3a3d2f03c58ec8fa05ac97275e" title="the client who is started in fullscreen mode on this workspace, NULL if there is...">fullscreen_client</a> == client) <a name="l00155"></a>00155 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#a918ace3a3d2f03c58ec8fa05ac97275e" title="the client who is started in fullscreen mode on this workspace, NULL if there is...">fullscreen_client</a> = NULL; <a name="l00156"></a>00156 <a name="l00157"></a>00157 <span class="comment">/* Insert into destination focus stack and list of floating clients */</span> <a name="l00158"></a>00158 client-><a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a> = new_workspace; <a name="l00159"></a>00159 <a class="code" href="a00047.html#a48df7439e09a419afabdd1f2f8551e73">SLIST_INSERT_HEAD</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), client, focus_clients); <a name="l00160"></a>00160 <a class="code" href="a00047.html#a512bee16b46f601078c96c776d2648c3">TAILQ_INSERT_TAIL</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>->floating_clients), client, floating_clients); <a name="l00161"></a>00161 <span class="keywordflow">if</span> (client-><a class="code" href="a00007.html#a9eeeb880b93223456c2eae445beccf94" title="fullscreen is pretty obvious">fullscreen</a>) <a name="l00162"></a>00162 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#a918ace3a3d2f03c58ec8fa05ac97275e" title="the client who is started in fullscreen mode on this workspace, NULL if there is...">fullscreen_client</a> = client; <a name="l00163"></a>00163 } <a name="l00164"></a>00164 <a name="l00165"></a>00165 <span class="comment">/*</span> <a name="l00166"></a>00166 <span class="comment"> * This is an ugly data structure which we need because there is no standard</span> <a name="l00167"></a>00167 <span class="comment"> * way of having nested functions (only available as a gcc extension at the</span> <a name="l00168"></a>00168 <span class="comment"> * moment, clang doesn’t support it) or blocks (only available as a clang</span> <a name="l00169"></a>00169 <span class="comment"> * extension and only on Mac OS X systems at the moment).</span> <a name="l00170"></a>00170 <span class="comment"> *</span> <a name="l00171"></a>00171 <span class="comment"> */</span> <a name="l00172"></a><a class="code" href="a00021.html">00172</a> <span class="keyword">struct </span><a class="code" href="a00021.html">resize_callback_params</a> { <a name="l00173"></a><a class="code" href="a00021.html#ad35288eabdfeda5987a47be9656fa5ba">00173</a> <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769a" title="On which border was the dragging initiated?">border_t</a> <a class="code" href="a00021.html#ad35288eabdfeda5987a47be9656fa5ba">border</a>; <a name="l00174"></a><a class="code" href="a00021.html#a0eac9fe2ffcfcb0832aa21a064dfe8fe">00174</a> xcb_button_press_event_t *<a class="code" href="a00021.html#a0eac9fe2ffcfcb0832aa21a064dfe8fe">event</a>; <a name="l00175"></a>00175 }; <a name="l00176"></a>00176 <a name="l00177"></a><a class="code" href="a00066.html#a14622d3948077559dc238d42578111fb">00177</a> <a class="code" href="a00039.html#a1b6cf5fbd1cee4e32a102b1da9b7a0a7" title="Macro to create a callback function for dragging.">DRAGGING_CB</a>(resize_callback) { <a name="l00178"></a>00178 <span class="keyword">struct </span><a class="code" href="a00021.html">resize_callback_params</a> *params = extra; <a name="l00179"></a>00179 xcb_button_press_event_t *<span class="keyword">event</span> = params-><a class="code" href="a00021.html#a0eac9fe2ffcfcb0832aa21a064dfe8fe">event</a>; <a name="l00180"></a>00180 <span class="keywordflow">switch</span> (params-><a class="code" href="a00021.html#ad35288eabdfeda5987a47be9656fa5ba">border</a>) { <a name="l00181"></a>00181 <span class="keywordflow">case</span> <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769aaf0e1382b7cab91ba9c3124607719c841">BORDER_RIGHT</a>: { <a name="l00182"></a>00182 <span class="keywordtype">int</span> new_width = old_rect->width + (new_x - <span class="keyword">event</span>->root_x); <a name="l00183"></a>00183 <span class="keywordflow">if</span> ((new_width < 0) || <a name="l00184"></a>00184 (new_width < <a class="code" href="a00060.html#a5e28f5d4823929a52611f745e41ec3e3" title="See client_min_height.">client_min_width</a>(client) && client->rect.width >= new_width)) <a name="l00185"></a>00185 <span class="keywordflow">return</span>; <a name="l00186"></a>00186 client->rect.width = new_width; <a name="l00187"></a>00187 <span class="keywordflow">break</span>; <a name="l00188"></a>00188 } <a name="l00189"></a>00189 <a name="l00190"></a>00190 <span class="keywordflow">case</span> <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769aa4f7b6a135ac7332d7b666aa49f72b970">BORDER_BOTTOM</a>: { <a name="l00191"></a>00191 <span class="keywordtype">int</span> new_height = old_rect->height + (new_y - <span class="keyword">event</span>->root_y); <a name="l00192"></a>00192 <span class="keywordflow">if</span> ((new_height < 0) || <a name="l00193"></a>00193 (new_height < <a class="code" href="a00060.html#a0c35ae37d3b41c85a9a0797b7578a018" title="Returns the minimum height of a specific window.">client_min_height</a>(client) && client->rect.height >= new_height)) <a name="l00194"></a>00194 <span class="keywordflow">return</span>; <a name="l00195"></a>00195 client->rect.height = old_rect->height + (new_y - <span class="keyword">event</span>->root_y); <a name="l00196"></a>00196 <span class="keywordflow">break</span>; <a name="l00197"></a>00197 } <a name="l00198"></a>00198 <a name="l00199"></a>00199 <span class="keywordflow">case</span> <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769aa74fabb36cb5f0a09955bb37ced6fd0da">BORDER_TOP</a>: { <a name="l00200"></a>00200 <span class="keywordtype">int</span> new_height = old_rect->height + (<span class="keyword">event</span>->root_y - new_y); <a name="l00201"></a>00201 <span class="keywordflow">if</span> ((new_height < 0) || <a name="l00202"></a>00202 (new_height < <a class="code" href="a00060.html#a0c35ae37d3b41c85a9a0797b7578a018" title="Returns the minimum height of a specific window.">client_min_height</a>(client) && client->rect.height >= new_height)) <a name="l00203"></a>00203 <span class="keywordflow">return</span>; <a name="l00204"></a>00204 <a name="l00205"></a>00205 client->rect.y = old_rect->y + (new_y - <span class="keyword">event</span>->root_y); <a name="l00206"></a>00206 client->rect.height = new_height; <a name="l00207"></a>00207 <span class="keywordflow">break</span>; <a name="l00208"></a>00208 } <a name="l00209"></a>00209 <a name="l00210"></a>00210 <span class="keywordflow">case</span> <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769aafc0aeaa77f9200b57bb411a7cdaaee94">BORDER_LEFT</a>: { <a name="l00211"></a>00211 <span class="keywordtype">int</span> new_width = old_rect->width + (<span class="keyword">event</span>->root_x - new_x); <a name="l00212"></a>00212 <span class="keywordflow">if</span> ((new_width < 0) || <a name="l00213"></a>00213 (new_width < <a class="code" href="a00060.html#a5e28f5d4823929a52611f745e41ec3e3" title="See client_min_height.">client_min_width</a>(client) && client->rect.width >= new_width)) <a name="l00214"></a>00214 <span class="keywordflow">return</span>; <a name="l00215"></a>00215 client->rect.x = old_rect->x + (new_x - <span class="keyword">event</span>->root_x); <a name="l00216"></a>00216 client->rect.width = new_width; <a name="l00217"></a>00217 <span class="keywordflow">break</span>; <a name="l00218"></a>00218 } <a name="l00219"></a>00219 } <a name="l00220"></a>00220 <a name="l00221"></a>00221 <span class="comment">/* Push the new position/size to X11 */</span> <a name="l00222"></a>00222 <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="l00223"></a>00223 <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="l00224"></a>00224 xcb_flush(conn); <a name="l00225"></a>00225 } <a name="l00226"></a>00226 <a name="l00227"></a>00227 <a name="l00228"></a>00228 <span class="comment">/*</span> <a name="l00229"></a>00229 <span class="comment"> * Called whenever the user clicks on a border (not the titlebar!) of a floating window.</span> <a name="l00230"></a>00230 <span class="comment"> * Determines on which border the user clicked and launches the drag_pointer function</span> <a name="l00231"></a>00231 <span class="comment"> * with the resize_callback.</span> <a name="l00232"></a>00232 <span class="comment"> *</span> <a name="l00233"></a>00233 <span class="comment"> */</span> <a name="l00234"></a><a class="code" href="a00039.html#a45f1fa09855e7264dba2e040b1a7eb7a">00234</a> <span class="keywordtype">int</span> <a class="code" href="a00066.html#a45f1fa09855e7264dba2e040b1a7eb7a" title="Called whenever the user clicks on a border (not the titlebar!) of a floating window...">floating_border_click</a>(xcb_connection_t *conn, <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client, xcb_button_press_event_t *<a class="code" href="a00021.html#a0eac9fe2ffcfcb0832aa21a064dfe8fe">event</a>) { <a name="l00235"></a>00235 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"floating border click\n"</span>); <a name="l00236"></a>00236 <a name="l00237"></a>00237 <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769a" title="On which border was the dragging initiated?">border_t</a> <a class="code" href="a00021.html#ad35288eabdfeda5987a47be9656fa5ba">border</a>; <a name="l00238"></a>00238 <a name="l00239"></a>00239 <span class="keywordflow">if</span> (event->event_y < 2) <a name="l00240"></a>00240 border = <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769aa74fabb36cb5f0a09955bb37ced6fd0da">BORDER_TOP</a>; <a name="l00241"></a>00241 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (event->event_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#a0a074c07d144c9647e3eb60ef54f88c3">height</a> - 2)) <a name="l00242"></a>00242 border = <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769aa4f7b6a135ac7332d7b666aa49f72b970">BORDER_BOTTOM</a>; <a name="l00243"></a>00243 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (event->event_x <= 2) <a name="l00244"></a>00244 border = <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769aafc0aeaa77f9200b57bb411a7cdaaee94">BORDER_LEFT</a>; <a name="l00245"></a>00245 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (event->event_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> - 2)) <a name="l00246"></a>00246 border = <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769aaf0e1382b7cab91ba9c3124607719c841">BORDER_RIGHT</a>; <a name="l00247"></a>00247 <span class="keywordflow">else</span> { <a name="l00248"></a>00248 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Not on any border, not doing anything.\n"</span>); <a name="l00249"></a>00249 <span class="keywordflow">return</span> 1; <a name="l00250"></a>00250 } <a name="l00251"></a>00251 <a name="l00252"></a>00252 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"border = %d\n"</span>, border); <a name="l00253"></a>00253 <a name="l00254"></a>00254 <span class="keyword">struct </span><a class="code" href="a00021.html">resize_callback_params</a> params = { border, <span class="keyword">event</span> }; <a name="l00255"></a>00255 <a name="l00256"></a>00256 <a class="code" href="a00066.html#a74161272ece36a35ab930bf32fb5027e" title="This function grabs your pointer and lets you drag stuff around (borders).">drag_pointer</a>(conn, client, event, XCB_NONE, border, resize_callback, &params); <a name="l00257"></a>00257 <a name="l00258"></a>00258 <span class="keywordflow">return</span> 1; <a name="l00259"></a>00259 } <a name="l00260"></a>00260 <a name="l00261"></a><a class="code" href="a00066.html#a7919029061db2b20e012b8733e8e96fd">00261</a> <a class="code" href="a00039.html#a1b6cf5fbd1cee4e32a102b1da9b7a0a7" title="Macro to create a callback function for dragging.">DRAGGING_CB</a>(drag_window_callback) { <a name="l00262"></a>00262 <span class="keyword">struct </span>xcb_button_press_event_t *<span class="keyword">event</span> = extra; <a name="l00263"></a>00263 <a name="l00264"></a>00264 <span class="comment">/* Reposition the client correctly while moving */</span> <a name="l00265"></a>00265 client->rect.x = old_rect->x + (new_x - <span class="keyword">event</span>->root_x); <a name="l00266"></a>00266 client->rect.y = old_rect->y + (new_y - <span class="keyword">event</span>->root_y); <a name="l00267"></a>00267 <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="l00268"></a>00268 <span class="comment">/* Because reposition_client does not send a faked configure event (only resize does),</span> <a name="l00269"></a>00269 <span class="comment"> * we need to initiate that on our own */</span> <a name="l00270"></a>00270 <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="l00271"></a>00271 <span class="comment">/* fake_absolute_configure_notify flushes */</span> <a name="l00272"></a>00272 } <a name="l00273"></a>00273 <a name="l00274"></a>00274 <span class="comment">/*</span> <a name="l00275"></a>00275 <span class="comment"> * Called when the user clicked on the titlebar of a floating window.</span> <a name="l00276"></a>00276 <span class="comment"> * Calls the drag_pointer function with the drag_window callback</span> <a name="l00277"></a>00277 <span class="comment"> *</span> <a name="l00278"></a>00278 <span class="comment"> */</span> <a name="l00279"></a><a class="code" href="a00039.html#ade1139a34e35e87474ee701231d57945">00279</a> <span class="keywordtype">void</span> <a class="code" href="a00066.html#ade1139a34e35e87474ee701231d57945" title="Called when the user clicked on the titlebar of a floating window.">floating_drag_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_button_press_event_t *event) { <a name="l00280"></a>00280 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"floating_drag_window\n"</span>); <a name="l00281"></a>00281 <a name="l00282"></a>00282 <a class="code" href="a00066.html#a74161272ece36a35ab930bf32fb5027e" title="This function grabs your pointer and lets you drag stuff around (borders).">drag_pointer</a>(conn, client, event, XCB_NONE, <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769aa74fabb36cb5f0a09955bb37ced6fd0da">BORDER_TOP</a> <span class="comment">/* irrelevant */</span>, drag_window_callback, event); <a name="l00283"></a>00283 } <a name="l00284"></a>00284 <a name="l00285"></a>00285 <span class="comment">/*</span> <a name="l00286"></a>00286 <span class="comment"> * This is an ugly data structure which we need because there is no standard</span> <a name="l00287"></a>00287 <span class="comment"> * way of having nested functions (only available as a gcc extension at the</span> <a name="l00288"></a>00288 <span class="comment"> * moment, clang doesn’t support it) or blocks (only available as a clang</span> <a name="l00289"></a>00289 <span class="comment"> * extension and only on Mac OS X systems at the moment).</span> <a name="l00290"></a>00290 <span class="comment"> *</span> <a name="l00291"></a>00291 <span class="comment"> */</span> <a name="l00292"></a><a class="code" href="a00022.html">00292</a> <span class="keyword">struct </span><a class="code" href="a00022.html">resize_window_callback_params</a> { <a name="l00293"></a><a class="code" href="a00022.html#ad5492f3bc8b794fd99eb8d1b3290511f">00293</a> <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769a" title="On which border was the dragging initiated?">border_t</a> <a class="code" href="a00022.html#ad5492f3bc8b794fd99eb8d1b3290511f">corner</a>; <a name="l00294"></a><a class="code" href="a00022.html#afc1e0277a7a7f5883859abae54dbdfcd">00294</a> <span class="keywordtype">bool</span> <a class="code" href="a00022.html#afc1e0277a7a7f5883859abae54dbdfcd">proportional</a>; <a name="l00295"></a><a class="code" href="a00022.html#ae266eda11403781f4b0c20c6741b6dd4">00295</a> xcb_button_press_event_t *<a class="code" href="a00022.html#ae266eda11403781f4b0c20c6741b6dd4">event</a>; <a name="l00296"></a>00296 }; <a name="l00297"></a>00297 <a name="l00298"></a><a class="code" href="a00066.html#a8924f88e2df8f159386e667b7255f69e">00298</a> <a class="code" href="a00039.html#a1b6cf5fbd1cee4e32a102b1da9b7a0a7" title="Macro to create a callback function for dragging.">DRAGGING_CB</a>(resize_window_callback) { <a name="l00299"></a>00299 <span class="keyword">struct </span><a class="code" href="a00022.html">resize_window_callback_params</a> *params = extra; <a name="l00300"></a>00300 xcb_button_press_event_t *<span class="keyword">event</span> = params-><a class="code" href="a00022.html#ae266eda11403781f4b0c20c6741b6dd4">event</a>; <a name="l00301"></a>00301 <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769a" title="On which border was the dragging initiated?">border_t</a> <a class="code" href="a00022.html#ad5492f3bc8b794fd99eb8d1b3290511f">corner</a> = params-><a class="code" href="a00022.html#ad5492f3bc8b794fd99eb8d1b3290511f">corner</a>; <a name="l00302"></a>00302 <a name="l00303"></a>00303 int32_t dest_x = client->rect.x; <a name="l00304"></a>00304 int32_t dest_y = client->rect.y; <a name="l00305"></a>00305 uint32_t dest_width; <a name="l00306"></a>00306 uint32_t dest_height; <a name="l00307"></a>00307 <a name="l00308"></a>00308 <span class="keywordtype">double</span> ratio = (double) old_rect->width / old_rect->height; <a name="l00309"></a>00309 <a name="l00310"></a>00310 <span class="comment">/* First guess: We resize by exactly the amount the mouse moved,</span> <a name="l00311"></a>00311 <span class="comment"> * taking into account in which corner the client was grabbed */</span> <a name="l00312"></a>00312 if (corner & <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769aafc0aeaa77f9200b57bb411a7cdaaee94">BORDER_LEFT</a>) <a name="l00313"></a>00313 dest_width = old_rect->width - (new_x - <span class="keyword">event</span>->root_x); <a name="l00314"></a>00314 <span class="keywordflow">else</span> dest_width = old_rect->width + (new_x - <span class="keyword">event</span>->root_x); <a name="l00315"></a>00315 <a name="l00316"></a>00316 <span class="keywordflow">if</span> (corner & <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769aa74fabb36cb5f0a09955bb37ced6fd0da">BORDER_TOP</a>) <a name="l00317"></a>00317 dest_height = old_rect->height - (new_y - <span class="keyword">event</span>->root_y); <a name="l00318"></a>00318 <span class="keywordflow">else</span> dest_height = old_rect->height + (new_y - <span class="keyword">event</span>->root_y); <a name="l00319"></a>00319 <a name="l00320"></a>00320 <span class="comment">/* Obey minimum window size */</span> <a name="l00321"></a>00321 dest_width = <a class="code" href="a00077.html#af082905f7eac6d03e92015146bbc1925">max</a>(dest_width, <a class="code" href="a00060.html#a5e28f5d4823929a52611f745e41ec3e3" title="See client_min_height.">client_min_width</a>(client)); <a name="l00322"></a>00322 dest_height = <a class="code" href="a00077.html#af082905f7eac6d03e92015146bbc1925">max</a>(dest_height, <a class="code" href="a00060.html#a0c35ae37d3b41c85a9a0797b7578a018" title="Returns the minimum height of a specific window.">client_min_height</a>(client)); <a name="l00323"></a>00323 <a name="l00324"></a>00324 <span class="comment">/* User wants to keep proportions, so we may have to adjust our values */</span> <a name="l00325"></a>00325 <span class="keywordflow">if</span> (params-><a class="code" href="a00022.html#afc1e0277a7a7f5883859abae54dbdfcd">proportional</a>) { <a name="l00326"></a>00326 dest_width = <a class="code" href="a00077.html#af082905f7eac6d03e92015146bbc1925">max</a>(dest_width, (<span class="keywordtype">int</span>) (dest_height * ratio)); <a name="l00327"></a>00327 dest_height = <a class="code" href="a00077.html#af082905f7eac6d03e92015146bbc1925">max</a>(dest_height, (<span class="keywordtype">int</span>) (dest_width / ratio)); <a name="l00328"></a>00328 } <a name="l00329"></a>00329 <a name="l00330"></a>00330 <span class="comment">/* If not the lower right corner is grabbed, we must also reposition</span> <a name="l00331"></a>00331 <span class="comment"> * the client by exactly the amount we resized it */</span> <a name="l00332"></a>00332 <span class="keywordflow">if</span> (corner & BORDER_LEFT) <a name="l00333"></a>00333 dest_x = old_rect->x + (old_rect->width - dest_width); <a name="l00334"></a>00334 <a name="l00335"></a>00335 <span class="keywordflow">if</span> (corner & BORDER_TOP) <a name="l00336"></a>00336 dest_y = old_rect->y + (old_rect->height - dest_height); <a name="l00337"></a>00337 <a name="l00338"></a>00338 client->rect = (<a class="code" href="a00020.html" title="Stores a rectangle, for example the size of a window, the child window etc.">Rect</a>) { dest_x, dest_y, dest_width, dest_height }; <a name="l00339"></a>00339 <a name="l00340"></a>00340 <span class="comment">/* resize_client flushes */</span> <a name="l00341"></a>00341 <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="l00342"></a>00342 } <a name="l00343"></a>00343 <a name="l00344"></a>00344 <span class="comment">/*</span> <a name="l00345"></a>00345 <span class="comment"> * Called when the user clicked on a floating window while holding the</span> <a name="l00346"></a>00346 <span class="comment"> * floating_modifier and the right mouse button.</span> <a name="l00347"></a>00347 <span class="comment"> * Calls the drag_pointer function with the resize_window callback</span> <a name="l00348"></a>00348 <span class="comment"> *</span> <a name="l00349"></a>00349 <span class="comment"> */</span> <a name="l00350"></a><a class="code" href="a00039.html#a7ad8b1f1b348648ed8d56facc5a1ccdb">00350</a> <span class="keywordtype">void</span> <a class="code" href="a00066.html#a7ad8b1f1b348648ed8d56facc5a1ccdb" title="Called when the user clicked on a floating window while holding the floating_modifier...">floating_resize_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="l00351"></a>00351 <span class="keywordtype">bool</span> <a class="code" href="a00022.html#afc1e0277a7a7f5883859abae54dbdfcd">proportional</a>, xcb_button_press_event_t *<a class="code" href="a00022.html#ae266eda11403781f4b0c20c6741b6dd4">event</a>) { <a name="l00352"></a>00352 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"floating_resize_window\n"</span>); <a name="l00353"></a>00353 <a name="l00354"></a>00354 <span class="comment">/* corner saves the nearest corner to the original click. It contains</span> <a name="l00355"></a>00355 <span class="comment"> * a bitmask of the nearest borders (BORDER_LEFT, BORDER_RIGHT, …) */</span> <a name="l00356"></a>00356 <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769a" title="On which border was the dragging initiated?">border_t</a> <a class="code" href="a00022.html#ad5492f3bc8b794fd99eb8d1b3290511f">corner</a> = 0; <a name="l00357"></a>00357 <a name="l00358"></a>00358 <span class="keywordflow">if</span> (event->event_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> / 2)) <a name="l00359"></a>00359 corner |= <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769aafc0aeaa77f9200b57bb411a7cdaaee94">BORDER_LEFT</a>; <a name="l00360"></a>00360 <span class="keywordflow">else</span> corner |= <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769aaf0e1382b7cab91ba9c3124607719c841">BORDER_RIGHT</a>; <a name="l00361"></a>00361 <a name="l00362"></a>00362 <span class="keywordflow">if</span> (event->event_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#a0a074c07d144c9647e3eb60ef54f88c3">height</a> / 2)) <a name="l00363"></a>00363 corner |= <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769aa74fabb36cb5f0a09955bb37ced6fd0da">BORDER_TOP</a>; <a name="l00364"></a>00364 <span class="keywordflow">else</span> corner |= <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769aaf0e1382b7cab91ba9c3124607719c841">BORDER_RIGHT</a>; <a name="l00365"></a>00365 <a name="l00366"></a>00366 <span class="keyword">struct </span><a class="code" href="a00022.html">resize_window_callback_params</a> params = { corner, proportional, <span class="keyword">event</span> }; <a name="l00367"></a>00367 <a name="l00368"></a>00368 <a class="code" href="a00066.html#a74161272ece36a35ab930bf32fb5027e" title="This function grabs your pointer and lets you drag stuff around (borders).">drag_pointer</a>(conn, client, event, XCB_NONE, <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769aa74fabb36cb5f0a09955bb37ced6fd0da">BORDER_TOP</a> <span class="comment">/* irrelevant */</span>, resize_window_callback, &params); <a name="l00369"></a>00369 } <a name="l00370"></a>00370 <a name="l00371"></a>00371 <a name="l00372"></a>00372 <span class="comment">/*</span> <a name="l00373"></a>00373 <span class="comment"> * This function grabs your pointer and lets you drag stuff around (borders).</span> <a name="l00374"></a>00374 <span class="comment"> * Every time you move your mouse, an XCB_MOTION_NOTIFY event will be received</span> <a name="l00375"></a>00375 <span class="comment"> * and the given callback will be called with the parameters specified (client,</span> <a name="l00376"></a>00376 <span class="comment"> * border on which the click originally was), the original rect of the client,</span> <a name="l00377"></a>00377 <span class="comment"> * the event and the new coordinates (x, y).</span> <a name="l00378"></a>00378 <span class="comment"> *</span> <a name="l00379"></a>00379 <span class="comment"> */</span> <a name="l00380"></a><a class="code" href="a00039.html#a74161272ece36a35ab930bf32fb5027e">00380</a> <span class="keywordtype">void</span> <a class="code" href="a00066.html#a74161272ece36a35ab930bf32fb5027e" title="This function grabs your pointer and lets you drag stuff around (borders).">drag_pointer</a>(xcb_connection_t *conn, <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client, xcb_button_press_event_t *<a class="code" href="a00022.html#ae266eda11403781f4b0c20c6741b6dd4">event</a>, <a name="l00381"></a>00381 xcb_window_t confine_to, <a class="code" href="a00039.html#aacfe70f93afb3b5a074ff4d6f726769a" title="On which border was the dragging initiated?">border_t</a> border, <a class="code" href="a00039.html#abc0e74d417ed2037efb335d66e644454" title="Callback for dragging.">callback_t</a> callback, <span class="keywordtype">void</span> *extra) { <a name="l00382"></a>00382 xcb_window_t <a class="code" href="a00071.html#a768f07da9e11ab88732a5c550ff49257">root</a> = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root; <a name="l00383"></a>00383 uint32_t new_x, new_y; <a name="l00384"></a>00384 <a class="code" href="a00020.html" title="Stores a rectangle, for example the size of a window, the child window etc.">Rect</a> old_rect; <a name="l00385"></a>00385 <span class="keywordflow">if</span> (client != NULL) <a name="l00386"></a>00386 memcpy(&old_rect, &(client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>), <span class="keyword">sizeof</span>(<a class="code" href="a00020.html" title="Stores a rectangle, for example the size of a window, the child window etc.">Rect</a>)); <a name="l00387"></a>00387 <a name="l00388"></a>00388 <span class="comment">/* Grab the pointer */</span> <a name="l00389"></a>00389 <span class="comment">/* TODO: returncode */</span> <a name="l00390"></a>00390 xcb_grab_pointer(conn, <a name="l00391"></a>00391 <span class="keyword">false</span>, <span class="comment">/* get all pointer events specified by the following mask */</span> <a name="l00392"></a>00392 root, <span class="comment">/* grab the root window */</span> <a name="l00393"></a>00393 XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION, <span class="comment">/* which events to let through */</span> <a name="l00394"></a>00394 XCB_GRAB_MODE_ASYNC, <span class="comment">/* pointer events should continue as normal */</span> <a name="l00395"></a>00395 XCB_GRAB_MODE_ASYNC, <span class="comment">/* keyboard mode */</span> <a name="l00396"></a>00396 confine_to, <span class="comment">/* confine_to = in which window should the cursor stay */</span> <a name="l00397"></a>00397 XCB_NONE, <span class="comment">/* don’t display a special cursor */</span> <a name="l00398"></a>00398 XCB_CURRENT_TIME); <a name="l00399"></a>00399 <a name="l00400"></a>00400 <span class="comment">/* Go into our own event loop */</span> <a name="l00401"></a>00401 xcb_flush(conn); <a name="l00402"></a>00402 <a name="l00403"></a>00403 xcb_generic_event_t *inside_event, *last_motion_notify = NULL; <a name="l00404"></a>00404 <span class="comment">/* I’ve always wanted to have my own eventhandler… */</span> <a name="l00405"></a>00405 <span class="keywordflow">while</span> ((inside_event = xcb_wait_for_event(conn))) { <a name="l00406"></a>00406 <span class="comment">/* We now handle all events we can get using xcb_poll_for_event */</span> <a name="l00407"></a>00407 <span class="keywordflow">do</span> { <a name="l00408"></a>00408 <span class="comment">/* Same as get_event_handler in xcb */</span> <a name="l00409"></a>00409 <span class="keywordtype">int</span> nr = inside_event->response_type; <a name="l00410"></a>00410 <span class="keywordflow">if</span> (nr == 0) { <a name="l00411"></a>00411 <span class="comment">/* An error occured */</span> <a name="l00412"></a>00412 <a class="code" href="a00064.html#a5f13dbbbc2fe5c143d138bba3b873b53">handle_event</a>(NULL, conn, inside_event); <a name="l00413"></a>00413 free(inside_event); <a name="l00414"></a>00414 <span class="keywordflow">continue</span>; <a name="l00415"></a>00415 } <a name="l00416"></a>00416 assert(nr < 256); <a name="l00417"></a>00417 nr &= XCB_EVENT_RESPONSE_TYPE_MASK; <a name="l00418"></a>00418 assert(nr >= 2); <a name="l00419"></a>00419 <a name="l00420"></a>00420 <span class="keywordflow">switch</span> (nr) { <a name="l00421"></a>00421 <span class="keywordflow">case</span> XCB_BUTTON_RELEASE: <a name="l00422"></a>00422 <span class="keywordflow">goto</span> done; <a name="l00423"></a>00423 <a name="l00424"></a>00424 <span class="keywordflow">case</span> XCB_MOTION_NOTIFY: <a name="l00425"></a>00425 <span class="comment">/* motion_notify events are saved for later */</span> <a name="l00426"></a>00426 <a class="code" href="a00052.html#ae88e84de75be0b138a19509d288b4cf4">FREE</a>(last_motion_notify); <a name="l00427"></a>00427 last_motion_notify = inside_event; <a name="l00428"></a>00428 <span class="keywordflow">break</span>; <a name="l00429"></a>00429 <a name="l00430"></a>00430 <span class="keywordflow">case</span> XCB_UNMAP_NOTIFY: <a name="l00431"></a>00431 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Unmap-notify, aborting\n"</span>); <a name="l00432"></a>00432 xcb_event_handle(&<a class="code" href="a00071.html#a123feed3140395e51010f45a3268464c">evenths</a>, inside_event); <a name="l00433"></a>00433 <span class="keywordflow">goto</span> done; <a name="l00434"></a>00434 <a name="l00435"></a>00435 <span class="keywordflow">default</span>: <a name="l00436"></a>00436 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Passing to original handler\n"</span>); <a name="l00437"></a>00437 <span class="comment">/* Use original handler */</span> <a name="l00438"></a>00438 xcb_event_handle(&<a class="code" href="a00071.html#a123feed3140395e51010f45a3268464c">evenths</a>, inside_event); <a name="l00439"></a>00439 <span class="keywordflow">break</span>; <a name="l00440"></a>00440 } <a name="l00441"></a>00441 <span class="keywordflow">if</span> (last_motion_notify != inside_event) <a name="l00442"></a>00442 free(inside_event); <a name="l00443"></a>00443 } <span class="keywordflow">while</span> ((inside_event = xcb_poll_for_event(conn)) != NULL); <a name="l00444"></a>00444 <a name="l00445"></a>00445 <span class="keywordflow">if</span> (last_motion_notify == NULL) <a name="l00446"></a>00446 <span class="keywordflow">continue</span>; <a name="l00447"></a>00447 <a name="l00448"></a>00448 new_x = ((xcb_motion_notify_event_t*)last_motion_notify)->root_x; <a name="l00449"></a>00449 new_y = ((xcb_motion_notify_event_t*)last_motion_notify)->root_y; <a name="l00450"></a>00450 <a name="l00451"></a>00451 callback(conn, client, &old_rect, new_x, new_y, extra); <a name="l00452"></a>00452 <a class="code" href="a00052.html#ae88e84de75be0b138a19509d288b4cf4">FREE</a>(last_motion_notify); <a name="l00453"></a>00453 } <a name="l00454"></a>00454 done: <a name="l00455"></a>00455 xcb_ungrab_pointer(conn, XCB_CURRENT_TIME); <a name="l00456"></a>00456 xcb_flush(conn); <a name="l00457"></a>00457 } <a name="l00458"></a>00458 <a name="l00459"></a>00459 <span class="comment">/*</span> <a name="l00460"></a>00460 <span class="comment"> * Changes focus in the given direction for floating clients.</span> <a name="l00461"></a>00461 <span class="comment"> *</span> <a name="l00462"></a>00462 <span class="comment"> * Changing to the left/right means going to the previous/next floating client,</span> <a name="l00463"></a>00463 <span class="comment"> * changing to top/bottom means cycling through the Z-index.</span> <a name="l00464"></a>00464 <span class="comment"> *</span> <a name="l00465"></a>00465 <span class="comment"> */</span> <a name="l00466"></a><a class="code" href="a00039.html#a8f14283efc52e767d701f71e58c2d8df">00466</a> <span class="keywordtype">void</span> <a class="code" href="a00066.html#a8f14283efc52e767d701f71e58c2d8df" title="Changes focus in the given direction for floating clients.">floating_focus_direction</a>(xcb_connection_t *conn, <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *currently_focused, <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6b">direction_t</a> direction) { <a name="l00467"></a>00467 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"floating focus\n"</span>); <a name="l00468"></a>00468 <a name="l00469"></a>00469 <span class="keywordflow">if</span> (direction == <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6babbac3b12101a9c0c07dbdfcd6bbb212c">D_LEFT</a> || direction == <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6ba07fb0d616c46d4120eb541871fbdfd2d">D_RIGHT</a>) { <a name="l00470"></a>00470 <span class="comment">/* Go to the next/previous floating client */</span> <a name="l00471"></a>00471 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client; <a name="l00472"></a>00472 <a name="l00473"></a>00473 <span class="keywordflow">while</span> ((client = (direction == <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6babbac3b12101a9c0c07dbdfcd6bbb212c">D_LEFT</a> ? <a class="code" href="a00047.html#a524f93a0c21c390683fab4c27e840a10">TAILQ_PREV</a>(currently_focused, floating_clients_head, floating_clients) : <a name="l00474"></a>00474 <a class="code" href="a00047.html#abd57fe9bdea6007a602f8c7d61bd5265">TAILQ_NEXT</a>(currently_focused, floating_clients))) != <a name="l00475"></a>00475 <a class="code" href="a00047.html#a4322b8461a6ab7632435ff4f57bb3a2e">TAILQ_END</a>(&(currently_focused-><a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a>->floating_clients))) { <a name="l00476"></a>00476 <span class="keywordflow">if</span> (!client-><a class="code" href="a00007.html#ad5e886955e668cc51fbb17acb2871cea" title="floating? (= not in tiling layout) This cannot be simply a bool because we want to...">floating</a>) <a name="l00477"></a>00477 <span class="keywordflow">continue</span>; <a name="l00478"></a>00478 <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="l00479"></a>00479 <span class="keywordflow">return</span>; <a name="l00480"></a>00480 } <a name="l00481"></a>00481 } <a name="l00482"></a>00482 } <a name="l00483"></a>00483 <a name="l00484"></a>00484 <span class="comment">/*</span> <a name="l00485"></a>00485 <span class="comment"> * Moves the client 10px to the specified direction.</span> <a name="l00486"></a>00486 <span class="comment"> *</span> <a name="l00487"></a>00487 <span class="comment"> */</span> <a name="l00488"></a><a class="code" href="a00039.html#aa4826c9c64505152ecccceec17ceabf2">00488</a> <span class="keywordtype">void</span> <a class="code" href="a00066.html#aa4826c9c64505152ecccceec17ceabf2" title="Moves the client 10px to the specified direction.">floating_move</a>(xcb_connection_t *conn, <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *currently_focused, <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6b">direction_t</a> direction) { <a name="l00489"></a>00489 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"floating move\n"</span>); <a name="l00490"></a>00490 <a name="l00491"></a>00491 <span class="keywordflow">if</span> (currently_focused-><a class="code" href="a00007.html#a9eeeb880b93223456c2eae445beccf94" title="fullscreen is pretty obvious">fullscreen</a>) { <a name="l00492"></a>00492 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Cannot move fullscreen windows\n"</span>); <a name="l00493"></a>00493 <span class="keywordflow">return</span>; <a name="l00494"></a>00494 } <a name="l00495"></a>00495 <a name="l00496"></a>00496 <a class="code" href="a00020.html" title="Stores a rectangle, for example the size of a window, the child window etc.">Rect</a> destination = currently_focused-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>; <a name="l00497"></a>00497 <a class="code" href="a00020.html" title="Stores a rectangle, for example the size of a window, the child window etc.">Rect</a> *screen = &(currently_focused-><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 class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>); <a name="l00498"></a>00498 <a name="l00499"></a>00499 <span class="keywordflow">switch</span> (direction) { <a name="l00500"></a>00500 <span class="keywordflow">case</span> <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6babbac3b12101a9c0c07dbdfcd6bbb212c">D_LEFT</a>: <a name="l00501"></a>00501 destination.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> -= 10; <a name="l00502"></a>00502 <span class="keywordflow">break</span>; <a name="l00503"></a>00503 <span class="keywordflow">case</span> <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6ba07fb0d616c46d4120eb541871fbdfd2d">D_RIGHT</a>: <a name="l00504"></a>00504 destination.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> += 10; <a name="l00505"></a>00505 <span class="keywordflow">break</span>; <a name="l00506"></a>00506 <span class="keywordflow">case</span> <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6bae8b5f804952c228061ed205833ae7083">D_UP</a>: <a name="l00507"></a>00507 destination.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> -= 10; <a name="l00508"></a>00508 <span class="keywordflow">break</span>; <a name="l00509"></a>00509 <span class="keywordflow">case</span> <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6baee5b9399d89b358fa6fb0adef67d3a4b">D_DOWN</a>: <a name="l00510"></a>00510 destination.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> += 10; <a name="l00511"></a>00511 <span class="keywordflow">break</span>; <a name="l00512"></a>00512 <span class="comment">/* to make static analyzers happy */</span> <a name="l00513"></a>00513 <span class="keywordflow">default</span>: <a name="l00514"></a>00514 <span class="keywordflow">break</span>; <a name="l00515"></a>00515 } <a name="l00516"></a>00516 <a name="l00517"></a>00517 <span class="comment">/* Prevent windows from vanishing completely */</span> <a name="l00518"></a>00518 <span class="keywordflow">if</span> ((int32_t)(destination.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> + destination.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> - 5) <= (int32_t)screen-><a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> || <a name="l00519"></a>00519 (int32_t)(destination.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> + 5) >= (int32_t)(screen-><a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> + screen-><a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>) || <a name="l00520"></a>00520 (int32_t)(destination.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> + destination.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> - 5) <= (int32_t)screen-><a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> || <a name="l00521"></a>00521 (int32_t)(destination.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> + 5) >= (int32_t)(screen-><a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> + screen-><a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>)) { <a name="l00522"></a>00522 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"boundary check failed, not moving\n"</span>); <a name="l00523"></a>00523 <span class="keywordflow">return</span>; <a name="l00524"></a>00524 } <a name="l00525"></a>00525 <a name="l00526"></a>00526 currently_focused-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a> = destination; <a name="l00527"></a>00527 <a class="code" href="a00069.html#a1d68fface3cf11ff882c23a5bfa586ab" title="Pushes the client’s x and y coordinates to X11.">reposition_client</a>(conn, currently_focused); <a name="l00528"></a>00528 <a name="l00529"></a>00529 <span class="comment">/* Because reposition_client does not send a faked configure event (only resize does),</span> <a name="l00530"></a>00530 <span class="comment"> * we need to initiate that on our own */</span> <a name="l00531"></a>00531 <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, currently_focused); <a name="l00532"></a>00532 <span class="comment">/* fake_absolute_configure_notify flushes */</span> <a name="l00533"></a>00533 } <a name="l00534"></a>00534 <a name="l00535"></a>00535 <span class="comment">/*</span> <a name="l00536"></a>00536 <span class="comment"> * Hides all floating clients (or show them if they are currently hidden) on</span> <a name="l00537"></a>00537 <span class="comment"> * the specified workspace.</span> <a name="l00538"></a>00538 <span class="comment"> *</span> <a name="l00539"></a>00539 <span class="comment"> */</span> <a name="l00540"></a><a class="code" href="a00039.html#a4616d049f3145ecee455c2d697864596">00540</a> <span class="keywordtype">void</span> <a class="code" href="a00066.html#a4616d049f3145ecee455c2d697864596" title="Hides all floating clients (or show them if they are currently hidden) on the specified...">floating_toggle_hide</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) { <a name="l00541"></a>00541 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client; <a name="l00542"></a>00542 <a name="l00543"></a>00543 workspace-><a class="code" href="a00025.html#a5efdecde018d10414e6f740573b2a9fb" title="Are the floating clients on this workspace currently hidden?">floating_hidden</a> = !workspace-><a class="code" href="a00025.html#a5efdecde018d10414e6f740573b2a9fb" title="Are the floating clients on this workspace currently hidden?">floating_hidden</a>; <a name="l00544"></a>00544 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"floating_hidden is now: %d\n"</span>, workspace-><a class="code" href="a00025.html#a5efdecde018d10414e6f740573b2a9fb" title="Are the floating clients on this workspace currently hidden?">floating_hidden</a>); <a name="l00545"></a>00545 <a class="code" href="a00047.html#a16e5fc168e7f3494d4b1df54447d871e">TAILQ_FOREACH</a>(client, &(workspace->floating_clients), floating_clients) { <a name="l00546"></a>00546 <span class="keywordflow">if</span> (workspace-><a class="code" href="a00025.html#a5efdecde018d10414e6f740573b2a9fb" title="Are the floating clients on this workspace currently hidden?">floating_hidden</a>) <a name="l00547"></a>00547 <a class="code" href="a00060.html#afe96e905cd2fcc23acf096304000f793" title="Unmap the client, correctly setting any state which is needed.">client_unmap</a>(conn, client); <a name="l00548"></a>00548 <span class="keywordflow">else</span> <a class="code" href="a00060.html#a7f3612a4061bd46213d5e28f0c4d00ee" title="Map the client, correctly restoring any state needed.">client_map</a>(conn, client); <a name="l00549"></a>00549 } <a name="l00550"></a>00550 <a name="l00551"></a>00551 <span class="comment">/* If we just unmapped all floating windows we should ensure that the focus</span> <a name="l00552"></a>00552 <span class="comment"> * is set correctly, that ist, to the first non-floating client in stack */</span> <a name="l00553"></a>00553 <span class="keywordflow">if</span> (workspace-><a class="code" href="a00025.html#a5efdecde018d10414e6f740573b2a9fb" title="Are the floating clients on this workspace currently hidden?">floating_hidden</a>) <a name="l00554"></a>00554 <a class="code" href="a00047.html#a05db87878125c27e3060dd641aa3b0f4">SLIST_FOREACH</a>(client, &(workspace->focus_stack), focus_clients) { <a name="l00555"></a>00555 <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="l00556"></a>00556 <span class="keywordflow">continue</span>; <a name="l00557"></a>00557 <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="l00558"></a>00558 <span class="keywordflow">return</span>; <a name="l00559"></a>00559 } <a name="l00560"></a>00560 <a name="l00561"></a>00561 xcb_flush(conn); <a name="l00562"></a>00562 } </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>