Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > c67c6057ffd14254a26624517a2352e6 > files > 474

i3-doc-3.e-3.bf1.fc14.noarch.rpm

<!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/handlers.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&nbsp;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;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&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<h1>src/handlers.c</h1><a href="a00067.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"> */</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;assert.h&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &lt;time.h&gt;</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;xcb/xcb.h&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;xcb/xcb_atom.h&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;xcb/xcb_icccm.h&gt;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;xcb/randr.h&gt;</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;X11/XKBlib.h&gt;</span>
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 <span class="preprocessor">#include &quot;<a class="code" href="a00041.html">i3.h</a>&quot;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &quot;<a class="code" href="a00037.html">debug.h</a>&quot;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &quot;<a class="code" href="a00051.html">table.h</a>&quot;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &quot;<a class="code" href="a00043.html">layout.h</a>&quot;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &quot;<a class="code" href="a00033.html">commands.h</a>&quot;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &quot;<a class="code" href="a00036.html">data.h</a>&quot;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &quot;<a class="code" href="a00054.html">xcb.h</a>&quot;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &quot;<a class="code" href="a00052.html">util.h</a>&quot;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &quot;<a class="code" href="a00048.html">randr.h</a>&quot;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &quot;<a class="code" href="a00034.html">config.h</a>&quot;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &quot;<a class="code" href="a00047.html">queue.h</a>&quot;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &quot;<a class="code" href="a00049.html">resize.h</a>&quot;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &quot;<a class="code" href="a00032.html">client.h</a>&quot;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &quot;<a class="code" href="a00046.html">manage.h</a>&quot;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &quot;<a class="code" href="a00039.html">floating.h</a>&quot;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &quot;<a class="code" href="a00053.html">workspace.h</a>&quot;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &quot;<a class="code" href="a00044.html">log.h</a>&quot;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include &quot;<a class="code" href="a00035.html">container.h</a>&quot;</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include &quot;<a class="code" href="a00042.html">ipc.h</a>&quot;</span>
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 <span class="comment">/* After mapping/unmapping windows, a notify event is generated. However, we don’t want it,</span>
<a name="l00045"></a>00045 <span class="comment">   since it’d trigger an infinite loop of switching between the different windows when</span>
<a name="l00046"></a>00046 <span class="comment">   changing workspaces */</span>
<a name="l00047"></a><a class="code" href="a00067.html#ad3b7f72327fa9f077af11b656beca636">00047</a> <span class="keyword">static</span> <a class="code" href="a00047.html#a8224e40ea764bc857bab6f6d9c357dd9">SLIST_HEAD</a>(ignore_head, <a class="code" href="a00016.html">Ignore_Event</a>) ignore_events;
<a name="l00048"></a>00048 
<a name="l00049"></a>00049 static <span class="keywordtype">void</span> add_ignore_event(const <span class="keywordtype">int</span> sequence) {
<a name="l00050"></a>00050         <span class="keyword">struct </span><a class="code" href="a00016.html">Ignore_Event</a> *<span class="keyword">event</span> = <a class="code" href="a00077.html#a46c23cb2833f4b674f5cfc977f16b990" title="Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there...">smalloc</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code" href="a00016.html">Ignore_Event</a>));
<a name="l00051"></a>00051 
<a name="l00052"></a>00052         <span class="keyword">event</span>-&gt;sequence = sequence;
<a name="l00053"></a>00053         <span class="keyword">event</span>-&gt;added = time(NULL);
<a name="l00054"></a>00054 
<a name="l00055"></a>00055         <a class="code" href="a00047.html#a48df7439e09a419afabdd1f2f8551e73">SLIST_INSERT_HEAD</a>(&amp;ignore_events, event, ignore_events);
<a name="l00056"></a>00056 }
<a name="l00057"></a>00057 
<a name="l00058"></a>00058 <span class="comment">/*</span>
<a name="l00059"></a>00059 <span class="comment"> * Checks if the given sequence is ignored and returns true if so.</span>
<a name="l00060"></a>00060 <span class="comment"> *</span>
<a name="l00061"></a>00061 <span class="comment"> */</span>
<a name="l00062"></a><a class="code" href="a00067.html#ada290ab6f713974c035649c76e35ca19">00062</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="a00067.html#ada290ab6f713974c035649c76e35ca19">event_is_ignored</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="a00016.html#a000081e19b26d51123d6c78bf5064c1e">sequence</a>) {
<a name="l00063"></a>00063         <span class="keyword">struct </span><a class="code" href="a00016.html">Ignore_Event</a> *event;
<a name="l00064"></a>00064         time_t now = time(NULL);
<a name="l00065"></a>00065         <span class="keywordflow">for</span> (event = <a class="code" href="a00047.html#a91bac7d0d32e3ec56bc579ace45ed8cd">SLIST_FIRST</a>(&amp;ignore_events); <span class="keyword">event</span> != <a class="code" href="a00047.html#a33283f951b262b1ac57d20c0e4e0862c">SLIST_END</a>(&amp;ignore_events);) {
<a name="l00066"></a>00066                 <span class="keywordflow">if</span> ((now - event-&gt;<a class="code" href="a00016.html#a76f213ac7429eab30a1835fe6ed69583">added</a>) &gt; 5) {
<a name="l00067"></a>00067                         <span class="keyword">struct </span><a class="code" href="a00016.html">Ignore_Event</a> *save = event;
<a name="l00068"></a>00068                         <span class="keyword">event</span> = <a class="code" href="a00047.html#a7cd1d5ae37224ecee1f0b831eb73e7f4">SLIST_NEXT</a>(event, ignore_events);
<a name="l00069"></a>00069                         <a class="code" href="a00047.html#a9c7950d61593ab9198524fca81b17ab0">SLIST_REMOVE</a>(&amp;ignore_events, save, <a class="code" href="a00016.html">Ignore_Event</a>, ignore_events);
<a name="l00070"></a>00070                         free(save);
<a name="l00071"></a>00071                 } <span class="keywordflow">else</span> <span class="keyword">event</span> = <a class="code" href="a00047.html#a7cd1d5ae37224ecee1f0b831eb73e7f4">SLIST_NEXT</a>(event, ignore_events);
<a name="l00072"></a>00072         }
<a name="l00073"></a>00073 
<a name="l00074"></a>00074         <a class="code" href="a00047.html#a05db87878125c27e3060dd641aa3b0f4">SLIST_FOREACH</a>(event, &amp;ignore_events, ignore_events) {
<a name="l00075"></a>00075                 <span class="keywordflow">if</span> (event-&gt;<a class="code" href="a00016.html#a000081e19b26d51123d6c78bf5064c1e">sequence</a> == sequence) {
<a name="l00076"></a>00076                         <a class="code" href="a00047.html#a9c7950d61593ab9198524fca81b17ab0">SLIST_REMOVE</a>(&amp;ignore_events, event, <a class="code" href="a00016.html">Ignore_Event</a>, ignore_events);
<a name="l00077"></a>00077                         free(event);
<a name="l00078"></a>00078                         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00079"></a>00079                 }
<a name="l00080"></a>00080         }
<a name="l00081"></a>00081 
<a name="l00082"></a>00082         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00083"></a>00083 }
<a name="l00084"></a>00084 
<a name="l00085"></a>00085 <span class="comment">/*</span>
<a name="l00086"></a>00086 <span class="comment"> * There was a key press. We compare this key code with our bindings table and pass</span>
<a name="l00087"></a>00087 <span class="comment"> * the bound action to parse_command().</span>
<a name="l00088"></a>00088 <span class="comment"> *</span>
<a name="l00089"></a>00089 <span class="comment"> */</span>
<a name="l00090"></a><a class="code" href="a00040.html#abcdedd21ed4dd7e762b2fb2ac49b6527">00090</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#abcdedd21ed4dd7e762b2fb2ac49b6527" title="There was a key press.">handle_key_press</a>(<span class="keywordtype">void</span> *ignored, xcb_connection_t *conn, xcb_key_press_event_t *event) {
<a name="l00091"></a>00091         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Keypress %d, state raw = %d\n&quot;</span>, event-&gt;detail, event-&gt;state);
<a name="l00092"></a>00092 
<a name="l00093"></a>00093         <span class="comment">/* Remove the numlock bit, all other bits are modifiers we can bind to */</span>
<a name="l00094"></a>00094         uint16_t state_filtered = <span class="keyword">event</span>-&gt;state &amp; ~(<a class="code" href="a00054.html#ac430ae06cbf6f5ef252c9ebfca47e644">xcb_numlock_mask</a> | XCB_MOD_MASK_LOCK);
<a name="l00095"></a>00095         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;(removed numlock, state = %d)\n&quot;</span>, state_filtered);
<a name="l00096"></a>00096         <span class="comment">/* Only use the lower 8 bits of the state (modifier masks) so that mouse</span>
<a name="l00097"></a>00097 <span class="comment">         * button masks are filtered out */</span>
<a name="l00098"></a>00098         state_filtered &amp;= 0xFF;
<a name="l00099"></a>00099         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;(removed upper 8 bits, state = %d)\n&quot;</span>, state_filtered);
<a name="l00100"></a>00100 
<a name="l00101"></a>00101         <span class="keywordflow">if</span> (<a class="code" href="a00071.html#a2590f55d5727c7d1cd01ebe7fd94a05d">xkb_current_group</a> == XkbGroup2Index)
<a name="l00102"></a>00102                 state_filtered |= <a class="code" href="a00036.html#a06fc87d81c62e9abb8790b6e5713c55ba059099ea410e7b545a26cefafe4b8358">BIND_MODE_SWITCH</a>;
<a name="l00103"></a>00103 
<a name="l00104"></a>00104         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;(checked mode_switch, state %d)\n&quot;</span>, state_filtered);
<a name="l00105"></a>00105 
<a name="l00106"></a>00106         <span class="comment">/* Find the binding */</span>
<a name="l00107"></a>00107         <a class="code" href="a00003.html" title="Holds a keybinding, consisting of a keycode combined with modifiers and the command...">Binding</a> *bind = <a class="code" href="a00062.html#afc938201ea536eed0f0838bb3c4c5c2c" title="Returns a pointer to the Binding with the specified modifiers and keycode or NULL...">get_binding</a>(state_filtered, event-&gt;detail);
<a name="l00108"></a>00108 
<a name="l00109"></a>00109         <span class="comment">/* No match? Then the user has Mode_switch enabled but does not have a</span>
<a name="l00110"></a>00110 <span class="comment">         * specific keybinding. Fall back to the default keybindings (without</span>
<a name="l00111"></a>00111 <span class="comment">         * Mode_switch). Makes it much more convenient for users of a hybrid</span>
<a name="l00112"></a>00112 <span class="comment">         * layout (like us, ru). */</span>
<a name="l00113"></a>00113         <span class="keywordflow">if</span> (bind == NULL) {
<a name="l00114"></a>00114                 state_filtered &amp;= ~(<a class="code" href="a00036.html#a06fc87d81c62e9abb8790b6e5713c55ba059099ea410e7b545a26cefafe4b8358">BIND_MODE_SWITCH</a>);
<a name="l00115"></a>00115                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;no match, new state_filtered = %d\n&quot;</span>, state_filtered);
<a name="l00116"></a>00116                 <span class="keywordflow">if</span> ((bind = <a class="code" href="a00062.html#afc938201ea536eed0f0838bb3c4c5c2c" title="Returns a pointer to the Binding with the specified modifiers and keycode or NULL...">get_binding</a>(state_filtered, event-&gt;detail)) == NULL) {
<a name="l00117"></a>00117                         <a class="code" href="a00044.html#a6828c68e0feb4b7fdfe0fc3ba9f3038b">ELOG</a>(<span class="stringliteral">&quot;Could not lookup key binding (modifiers %d, keycode %d)\n&quot;</span>,
<a name="l00118"></a>00118                              state_filtered, event-&gt;detail);
<a name="l00119"></a>00119                         <span class="keywordflow">return</span> 1;
<a name="l00120"></a>00120                 }
<a name="l00121"></a>00121         }
<a name="l00122"></a>00122 
<a name="l00123"></a>00123         <a class="code" href="a00061.html#a321767a534b7214d81f4cfeaa4bd0736" title="Parses a command, see file CMDMODE for more information.">parse_command</a>(conn, bind-&gt;<a class="code" href="a00003.html#a6b2981f10cc6dc9d285d8091e7c55812" title="Command, like in command mode.">command</a>);
<a name="l00124"></a>00124         <span class="keywordflow">return</span> 1;
<a name="l00125"></a>00125 }
<a name="l00126"></a>00126 
<a name="l00127"></a>00127 <span class="comment">/*</span>
<a name="l00128"></a>00128 <span class="comment"> * Called with coordinates of an enter_notify event or motion_notify event</span>
<a name="l00129"></a>00129 <span class="comment"> * to check if the user crossed virtual screen boundaries and adjust the</span>
<a name="l00130"></a>00130 <span class="comment"> * current workspace, if so.</span>
<a name="l00131"></a>00131 <span class="comment"> *</span>
<a name="l00132"></a>00132 <span class="comment"> */</span>
<a name="l00133"></a><a class="code" href="a00067.html#a6c2a861a2ecc525852ff09cf4256b6d3">00133</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="a00067.html#a6c2a861a2ecc525852ff09cf4256b6d3">check_crossing_screen_boundary</a>(uint32_t x, uint32_t <a class="code" href="a00068.html#a16e56e533e1eb98fda15e06fdec03da6">y</a>) {
<a name="l00134"></a>00134         <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output;
<a name="l00135"></a>00135 
<a name="l00136"></a>00136         <span class="keywordflow">if</span> ((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>(x, y)) == NULL) {
<a name="l00137"></a>00137                 <a class="code" href="a00044.html#a6828c68e0feb4b7fdfe0fc3ba9f3038b">ELOG</a>(<span class="stringliteral">&quot;ERROR: No such screen\n&quot;</span>);
<a name="l00138"></a>00138                 <span class="keywordflow">return</span>;
<a name="l00139"></a>00139         }
<a name="l00140"></a>00140         <span class="keywordflow">if</span> (output == <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>)
<a name="l00141"></a>00141                 <span class="keywordflow">return</span>;
<a name="l00142"></a>00142 
<a name="l00143"></a>00143         <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#a86fefbdc838f2b5593ea2521378e4ddd" title="These are stored here only while this workspace is _not_ shown (see show_workspace())...">current_row</a> = <a class="code" href="a00076.html#a40ba377d6a3a574ff03b859bc7cdd4b0">current_row</a>;
<a name="l00144"></a>00144         <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#ab683091dfe46963b2dd0761e8e5f9e16" title="These are stored here only while this workspace is _not_ shown (see show_workspace())...">current_col</a> = <a class="code" href="a00076.html#a5f839b3ac61c0771c9f8fbef974afe76">current_col</a>;
<a name="l00145"></a>00145         <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a> = output-&gt;<a class="code" href="a00026.html#a9bcf702b65d8f47f98eafbefff529ffe" title="Current workspace selected on this virtual screen.">current_workspace</a>;
<a name="l00146"></a>00146         <a class="code" href="a00076.html#a40ba377d6a3a574ff03b859bc7cdd4b0">current_row</a> = <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#a86fefbdc838f2b5593ea2521378e4ddd" title="These are stored here only while this workspace is _not_ shown (see show_workspace())...">current_row</a>;
<a name="l00147"></a>00147         <a class="code" href="a00076.html#a5f839b3ac61c0771c9f8fbef974afe76">current_col</a> = <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#ab683091dfe46963b2dd0761e8e5f9e16" title="These are stored here only while this workspace is _not_ shown (see show_workspace())...">current_col</a>;
<a name="l00148"></a>00148         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;We&#39;re now on output %p\n&quot;</span>, output);
<a name="l00149"></a>00149 
<a name="l00150"></a>00150         <span class="comment">/* While usually this function is only called when the user switches</span>
<a name="l00151"></a>00151 <span class="comment">         * to a different output using his mouse (and thus the output is</span>
<a name="l00152"></a>00152 <span class="comment">         * empty), it may be that the following race condition occurs:</span>
<a name="l00153"></a>00153 <span class="comment">         * 1) the user actives a new output (say VGA1).</span>
<a name="l00154"></a>00154 <span class="comment">         * 2) the cursor is sent to the first pixel of the new VGA1, thus</span>
<a name="l00155"></a>00155 <span class="comment">         *    generating an enter_notify for the screen (the enter_notify</span>
<a name="l00156"></a>00156 <span class="comment">         *    is not yet received by i3).</span>
<a name="l00157"></a>00157 <span class="comment">         * 3) i3 requeries screen configuration and maps a workspace onto the</span>
<a name="l00158"></a>00158 <span class="comment">         *    new output.</span>
<a name="l00159"></a>00159 <span class="comment">         * 4) the enter_notify event arrives and c_ws is set to the new</span>
<a name="l00160"></a>00160 <span class="comment">         *    workspace but the existing windows on the new workspace are not</span>
<a name="l00161"></a>00161 <span class="comment">         *    focused.</span>
<a name="l00162"></a>00162 <span class="comment">         *</span>
<a name="l00163"></a>00163 <span class="comment">         * Therefore, we re-set the focus here to be sure it’s correct. */</span>
<a name="l00164"></a>00164         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *first_client = <a class="code" href="a00047.html#a91bac7d0d32e3ec56bc579ace45ed8cd">SLIST_FIRST</a>(&amp;(<a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;focus_stack));
<a name="l00165"></a>00165         <span class="keywordflow">if</span> (first_client != NULL)
<a name="l00166"></a>00166                 <a class="code" href="a00077.html#a323dcf30475bb3bf165100e74d225b48" title="Sets the given client as focused by updating the data structures correctly, updating...">set_focus</a>(<a class="code" href="a00071.html#ada13c42121d64521629e06e7a5e1db16">global_conn</a>, first_client, <span class="keyword">true</span>);
<a name="l00167"></a>00167 }
<a name="l00168"></a>00168 
<a name="l00169"></a>00169 <span class="comment">/*</span>
<a name="l00170"></a>00170 <span class="comment"> * When the user moves the mouse pointer onto a window, this callback gets called.</span>
<a name="l00171"></a>00171 <span class="comment"> *</span>
<a name="l00172"></a>00172 <span class="comment"> */</span>
<a name="l00173"></a><a class="code" href="a00040.html#ade0bc204de173bdbeacb7b10b5631aec">00173</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#ade0bc204de173bdbeacb7b10b5631aec" title="When the user moves the mouse pointer onto a window, this callback gets called.">handle_enter_notify</a>(<span class="keywordtype">void</span> *ignored, xcb_connection_t *conn, xcb_enter_notify_event_t *event) {
<a name="l00174"></a>00174         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;enter_notify for %08x, mode = %d, detail %d, serial %d\n&quot;</span>, event-&gt;event, event-&gt;mode, event-&gt;detail, event-&gt;sequence);
<a name="l00175"></a>00175         <span class="keywordflow">if</span> (event-&gt;mode != XCB_NOTIFY_MODE_NORMAL) {
<a name="l00176"></a>00176                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;This was not a normal notify, ignoring\n&quot;</span>);
<a name="l00177"></a>00177                 <span class="keywordflow">return</span> 1;
<a name="l00178"></a>00178         }
<a name="l00179"></a>00179         <span class="comment">/* Some events are not interesting, because they were not generated actively by the</span>
<a name="l00180"></a>00180 <span class="comment">           user, but by reconfiguration of windows */</span>
<a name="l00181"></a>00181         <span class="keywordflow">if</span> (<a class="code" href="a00067.html#ada290ab6f713974c035649c76e35ca19">event_is_ignored</a>(event-&gt;sequence))
<a name="l00182"></a>00182                 <span class="keywordflow">return</span> 1;
<a name="l00183"></a>00183 
<a name="l00184"></a>00184         <span class="comment">/* This was either a focus for a client’s parent (= titlebar)… */</span>
<a name="l00185"></a>00185         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client = <a class="code" href="a00077.html#ae1529a1d81e2457f9a2402eda35735d7" title="Returns the value of the element of the given keyvalue-table with the given key.">table_get</a>(&amp;<a class="code" href="a00077.html#a38dffc58d761d720f7c63d35f2efd71d">by_parent</a>, event-&gt;event);
<a name="l00186"></a>00186         <span class="comment">/* …or the client itself */</span>
<a name="l00187"></a>00187         <span class="keywordflow">if</span> (client == NULL)
<a name="l00188"></a>00188                 client = <a class="code" href="a00077.html#ae1529a1d81e2457f9a2402eda35735d7" title="Returns the value of the element of the given keyvalue-table with the given key.">table_get</a>(&amp;<a class="code" href="a00077.html#aadfb9c6f265623f83355191df37c86c8">by_child</a>, event-&gt;event);
<a name="l00189"></a>00189 
<a name="l00190"></a>00190         <span class="comment">/* Check for stack windows */</span>
<a name="l00191"></a>00191         <span class="keywordflow">if</span> (client == NULL) {
<a name="l00192"></a>00192                 <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;
<a name="l00193"></a>00193                 <a class="code" href="a00047.html#a05db87878125c27e3060dd641aa3b0f4">SLIST_FOREACH</a>(stack_win, &amp;<a class="code" href="a00071.html#ac38e5cddf6395c52d3755d7b368e4a2b">stack_wins</a>, stack_windows)
<a name="l00194"></a>00194                         <span class="keywordflow">if</span> (stack_win-&gt;<a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a> == event-&gt;event) {
<a name="l00195"></a>00195                                 client = stack_win-&gt;<a class="code" href="a00023.html#ad5f9402c2db288b0762e3a6467257dc8" title="Backpointer to the container this stack window is in.">container</a>-&gt;<a class="code" href="a00013.html#a82d910506b0d788a92ebeeb1d82da75b">currently_focused</a>;
<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 
<a name="l00200"></a>00200 
<a name="l00201"></a>00201         <span class="comment">/* If not, then the user moved his cursor to the root window. In that case, we adjust c_ws */</span>
<a name="l00202"></a>00202         <span class="keywordflow">if</span> (client == NULL) {
<a name="l00203"></a>00203                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Getting screen at %d x %d\n&quot;</span>, event-&gt;root_x, event-&gt;root_y);
<a name="l00204"></a>00204                 <a class="code" href="a00067.html#a6c2a861a2ecc525852ff09cf4256b6d3">check_crossing_screen_boundary</a>(event-&gt;root_x, event-&gt;root_y);
<a name="l00205"></a>00205                 <span class="keywordflow">return</span> 1;
<a name="l00206"></a>00206         }
<a name="l00207"></a>00207 
<a name="l00208"></a>00208         <span class="comment">/* Do plausibility checks: This event may be useless for us if it occurs on a window</span>
<a name="l00209"></a>00209 <span class="comment">           which is in a stacked container but not the focused one */</span>
<a name="l00210"></a>00210         <span class="keywordflow">if</span> (client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a> != NULL &amp;&amp;
<a name="l00211"></a>00211             client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>-&gt;<a class="code" href="a00013.html#ac094306ab77e360742aba04d7cbd0fe6">mode</a> == MODE_STACK &amp;&amp;
<a name="l00212"></a>00212             client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>-&gt;<a class="code" href="a00013.html#a82d910506b0d788a92ebeeb1d82da75b">currently_focused</a> != client) {
<a name="l00213"></a>00213                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Plausibility check says: no\n&quot;</span>);
<a name="l00214"></a>00214                 <span class="keywordflow">return</span> 1;
<a name="l00215"></a>00215         }
<a name="l00216"></a>00216 
<a name="l00217"></a>00217         <span class="keywordflow">if</span> (client-&gt;<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="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a> &amp;&amp; client-&gt;<a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a>-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a> == <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>) {
<a name="l00218"></a>00218                 <span class="comment">/* This can happen when a client gets assigned to a different workspace than</span>
<a name="l00219"></a>00219 <span class="comment">                 * the current one (see src/mainx.c:reparent_window). Shortly after it was created,</span>
<a name="l00220"></a>00220 <span class="comment">                 * an enter_notify will follow. */</span>
<a name="l00221"></a>00221                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;enter_notify for a client on a different workspace but the same screen, ignoring\n&quot;</span>);
<a name="l00222"></a>00222                 <span class="keywordflow">return</span> 1;
<a name="l00223"></a>00223         }
<a name="l00224"></a>00224 
<a name="l00225"></a>00225         <span class="keywordflow">if</span> (!<a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#a5d334bc50cc91b445abe1cff1eddd269" title="By default, focus follows mouse.">disable_focus_follows_mouse</a>)
<a name="l00226"></a>00226                 <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">false</span>);
<a name="l00227"></a>00227 
<a name="l00228"></a>00228         <span class="keywordflow">return</span> 1;
<a name="l00229"></a>00229 }
<a name="l00230"></a>00230 
<a name="l00231"></a>00231 <span class="comment">/*</span>
<a name="l00232"></a>00232 <span class="comment"> * When the user moves the mouse but does not change the active window</span>
<a name="l00233"></a>00233 <span class="comment"> * (e.g. when having no windows opened but moving mouse on the root screen</span>
<a name="l00234"></a>00234 <span class="comment"> * and crossing virtual screen boundaries), this callback gets called.</span>
<a name="l00235"></a>00235 <span class="comment"> *</span>
<a name="l00236"></a>00236 <span class="comment"> */</span>
<a name="l00237"></a><a class="code" href="a00040.html#a23c1d18838f1993a18c1bd891a0fcd3e">00237</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#a23c1d18838f1993a18c1bd891a0fcd3e" title="When the user moves the mouse but does not change the active window (e.g.">handle_motion_notify</a>(<span class="keywordtype">void</span> *ignored, xcb_connection_t *conn, xcb_motion_notify_event_t *event) {
<a name="l00238"></a>00238         <span class="comment">/* Skip events where the pointer was over a child window, we are only</span>
<a name="l00239"></a>00239 <span class="comment">         * interested in events on the root window. */</span>
<a name="l00240"></a>00240         <span class="keywordflow">if</span> (event-&gt;child != 0)
<a name="l00241"></a>00241                 <span class="keywordflow">return</span> 1;
<a name="l00242"></a>00242 
<a name="l00243"></a>00243         <a class="code" href="a00067.html#a6c2a861a2ecc525852ff09cf4256b6d3">check_crossing_screen_boundary</a>(event-&gt;root_x, event-&gt;root_y);
<a name="l00244"></a>00244 
<a name="l00245"></a>00245         <span class="keywordflow">return</span> 1;
<a name="l00246"></a>00246 }
<a name="l00247"></a>00247 
<a name="l00248"></a>00248 <span class="comment">/*</span>
<a name="l00249"></a>00249 <span class="comment"> * Called when the keyboard mapping changes (for example by using Xmodmap),</span>
<a name="l00250"></a>00250 <span class="comment"> * we need to update our key bindings then (re-translate symbols).</span>
<a name="l00251"></a>00251 <span class="comment"> *</span>
<a name="l00252"></a>00252 <span class="comment"> */</span>
<a name="l00253"></a><a class="code" href="a00040.html#a2ca89397c76485894e1de2fcb65ec697">00253</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#a2ca89397c76485894e1de2fcb65ec697" title="Called when the keyboard mapping changes (for example by using Xmodmap), we need...">handle_mapping_notify</a>(<span class="keywordtype">void</span> *ignored, xcb_connection_t *conn, xcb_mapping_notify_event_t *event) {
<a name="l00254"></a>00254         <span class="keywordflow">if</span> (event-&gt;request != XCB_MAPPING_KEYBOARD &amp;&amp;
<a name="l00255"></a>00255             event-&gt;request != XCB_MAPPING_MODIFIER)
<a name="l00256"></a>00256                 <span class="keywordflow">return</span> 0;
<a name="l00257"></a>00257 
<a name="l00258"></a>00258         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Received mapping_notify for keyboard or modifier mapping, re-grabbing keys\n&quot;</span>);
<a name="l00259"></a>00259         xcb_refresh_keyboard_mapping(<a class="code" href="a00071.html#a5cc0138ae2cf3bbb63a7cae907620797">keysyms</a>, event);
<a name="l00260"></a>00260 
<a name="l00261"></a>00261         <a class="code" href="a00079.html#aeae86e9fc76e08fd43f142de4d11bba0" title="Finds out which modifier mask is the one for numlock, as the user may change this...">xcb_get_numlock_mask</a>(conn);
<a name="l00262"></a>00262 
<a name="l00263"></a>00263         <a class="code" href="a00062.html#afa95dc10a37decc54e9a376d0d462048" title="Ungrabs all keys, to be called before re-grabbing the keys because of a mapping_notify...">ungrab_all_keys</a>(conn);
<a name="l00264"></a>00264         <a class="code" href="a00062.html#a0ee8ffa5c11aeb96126b36171da84adc" title="Translates keysymbols to keycodes for all bindings which use keysyms.">translate_keysyms</a>();
<a name="l00265"></a>00265         <a class="code" href="a00062.html#a1741cf749eb2243cca453355d3f6879b" title="Grab the bound keys (tell X to send us keypress events for those keycodes).">grab_all_keys</a>(conn, <span class="keyword">false</span>);
<a name="l00266"></a>00266 
<a name="l00267"></a>00267         <span class="keywordflow">return</span> 0;
<a name="l00268"></a>00268 }
<a name="l00269"></a>00269 
<a name="l00270"></a>00270 <span class="comment">/*</span>
<a name="l00271"></a>00271 <span class="comment"> * A new window appeared on the screen (=was mapped), so let’s manage it.</span>
<a name="l00272"></a>00272 <span class="comment"> *</span>
<a name="l00273"></a>00273 <span class="comment"> */</span>
<a name="l00274"></a><a class="code" href="a00040.html#ae301f3f0db441a1c22a39e88989a96c3">00274</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#ae301f3f0db441a1c22a39e88989a96c3" title="A new window appeared on the screen (=was mapped), so let’s manage it.">handle_map_request</a>(<span class="keywordtype">void</span> *prophs, xcb_connection_t *conn, xcb_map_request_event_t *event) {
<a name="l00275"></a>00275         xcb_get_window_attributes_cookie_t cookie;
<a name="l00276"></a>00276 
<a name="l00277"></a>00277         cookie = xcb_get_window_attributes_unchecked(conn, event-&gt;window);
<a name="l00278"></a>00278 
<a name="l00279"></a>00279         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;window = 0x%08x, serial is %d.\n&quot;</span>, event-&gt;window, event-&gt;sequence);
<a name="l00280"></a>00280         add_ignore_event(event-&gt;sequence);
<a name="l00281"></a>00281 
<a name="l00282"></a>00282         <a class="code" href="a00072.html#a4a34e4e6e27dfe96206b43297c001f9c" title="Do some sanity checks and then reparent the window.">manage_window</a>(prophs, conn, event-&gt;window, cookie, <span class="keyword">false</span>);
<a name="l00283"></a>00283         <span class="keywordflow">return</span> 1;
<a name="l00284"></a>00284 }
<a name="l00285"></a>00285 
<a name="l00286"></a>00286 <span class="comment">/*</span>
<a name="l00287"></a>00287 <span class="comment"> * Configure requests are received when the application wants to resize windows on their own.</span>
<a name="l00288"></a>00288 <span class="comment"> *</span>
<a name="l00289"></a>00289 <span class="comment"> * We generate a synthethic configure notify event to signalize the client its &quot;new&quot; position.</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="a00040.html#abef279a14e8384ccf48371d6a3f6f962">00292</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#abef279a14e8384ccf48371d6a3f6f962" title="Configure requests are received when the application wants to resize windows on their...">handle_configure_request</a>(<span class="keywordtype">void</span> *prophs, xcb_connection_t *conn, xcb_configure_request_event_t *event) {
<a name="l00293"></a>00293         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;window 0x%08x wants to be at %dx%d with %dx%d\n&quot;</span>,
<a name="l00294"></a>00294             event-&gt;window, event-&gt;x, event-&gt;y, event-&gt;width, event-&gt;height);
<a name="l00295"></a>00295 
<a name="l00296"></a>00296         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client = <a class="code" href="a00077.html#ae1529a1d81e2457f9a2402eda35735d7" title="Returns the value of the element of the given keyvalue-table with the given key.">table_get</a>(&amp;<a class="code" href="a00077.html#aadfb9c6f265623f83355191df37c86c8">by_child</a>, event-&gt;window);
<a name="l00297"></a>00297         <span class="keywordflow">if</span> (client == NULL) {
<a name="l00298"></a>00298                 uint32_t mask = 0;
<a name="l00299"></a>00299                 uint32_t values[7];
<a name="l00300"></a>00300                 <span class="keywordtype">int</span> c = 0;
<a name="l00301"></a>00301 <span class="preprocessor">#define COPY_MASK_MEMBER(mask_member, event_member) do { \</span>
<a name="l00302"></a>00302 <span class="preprocessor">                if (event-&gt;value_mask &amp; mask_member) { \</span>
<a name="l00303"></a>00303 <span class="preprocessor">                        mask |= mask_member; \</span>
<a name="l00304"></a>00304 <span class="preprocessor">                        values[c++] = event-&gt;event_member; \</span>
<a name="l00305"></a>00305 <span class="preprocessor">                } \</span>
<a name="l00306"></a>00306 <span class="preprocessor">} while (0)</span>
<a name="l00307"></a>00307 <span class="preprocessor"></span>
<a name="l00308"></a>00308                 <a class="code" href="a00067.html#a91bd15dcdcdde1b9b0e46e9ed5a51178">COPY_MASK_MEMBER</a>(XCB_CONFIG_WINDOW_X, x);
<a name="l00309"></a>00309                 <a class="code" href="a00067.html#a91bd15dcdcdde1b9b0e46e9ed5a51178">COPY_MASK_MEMBER</a>(XCB_CONFIG_WINDOW_Y, <a class="code" href="a00068.html#a16e56e533e1eb98fda15e06fdec03da6">y</a>);
<a name="l00310"></a>00310                 <a class="code" href="a00067.html#a91bd15dcdcdde1b9b0e46e9ed5a51178">COPY_MASK_MEMBER</a>(XCB_CONFIG_WINDOW_WIDTH, width);
<a name="l00311"></a>00311                 <a class="code" href="a00067.html#a91bd15dcdcdde1b9b0e46e9ed5a51178">COPY_MASK_MEMBER</a>(XCB_CONFIG_WINDOW_HEIGHT, height);
<a name="l00312"></a>00312                 <a class="code" href="a00067.html#a91bd15dcdcdde1b9b0e46e9ed5a51178">COPY_MASK_MEMBER</a>(XCB_CONFIG_WINDOW_BORDER_WIDTH, border_width);
<a name="l00313"></a>00313                 <a class="code" href="a00067.html#a91bd15dcdcdde1b9b0e46e9ed5a51178">COPY_MASK_MEMBER</a>(XCB_CONFIG_WINDOW_SIBLING, sibling);
<a name="l00314"></a>00314                 <a class="code" href="a00067.html#a91bd15dcdcdde1b9b0e46e9ed5a51178">COPY_MASK_MEMBER</a>(XCB_CONFIG_WINDOW_STACK_MODE, stack_mode);
<a name="l00315"></a>00315 
<a name="l00316"></a>00316                 xcb_configure_window(conn, event-&gt;window, mask, values);
<a name="l00317"></a>00317                 xcb_flush(conn);
<a name="l00318"></a>00318 
<a name="l00319"></a>00319                 <span class="keywordflow">return</span> 1;
<a name="l00320"></a>00320         }
<a name="l00321"></a>00321 
<a name="l00322"></a>00322         <span class="keywordflow">if</span> (client-&gt;<a class="code" href="a00007.html#a9eeeb880b93223456c2eae445beccf94" title="fullscreen is pretty obvious">fullscreen</a>) {
<a name="l00323"></a>00323                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Client is in fullscreen mode\n&quot;</span>);
<a name="l00324"></a>00324 
<a name="l00325"></a>00325                 <a class="code" href="a00020.html" title="Stores a rectangle, for example the size of a window, the child window etc.">Rect</a> child_rect = client-&gt;<a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a>-&gt;<a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>;
<a name="l00326"></a>00326                 child_rect.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> = child_rect.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> = 0;
<a name="l00327"></a>00327                 <a class="code" href="a00079.html#a164801596691fe72d4e2e2f1b8b3cee1" title="Generates a configure_notify event and sends it to the given window Applications...">fake_configure_notify</a>(conn, child_rect, client-&gt;<a class="code" href="a00007.html#afba312b946fa74727ce619a33f8f28aa" title="The client’s window.">child</a>);
<a name="l00328"></a>00328 
<a name="l00329"></a>00329                 <span class="keywordflow">return</span> 1;
<a name="l00330"></a>00330         }
<a name="l00331"></a>00331 
<a name="l00332"></a>00332         <span class="comment">/* Floating clients can be reconfigured */</span>
<a name="l00333"></a>00333         <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="l00334"></a>00334                 <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="l00335"></a>00335                 <span class="keywordtype">int</span> mode = (client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a> != NULL ? client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>-&gt;<a class="code" href="a00013.html#ac094306ab77e360742aba04d7cbd0fe6">mode</a> : MODE_DEFAULT);
<a name="l00336"></a>00336                 <span class="comment">/* TODO: refactor this code. we need a function to translate</span>
<a name="l00337"></a>00337 <span class="comment">                 * coordinates of child_rect/rect. */</span>
<a name="l00338"></a>00338 
<a name="l00339"></a>00339                 <span class="keywordflow">if</span> (event-&gt;value_mask &amp; XCB_CONFIG_WINDOW_X) {
<a name="l00340"></a>00340                         <span class="keywordflow">if</span> (mode == MODE_STACK || mode == MODE_TABBED) {
<a name="l00341"></a>00341                                 client-&gt;<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> = <span class="keyword">event</span>-&gt;x - 2;
<a name="l00342"></a>00342                         } <span class="keywordflow">else</span> {
<a name="l00343"></a>00343                                 <span class="keywordflow">if</span> (client-&gt;<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 &amp;&amp; client-&gt;<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="l00344"></a>00344                                         client-&gt;<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> = <span class="keyword">event</span>-&gt;x;
<a name="l00345"></a>00345                                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (client-&gt;<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 &amp;&amp; !client-&gt;<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="l00346"></a>00346                                         client-&gt;<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> = <span class="keyword">event</span>-&gt;x - 1;
<a name="l00347"></a>00347                                 <span class="keywordflow">else</span> client-&gt;<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> = <span class="keyword">event</span>-&gt;x - 2;
<a name="l00348"></a>00348                         }
<a name="l00349"></a>00349                 }
<a name="l00350"></a>00350                 <span class="keywordflow">if</span> (event-&gt;value_mask &amp; XCB_CONFIG_WINDOW_Y) {
<a name="l00351"></a>00351                         <span class="keywordflow">if</span> (mode == MODE_STACK || mode == MODE_TABBED) {
<a name="l00352"></a>00352                                 client-&gt;<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> = <span class="keyword">event</span>-&gt;y - 2;
<a name="l00353"></a>00353                         } <span class="keywordflow">else</span> {
<a name="l00354"></a>00354                                 <span class="keywordflow">if</span> (client-&gt;<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 &amp;&amp; client-&gt;<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="l00355"></a>00355                                         client-&gt;<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> = <span class="keyword">event</span>-&gt;y;
<a name="l00356"></a>00356                                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (client-&gt;<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 &amp;&amp; !client-&gt;<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="l00357"></a>00357                                         client-&gt;<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> = <span class="keyword">event</span>-&gt;y - 1;
<a name="l00358"></a>00358                                 <span class="keywordflow">else</span> client-&gt;<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> = <span class="keyword">event</span>-&gt;y - font-&gt;<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="l00359"></a>00359                         }
<a name="l00360"></a>00360                 }
<a name="l00361"></a>00361                 <span class="keywordflow">if</span> (event-&gt;value_mask &amp; XCB_CONFIG_WINDOW_WIDTH) {
<a name="l00362"></a>00362                         <span class="keywordflow">if</span> (mode == MODE_STACK || mode == MODE_TABBED) {
<a name="l00363"></a>00363                                 client-&gt;<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> = <span class="keyword">event</span>-&gt;width + 2 + 2;
<a name="l00364"></a>00364                         } <span class="keywordflow">else</span> {
<a name="l00365"></a>00365                                 <span class="keywordflow">if</span> (client-&gt;<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 &amp;&amp; client-&gt;<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="l00366"></a>00366                                         client-&gt;<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> = <span class="keyword">event</span>-&gt;width;
<a name="l00367"></a>00367                                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (client-&gt;<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 &amp;&amp; !client-&gt;<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="l00368"></a>00368                                         client-&gt;<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> = <span class="keyword">event</span>-&gt;width + (1 + 1);
<a name="l00369"></a>00369                                 <span class="keywordflow">else</span> client-&gt;<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> = <span class="keyword">event</span>-&gt;width + (2 + 2);
<a name="l00370"></a>00370                         }
<a name="l00371"></a>00371                 }
<a name="l00372"></a>00372                 <span class="keywordflow">if</span> (event-&gt;value_mask &amp; XCB_CONFIG_WINDOW_HEIGHT) {
<a name="l00373"></a>00373                         <span class="keywordflow">if</span> (mode == MODE_STACK || mode == MODE_TABBED) {
<a name="l00374"></a>00374                                 client-&gt;<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> = <span class="keyword">event</span>-&gt;height + 2;
<a name="l00375"></a>00375                         } <span class="keywordflow">else</span> {
<a name="l00376"></a>00376                                 <span class="keywordflow">if</span> (client-&gt;<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 &amp;&amp; client-&gt;<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="l00377"></a>00377                                         client-&gt;<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> = <span class="keyword">event</span>-&gt;height;
<a name="l00378"></a>00378                                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (client-&gt;<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 &amp;&amp; !client-&gt;<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="l00379"></a>00379                                         client-&gt;<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> = <span class="keyword">event</span>-&gt;height + (1 + 1);
<a name="l00380"></a>00380                                 <span class="keywordflow">else</span> client-&gt;<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> = <span class="keyword">event</span>-&gt;height + (font-&gt;<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="l00381"></a>00381                         }
<a name="l00382"></a>00382                 }
<a name="l00383"></a>00383 
<a name="l00384"></a>00384                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Accepted new position/size for floating client: (%d, %d) size %d x %d\n&quot;</span>,
<a name="l00385"></a>00385                     client-&gt;<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-&gt;<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-&gt;<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-&gt;<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="l00386"></a>00386 
<a name="l00387"></a>00387                 <span class="comment">/* Push the new position/size to X11 */</span>
<a name="l00388"></a>00388                 <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="l00389"></a>00389                 <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="l00390"></a>00390                 xcb_flush(conn);
<a name="l00391"></a>00391 
<a name="l00392"></a>00392                 <span class="keywordflow">return</span> 1;
<a name="l00393"></a>00393         }
<a name="l00394"></a>00394 
<a name="l00395"></a>00395         <span class="comment">/* Dock clients can be reconfigured in their height */</span>
<a name="l00396"></a>00396         <span class="keywordflow">if</span> (client-&gt;<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="l00397"></a>00397                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Reconfiguring height of this dock client\n&quot;</span>);
<a name="l00398"></a>00398 
<a name="l00399"></a>00399                 <span class="keywordflow">if</span> (!(event-&gt;value_mask &amp; XCB_CONFIG_WINDOW_HEIGHT)) {
<a name="l00400"></a>00400                         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Ignoring configure request, no height given\n&quot;</span>);
<a name="l00401"></a>00401                         <span class="keywordflow">return</span> 1;
<a name="l00402"></a>00402                 }
<a name="l00403"></a>00403 
<a name="l00404"></a>00404                 client-&gt;<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> = <span class="keyword">event</span>-&gt;height;
<a name="l00405"></a>00405                 <a class="code" href="a00069.html#ab3e248d886080e290648c0d791a40b64" title="Renders the given workspace on the given screen.">render_workspace</a>(conn, <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>, <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>);
<a name="l00406"></a>00406                 xcb_flush(conn);
<a name="l00407"></a>00407 
<a name="l00408"></a>00408                 <span class="keywordflow">return</span> 1;
<a name="l00409"></a>00409         }
<a name="l00410"></a>00410 
<a name="l00411"></a>00411         <span class="keywordflow">if</span> (client-&gt;<a class="code" href="a00007.html#a9eeeb880b93223456c2eae445beccf94" title="fullscreen is pretty obvious">fullscreen</a>) {
<a name="l00412"></a>00412                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Client is in fullscreen mode\n&quot;</span>);
<a name="l00413"></a>00413 
<a name="l00414"></a>00414                 <a class="code" href="a00020.html" title="Stores a rectangle, for example the size of a window, the child window etc.">Rect</a> child_rect = client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>-&gt;<a class="code" href="a00013.html#a98ed501e1088ccf2e7c75399ab7e6031">workspace</a>-&gt;<a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>;
<a name="l00415"></a>00415                 child_rect.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> = child_rect.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> = 0;
<a name="l00416"></a>00416                 <a class="code" href="a00079.html#a164801596691fe72d4e2e2f1b8b3cee1" title="Generates a configure_notify event and sends it to the given window Applications...">fake_configure_notify</a>(conn, child_rect, client-&gt;<a class="code" href="a00007.html#afba312b946fa74727ce619a33f8f28aa" title="The client’s window.">child</a>);
<a name="l00417"></a>00417 
<a name="l00418"></a>00418                 <span class="keywordflow">return</span> 1;
<a name="l00419"></a>00419         }
<a name="l00420"></a>00420 
<a name="l00421"></a>00421         <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="l00422"></a>00422 
<a name="l00423"></a>00423         <span class="keywordflow">return</span> 1;
<a name="l00424"></a>00424 }
<a name="l00425"></a>00425 
<a name="l00426"></a>00426 <span class="comment">/*</span>
<a name="l00427"></a>00427 <span class="comment"> * Configuration notifies are only handled because we need to set up ignore for</span>
<a name="l00428"></a>00428 <span class="comment"> * the following enter notify events.</span>
<a name="l00429"></a>00429 <span class="comment"> *</span>
<a name="l00430"></a>00430 <span class="comment"> */</span>
<a name="l00431"></a><a class="code" href="a00040.html#aa17e023a1acbf56eb18628e82c8ed55e">00431</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#aa17e023a1acbf56eb18628e82c8ed55e" title="Configuration notifies are only handled because we need to set up ignore for the...">handle_configure_event</a>(<span class="keywordtype">void</span> *prophs, xcb_connection_t *conn, xcb_configure_notify_event_t *event) {
<a name="l00432"></a>00432         <span class="comment">/* We ignore this sequence twice because events for child and frame should be ignored */</span>
<a name="l00433"></a>00433         add_ignore_event(event-&gt;sequence);
<a name="l00434"></a>00434         add_ignore_event(event-&gt;sequence);
<a name="l00435"></a>00435 
<a name="l00436"></a>00436         <span class="keywordflow">return</span> 1;
<a name="l00437"></a>00437 }
<a name="l00438"></a>00438 
<a name="l00439"></a>00439 <span class="comment">/*</span>
<a name="l00440"></a>00440 <span class="comment"> * Gets triggered upon a RandR screen change event, that is when the user</span>
<a name="l00441"></a>00441 <span class="comment"> * changes the screen configuration in any way (mode, position, …)</span>
<a name="l00442"></a>00442 <span class="comment"> *</span>
<a name="l00443"></a>00443 <span class="comment"> */</span>
<a name="l00444"></a><a class="code" href="a00040.html#a38db143e8cde0e72a7fe1aa1a9412c0e">00444</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#a38db143e8cde0e72a7fe1aa1a9412c0e" title="Gets triggered upon a RandR screen change event, that is when the user changes the...">handle_screen_change</a>(<span class="keywordtype">void</span> *prophs, xcb_connection_t *conn,
<a name="l00445"></a>00445                          xcb_generic_event_t *e) {
<a name="l00446"></a>00446         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;RandR screen change\n&quot;</span>);
<a name="l00447"></a>00447 
<a name="l00448"></a>00448         <a class="code" href="a00073.html#ace31eff56142111b49e1e88608c8964a" title="(Re-)queries the outputs via RandR and stores them in the list of outputs.">randr_query_outputs</a>(conn);
<a name="l00449"></a>00449 
<a name="l00450"></a>00450         <a class="code" href="a00068.html#ad525c6fad9f4978ae1f06282ad9de6c6" title="Sends the specified event to all IPC clients which are currently connected and subscribed...">ipc_send_event</a>(<span class="stringliteral">&quot;output&quot;</span>, I3_IPC_EVENT_OUTPUT, <span class="stringliteral">&quot;{\&quot;change\&quot;:\&quot;unspecified\&quot;}&quot;</span>);
<a name="l00451"></a>00451 
<a name="l00452"></a>00452         <span class="keywordflow">return</span> 1;
<a name="l00453"></a>00453 }
<a name="l00454"></a>00454 
<a name="l00455"></a>00455 <span class="comment">/*</span>
<a name="l00456"></a>00456 <span class="comment"> * Our window decorations were unmapped. That means, the window will be killed now,</span>
<a name="l00457"></a>00457 <span class="comment"> * so we better clean up before.</span>
<a name="l00458"></a>00458 <span class="comment"> *</span>
<a name="l00459"></a>00459 <span class="comment"> */</span>
<a name="l00460"></a><a class="code" href="a00040.html#af9fc851cafbabe50fa229f4bfb5f0d22">00460</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#af9fc851cafbabe50fa229f4bfb5f0d22" title="Our window decorations were unmapped.">handle_unmap_notify_event</a>(<span class="keywordtype">void</span> *data, xcb_connection_t *conn, xcb_unmap_notify_event_t *event) {
<a name="l00461"></a>00461         xcb_window_t <a class="code" href="a00071.html#a768f07da9e11ab88732a5c550ff49257">root</a> = xcb_setup_roots_iterator(xcb_get_setup(conn)).data-&gt;root;
<a name="l00462"></a>00462 
<a name="l00463"></a>00463         add_ignore_event(event-&gt;sequence);
<a name="l00464"></a>00464 
<a name="l00465"></a>00465         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client = <a class="code" href="a00077.html#ae1529a1d81e2457f9a2402eda35735d7" title="Returns the value of the element of the given keyvalue-table with the given key.">table_get</a>(&amp;<a class="code" href="a00077.html#aadfb9c6f265623f83355191df37c86c8">by_child</a>, event-&gt;window);
<a name="l00466"></a>00466         <span class="comment">/* First, we need to check if the client is awaiting an unmap-request which</span>
<a name="l00467"></a>00467 <span class="comment">           was generated by us reparenting the window. In that case, we just ignore it. */</span>
<a name="l00468"></a>00468         <span class="keywordflow">if</span> (client != NULL &amp;&amp; client-&gt;<a class="code" href="a00007.html#a0817c563b1f63c30c7873067a22d2607">awaiting_useless_unmap</a>) {
<a name="l00469"></a>00469                 client-&gt;<a class="code" href="a00007.html#a0817c563b1f63c30c7873067a22d2607">awaiting_useless_unmap</a> = <span class="keyword">false</span>;
<a name="l00470"></a>00470                 <span class="keywordflow">return</span> 1;
<a name="l00471"></a>00471         }
<a name="l00472"></a>00472 
<a name="l00473"></a>00473         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;event-&gt;window = %08x, event-&gt;event = %08x\n&quot;</span>, event-&gt;window, event-&gt;event);
<a name="l00474"></a>00474         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;UnmapNotify for 0x%08x (received from 0x%08x)\n&quot;</span>, event-&gt;window, event-&gt;event);
<a name="l00475"></a>00475         <span class="keywordflow">if</span> (client == NULL) {
<a name="l00476"></a>00476                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;not a managed window. Ignoring.\n&quot;</span>);
<a name="l00477"></a>00477 
<a name="l00478"></a>00478                 <span class="comment">/* This was most likely the destroyed frame of a client which is</span>
<a name="l00479"></a>00479 <span class="comment">                 * currently being unmapped, so we add this sequence (again!) to</span>
<a name="l00480"></a>00480 <span class="comment">                 * the ignore list (enter_notify events will get sent for both,</span>
<a name="l00481"></a>00481 <span class="comment">                 * the child and its frame). */</span>
<a name="l00482"></a>00482                 add_ignore_event(event-&gt;sequence);
<a name="l00483"></a>00483 
<a name="l00484"></a>00484                 <span class="keywordflow">return</span> 0;
<a name="l00485"></a>00485         }
<a name="l00486"></a>00486 
<a name="l00487"></a>00487         client = <a class="code" href="a00077.html#a325edcce10c699e46d7638d4361599e7" title="Removes the element from the given keyvalue-table with the given key and returns...">table_remove</a>(&amp;<a class="code" href="a00077.html#aadfb9c6f265623f83355191df37c86c8">by_child</a>, event-&gt;window);
<a name="l00488"></a>00488 
<a name="l00489"></a>00489         <span class="comment">/* If this was the fullscreen client, we need to unset it from all</span>
<a name="l00490"></a>00490 <span class="comment">         * workspaces it was on (global fullscreen) */</span>
<a name="l00491"></a>00491         <span class="keywordflow">if</span> (client-&gt;<a class="code" href="a00007.html#a9eeeb880b93223456c2eae445beccf94" title="fullscreen is pretty obvious">fullscreen</a>) {
<a name="l00492"></a>00492                 <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws;
<a name="l00493"></a>00493                 <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="l00494"></a>00494                         <span class="keywordflow">if</span> (ws-&gt;<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="l00495"></a>00495                                 ws-&gt;<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="l00496"></a>00496         }
<a name="l00497"></a>00497 
<a name="l00498"></a>00498         <span class="comment">/* Clients without a container are either floating or dock windows */</span>
<a name="l00499"></a>00499         <span class="keywordflow">if</span> (client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a> != NULL) {
<a name="l00500"></a>00500                 <a class="code" href="a00013.html" title="A container is either in default, stacking or tabbed mode.">Container</a> *con = client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>;
<a name="l00501"></a>00501 
<a name="l00502"></a>00502                 <span class="comment">/* Remove the client from the list of clients */</span>
<a name="l00503"></a>00503                 <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">true</span>);
<a name="l00504"></a>00504 
<a name="l00505"></a>00505                 <span class="comment">/* Set focus to the last focused client in this container */</span>
<a name="l00506"></a>00506                 con-&gt;<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="l00507"></a>00507 
<a name="l00508"></a>00508                 <span class="comment">/* Only if this is the active container, we need to really change focus */</span>
<a name="l00509"></a>00509                 <span class="keywordflow">if</span> ((con-&gt;<a class="code" href="a00013.html#a82d910506b0d788a92ebeeb1d82da75b">currently_focused</a> != NULL) &amp;&amp; ((con == <a class="code" href="a00051.html#ac120dc3752e8ac2853ddd65d7737a2fd">CUR_CELL</a>) || client-&gt;<a class="code" href="a00007.html#a9eeeb880b93223456c2eae445beccf94" title="fullscreen is pretty obvious">fullscreen</a>))
<a name="l00510"></a>00510                         <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, con-&gt;<a class="code" href="a00013.html#a82d910506b0d788a92ebeeb1d82da75b">currently_focused</a>, <span class="keyword">true</span>);
<a name="l00511"></a>00511         } <span class="keywordflow">else</span> <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="l00512"></a>00512                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Removing from floating clients\n&quot;</span>);
<a name="l00513"></a>00513                 <a class="code" href="a00047.html#aaae87ca18c28066e1a96221e762d1209">TAILQ_REMOVE</a>(&amp;(client-&gt;<a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a>-&gt;floating_clients), client, floating_clients);
<a name="l00514"></a>00514                 <a class="code" href="a00047.html#a9c7950d61593ab9198524fca81b17ab0">SLIST_REMOVE</a>(&amp;(client-&gt;<a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a>-&gt;focus_stack), client, <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a>, focus_clients);
<a name="l00515"></a>00515         }
<a name="l00516"></a>00516 
<a name="l00517"></a>00517         <span class="keywordflow">if</span> (client-&gt;<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="l00518"></a>00518                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Removing from dock clients\n&quot;</span>);
<a name="l00519"></a>00519                 <a class="code" href="a00047.html#a9c7950d61593ab9198524fca81b17ab0">SLIST_REMOVE</a>(&amp;(client-&gt;<a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a>-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>-&gt;dock_clients), client, <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a>, dock_clients);
<a name="l00520"></a>00520         }
<a name="l00521"></a>00521 
<a name="l00522"></a>00522         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;child of 0x%08x.\n&quot;</span>, client-&gt;<a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>);
<a name="l00523"></a>00523         xcb_reparent_window(conn, client-&gt;<a class="code" href="a00007.html#afba312b946fa74727ce619a33f8f28aa" title="The client’s window.">child</a>, root, 0, 0);
<a name="l00524"></a>00524 
<a name="l00525"></a>00525         <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="l00526"></a>00526 
<a name="l00527"></a>00527         xcb_destroy_window(conn, client-&gt;<a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>);
<a name="l00528"></a>00528         xcb_flush(conn);
<a name="l00529"></a>00529         <a class="code" href="a00077.html#a325edcce10c699e46d7638d4361599e7" title="Removes the element from the given keyvalue-table with the given key and returns...">table_remove</a>(&amp;<a class="code" href="a00077.html#a38dffc58d761d720f7c63d35f2efd71d">by_parent</a>, client-&gt;<a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>);
<a name="l00530"></a>00530 
<a name="l00531"></a>00531         <span class="keywordflow">if</span> (client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a> != NULL) {
<a name="l00532"></a>00532                 <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *workspace = client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>-&gt;<a class="code" href="a00013.html#a98ed501e1088ccf2e7c75399ab7e6031">workspace</a>;
<a name="l00533"></a>00533                 <a class="code" href="a00076.html#a53709ed2b55f1b76021b0e6c93aae547" title="Shrinks the table by &amp;quot;compacting&amp;quot; it, that is, removing completely empty...">cleanup_table</a>(conn, workspace);
<a name="l00534"></a>00534                 <a class="code" href="a00076.html#aaeae76f5b6005f3a20a6fb1d8906d8a5" title="Fixes col/rowspan (makes sure there are no overlapping windows).">fix_colrowspan</a>(conn, workspace);
<a name="l00535"></a>00535         }
<a name="l00536"></a>00536 
<a name="l00537"></a>00537         <span class="comment">/* Let’s see how many clients there are left on the workspace to delete it if it’s empty */</span>
<a name="l00538"></a>00538         <span class="keywordtype">bool</span> workspace_empty = <a class="code" href="a00047.html#a59bcc4e6f4bf63b897bdc0644566c583">SLIST_EMPTY</a>(&amp;(client-&gt;<a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a>-&gt;focus_stack));
<a name="l00539"></a>00539         <span class="keywordtype">bool</span> workspace_focused = (<a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a> == client-&gt;<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="l00540"></a>00540         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *to_focus = (!workspace_empty ? <a class="code" href="a00047.html#a91bac7d0d32e3ec56bc579ace45ed8cd">SLIST_FIRST</a>(&amp;(client-&gt;<a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a>-&gt;focus_stack)) : NULL);
<a name="l00541"></a>00541 
<a name="l00542"></a>00542         <span class="comment">/* If this workspace is currently visible, we don’t delete it */</span>
<a name="l00543"></a>00543         <span class="keywordflow">if</span> (<a class="code" href="a00078.html#a7a4e9d7994d904776ead4c8fc1b22091" title="Returns true if the workspace is currently visible.">workspace_is_visible</a>(client-&gt;<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="l00544"></a>00544                 workspace_empty = <span class="keyword">false</span>;
<a name="l00545"></a>00545 
<a name="l00546"></a>00546         <span class="keywordflow">if</span> (workspace_empty) {
<a name="l00547"></a>00547                 client-&gt;<a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a>-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a> = NULL;
<a name="l00548"></a>00548                 <a class="code" href="a00068.html#ad525c6fad9f4978ae1f06282ad9de6c6" title="Sends the specified event to all IPC clients which are currently connected and subscribed...">ipc_send_event</a>(<span class="stringliteral">&quot;workspace&quot;</span>, I3_IPC_EVENT_WORKSPACE, <span class="stringliteral">&quot;{\&quot;change\&quot;:\&quot;empty\&quot;}&quot;</span>);
<a name="l00549"></a>00549         }
<a name="l00550"></a>00550 
<a name="l00551"></a>00551         <span class="comment">/* Remove the urgency flag if set */</span>
<a name="l00552"></a>00552         client-&gt;<a class="code" href="a00007.html#ad169bd46b1c1edf6f7cddf2c0c5306c7" title="True if the client set the urgency flag in its WM_HINTS property.">urgent</a> = <span class="keyword">false</span>;
<a name="l00553"></a>00553         <a class="code" href="a00078.html#a2c43568cc3492bd24992d93f4552bbe9" title="Goes through all clients on the given workspace and updates the workspace’s urgent...">workspace_update_urgent_flag</a>(client-&gt;<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="l00554"></a>00554 
<a name="l00555"></a>00555         <a class="code" href="a00052.html#ae88e84de75be0b138a19509d288b4cf4">FREE</a>(client-&gt;<a class="code" href="a00007.html#ac39c70e8b92f752b81f2c5cca3522399" title="Holds the WM_CLASS (which consists of two strings, the instance and the class), useful...">window_class_instance</a>);
<a name="l00556"></a>00556         <a class="code" href="a00052.html#ae88e84de75be0b138a19509d288b4cf4">FREE</a>(client-&gt;<a class="code" href="a00007.html#a1c231d29bfbf4213354bb5ac43bacfa4">window_class_class</a>);
<a name="l00557"></a>00557         <a class="code" href="a00052.html#ae88e84de75be0b138a19509d288b4cf4">FREE</a>(client-&gt;<a class="code" href="a00007.html#a14c9eb7f57edfd939ed2fada25e83916" title="Name (= window title).">name</a>);
<a name="l00558"></a>00558         free(client);
<a name="l00559"></a>00559 
<a name="l00560"></a>00560         <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>(conn);
<a name="l00561"></a>00561 
<a name="l00562"></a>00562         <span class="comment">/* Ensure the focus is set to the next client in the focus stack or to</span>
<a name="l00563"></a>00563 <span class="comment">         * the screen itself (if we do not focus the screen, it can happen that</span>
<a name="l00564"></a>00564 <span class="comment">         * the focus is &quot;nowhere&quot; and thus keypress events will not be received</span>
<a name="l00565"></a>00565 <span class="comment">         * by i3, thus the user cannot use any hotkeys). */</span>
<a name="l00566"></a>00566         <span class="keywordflow">if</span> (workspace_focused) {
<a name="l00567"></a>00567                 <span class="keywordflow">if</span> (to_focus != NULL)
<a name="l00568"></a>00568                         <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, to_focus, <span class="keyword">true</span>);
<a name="l00569"></a>00569                 <span class="keywordflow">else</span> {
<a name="l00570"></a>00570                         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Restoring focus to root screen\n&quot;</span>);
<a name="l00571"></a>00571                         xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME);
<a name="l00572"></a>00572                         xcb_flush(conn);
<a name="l00573"></a>00573                 }
<a name="l00574"></a>00574         }
<a name="l00575"></a>00575 
<a name="l00576"></a>00576         <span class="keywordflow">return</span> 1;
<a name="l00577"></a>00577 }
<a name="l00578"></a>00578 
<a name="l00579"></a>00579 <span class="comment">/*</span>
<a name="l00580"></a>00580 <span class="comment"> * A destroy notify event is sent when the window is not unmapped, but</span>
<a name="l00581"></a>00581 <span class="comment"> * immediately destroyed (for example when starting a window and immediately</span>
<a name="l00582"></a>00582 <span class="comment"> * killing the program which started it).</span>
<a name="l00583"></a>00583 <span class="comment"> *</span>
<a name="l00584"></a>00584 <span class="comment"> * We just pass on the event to the unmap notify handler (by copying the</span>
<a name="l00585"></a>00585 <span class="comment"> * important fields in the event data structure).</span>
<a name="l00586"></a>00586 <span class="comment"> *</span>
<a name="l00587"></a>00587 <span class="comment"> */</span>
<a name="l00588"></a><a class="code" href="a00040.html#a8c3b4a8b74d993af20e5078e4a20efed">00588</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#a8c3b4a8b74d993af20e5078e4a20efed" title="A destroy notify event is sent when the window is not unmapped, but immediately destroyed...">handle_destroy_notify_event</a>(<span class="keywordtype">void</span> *data, xcb_connection_t *conn, xcb_destroy_notify_event_t *event) {
<a name="l00589"></a>00589         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;destroy notify for 0x%08x, 0x%08x\n&quot;</span>, event-&gt;event, event-&gt;window);
<a name="l00590"></a>00590 
<a name="l00591"></a>00591         xcb_unmap_notify_event_t unmap;
<a name="l00592"></a>00592         unmap.sequence = <span class="keyword">event</span>-&gt;sequence;
<a name="l00593"></a>00593         unmap.event = <span class="keyword">event</span>-&gt;event;
<a name="l00594"></a>00594         unmap.window = <span class="keyword">event</span>-&gt;window;
<a name="l00595"></a>00595 
<a name="l00596"></a>00596         <span class="keywordflow">return</span> <a class="code" href="a00067.html#af9fc851cafbabe50fa229f4bfb5f0d22" title="Our window decorations were unmapped.">handle_unmap_notify_event</a>(NULL, conn, &amp;unmap);
<a name="l00597"></a>00597 }
<a name="l00598"></a>00598 
<a name="l00599"></a>00599 <span class="comment">/*</span>
<a name="l00600"></a>00600 <span class="comment"> * Called when a window changes its title</span>
<a name="l00601"></a>00601 <span class="comment"> *</span>
<a name="l00602"></a>00602 <span class="comment"> */</span>
<a name="l00603"></a><a class="code" href="a00040.html#a763f921cc825269f3034ac3237f911f2">00603</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#a763f921cc825269f3034ac3237f911f2" title="Called when a window changes its title.">handle_windowname_change</a>(<span class="keywordtype">void</span> *data, xcb_connection_t *conn, uint8_t state,
<a name="l00604"></a>00604                                 xcb_window_t <a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a>, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
<a name="l00605"></a>00605         <span class="keywordflow">if</span> (prop == NULL || xcb_get_property_value_length(prop) == 0) {
<a name="l00606"></a>00606                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;_NET_WM_NAME not specified, not changing\n&quot;</span>);
<a name="l00607"></a>00607                 <span class="keywordflow">return</span> 1;
<a name="l00608"></a>00608         }
<a name="l00609"></a>00609         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client = <a class="code" href="a00077.html#ae1529a1d81e2457f9a2402eda35735d7" title="Returns the value of the element of the given keyvalue-table with the given key.">table_get</a>(&amp;<a class="code" href="a00077.html#aadfb9c6f265623f83355191df37c86c8">by_child</a>, window);
<a name="l00610"></a>00610         <span class="keywordflow">if</span> (client == NULL)
<a name="l00611"></a>00611                 <span class="keywordflow">return</span> 1;
<a name="l00612"></a>00612 
<a name="l00613"></a>00613         <span class="comment">/* Save the old pointer to make the update atomic */</span>
<a name="l00614"></a>00614         <span class="keywordtype">char</span> *new_name;
<a name="l00615"></a>00615         <span class="keywordtype">int</span> new_len;
<a name="l00616"></a>00616         <span class="keywordflow">if</span> (asprintf(&amp;new_name, <span class="stringliteral">&quot;%.*s&quot;</span>, xcb_get_property_value_length(prop), (<span class="keywordtype">char</span>*)xcb_get_property_value(prop)) == -1) {
<a name="l00617"></a>00617                 perror(<span class="stringliteral">&quot;asprintf&quot;</span>);
<a name="l00618"></a>00618                 <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">&quot;Could not format _NET_WM_NAME, ignoring new hint\n&quot;</span>);
<a name="l00619"></a>00619                 <span class="keywordflow">return</span> 1;
<a name="l00620"></a>00620         }
<a name="l00621"></a>00621         <span class="comment">/* Convert it to UCS-2 here for not having to convert it later every time we want to pass it to X */</span>
<a name="l00622"></a>00622         <span class="keywordtype">char</span> *ucs2_name = <a class="code" href="a00077.html#a1d926a6371d3d87f2dd85c1a27d83f4b" title="Converts the given string to UCS-2 big endian for use with xcb_image_text_16().">convert_utf8_to_ucs2</a>(new_name, &amp;new_len);
<a name="l00623"></a>00623         <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">&quot;_NET_WM_NAME changed to \&quot;%s\&quot;\n&quot;</span>, new_name);
<a name="l00624"></a>00624         free(new_name);
<a name="l00625"></a>00625         <span class="keywordflow">if</span> (ucs2_name == NULL) {
<a name="l00626"></a>00626                 <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">&quot;Could not convert _NET_WM_NAME to UCS-2, ignoring new hint\n&quot;</span>);
<a name="l00627"></a>00627                 <span class="keywordflow">return</span> 1;
<a name="l00628"></a>00628         }
<a name="l00629"></a>00629 
<a name="l00630"></a>00630         <span class="comment">/* Check if they are the same and don’t update if so.</span>
<a name="l00631"></a>00631 <span class="comment">           Note the use of new_len * 2 to check all bytes as each glyph takes 2 bytes.</span>
<a name="l00632"></a>00632 <span class="comment">           Also note the use of memcmp() instead of strncmp() because the latter stops on nullbytes,</span>
<a name="l00633"></a>00633 <span class="comment">           but UCS-2 uses nullbytes to fill up glyphs which only use one byte. */</span>
<a name="l00634"></a>00634         <span class="keywordflow">if</span> ((new_len == client-&gt;<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>) &amp;&amp;
<a name="l00635"></a>00635             (client-&gt;<a class="code" href="a00007.html#a14c9eb7f57edfd939ed2fada25e83916" title="Name (= window title).">name</a> != NULL) &amp;&amp;
<a name="l00636"></a>00636             (memcmp(client-&gt;<a class="code" href="a00007.html#a14c9eb7f57edfd939ed2fada25e83916" title="Name (= window title).">name</a>, ucs2_name, new_len * 2) == 0)) {
<a name="l00637"></a>00637                 free(ucs2_name);
<a name="l00638"></a>00638                 <span class="keywordflow">return</span> 1;
<a name="l00639"></a>00639         }
<a name="l00640"></a>00640 
<a name="l00641"></a>00641         <span class="keywordtype">char</span> *old_name = client-&gt;<a class="code" href="a00007.html#a14c9eb7f57edfd939ed2fada25e83916" title="Name (= window title).">name</a>;
<a name="l00642"></a>00642         client-&gt;<a class="code" href="a00007.html#a14c9eb7f57edfd939ed2fada25e83916" title="Name (= window title).">name</a> = ucs2_name;
<a name="l00643"></a>00643         client-&gt;<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> = new_len;
<a name="l00644"></a>00644         client-&gt;<a class="code" href="a00007.html#ab88a383fe1d2388cf4d4c792c899a766" title="This will be set to true as soon as the first _NET_WM_NAME comes in.">uses_net_wm_name</a> = <span class="keyword">true</span>;
<a name="l00645"></a>00645 
<a name="l00646"></a>00646         <a class="code" href="a00052.html#ae88e84de75be0b138a19509d288b4cf4">FREE</a>(old_name);
<a name="l00647"></a>00647 
<a name="l00648"></a>00648         <span class="comment">/* If the client is a dock window, we don’t need to render anything */</span>
<a name="l00649"></a>00649         <span class="keywordflow">if</span> (client-&gt;<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="l00650"></a>00650                 <span class="keywordflow">return</span> 1;
<a name="l00651"></a>00651 
<a name="l00652"></a>00652         <span class="keywordflow">if</span> (!<a class="code" href="a00078.html#a7a4e9d7994d904776ead4c8fc1b22091" title="Returns true if the workspace is currently visible.">workspace_is_visible</a>(client-&gt;<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="l00653"></a>00653                 <span class="keywordflow">return</span> 1;
<a name="l00654"></a>00654 
<a name="l00655"></a>00655         <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-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>, <span class="keyword">true</span>);
<a name="l00656"></a>00656         <span class="keywordflow">if</span> (mode == MODE_STACK || mode == MODE_TABBED)
<a name="l00657"></a>00657                 <a class="code" href="a00069.html#a2a1fee0aebdaf2497fb52ea57a1033a4" title="Renders the given container.">render_container</a>(conn, client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>);
<a name="l00658"></a>00658         <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-&gt;<a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, client-&gt;<a class="code" href="a00007.html#ab9525d9a134fa0d25a1352f8e58bee2e" title="The titlebar’s graphic context inside the frame.">titlegc</a>, 0, 0);
<a name="l00659"></a>00659         xcb_flush(conn);
<a name="l00660"></a>00660 
<a name="l00661"></a>00661         <span class="keywordflow">return</span> 1;
<a name="l00662"></a>00662 }
<a name="l00663"></a>00663 
<a name="l00664"></a>00664 <span class="comment">/*</span>
<a name="l00665"></a>00665 <span class="comment"> * We handle legacy window names (titles) which are in COMPOUND_TEXT encoding. However, we</span>
<a name="l00666"></a>00666 <span class="comment"> * just pass them along, so when containing non-ASCII characters, those will be rendering</span>
<a name="l00667"></a>00667 <span class="comment"> * incorrectly. In order to correctly render unicode window titles in i3, an application</span>
<a name="l00668"></a>00668 <span class="comment"> * has to set _NET_WM_NAME, which is in UTF-8 encoding.</span>
<a name="l00669"></a>00669 <span class="comment"> *</span>
<a name="l00670"></a>00670 <span class="comment"> * On every update, a message is put out to the user, so he may improve the situation and</span>
<a name="l00671"></a>00671 <span class="comment"> * update applications which display filenames in their title to correctly use</span>
<a name="l00672"></a>00672 <span class="comment"> * _NET_WM_NAME and therefore support unicode.</span>
<a name="l00673"></a>00673 <span class="comment"> *</span>
<a name="l00674"></a>00674 <span class="comment"> */</span>
<a name="l00675"></a><a class="code" href="a00040.html#ac3e59ebb6684722fada02f66582a1787">00675</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#ac3e59ebb6684722fada02f66582a1787" title="We handle legacy window names (titles) which are in COMPOUND_TEXT encoding.">handle_windowname_change_legacy</a>(<span class="keywordtype">void</span> *data, xcb_connection_t *conn, uint8_t state,
<a name="l00676"></a>00676                                 xcb_window_t <a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a>, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
<a name="l00677"></a>00677         <span class="keywordflow">if</span> (prop == NULL || xcb_get_property_value_length(prop) == 0) {
<a name="l00678"></a>00678                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;prop == NULL\n&quot;</span>);
<a name="l00679"></a>00679                 <span class="keywordflow">return</span> 1;
<a name="l00680"></a>00680         }
<a name="l00681"></a>00681         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client = <a class="code" href="a00077.html#ae1529a1d81e2457f9a2402eda35735d7" title="Returns the value of the element of the given keyvalue-table with the given key.">table_get</a>(&amp;<a class="code" href="a00077.html#aadfb9c6f265623f83355191df37c86c8">by_child</a>, window);
<a name="l00682"></a>00682         <span class="keywordflow">if</span> (client == NULL)
<a name="l00683"></a>00683                 <span class="keywordflow">return</span> 1;
<a name="l00684"></a>00684 
<a name="l00685"></a>00685         <span class="comment">/* Client capable of _NET_WM_NAME, ignore legacy name changes */</span>
<a name="l00686"></a>00686         <span class="keywordflow">if</span> (client-&gt;<a class="code" href="a00007.html#ab88a383fe1d2388cf4d4c792c899a766" title="This will be set to true as soon as the first _NET_WM_NAME comes in.">uses_net_wm_name</a>)
<a name="l00687"></a>00687                 <span class="keywordflow">return</span> 1;
<a name="l00688"></a>00688 
<a name="l00689"></a>00689         <span class="comment">/* Save the old pointer to make the update atomic */</span>
<a name="l00690"></a>00690         <span class="keywordtype">char</span> *new_name;
<a name="l00691"></a>00691         <span class="keywordflow">if</span> (asprintf(&amp;new_name, <span class="stringliteral">&quot;%.*s&quot;</span>, xcb_get_property_value_length(prop), (<span class="keywordtype">char</span>*)xcb_get_property_value(prop)) == -1) {
<a name="l00692"></a>00692                 perror(<span class="stringliteral">&quot;Could not get old name&quot;</span>);
<a name="l00693"></a>00693                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Could not get old name\n&quot;</span>);
<a name="l00694"></a>00694                 <span class="keywordflow">return</span> 1;
<a name="l00695"></a>00695         }
<a name="l00696"></a>00696         <span class="comment">/* Convert it to UCS-2 here for not having to convert it later every time we want to pass it to X */</span>
<a name="l00697"></a>00697         <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">&quot;WM_NAME changed to \&quot;%s\&quot;\n&quot;</span>, new_name);
<a name="l00698"></a>00698 
<a name="l00699"></a>00699         <span class="comment">/* Check if they are the same and don’t update if so. */</span>
<a name="l00700"></a>00700         <span class="keywordflow">if</span> (client-&gt;<a class="code" href="a00007.html#a14c9eb7f57edfd939ed2fada25e83916" title="Name (= window title).">name</a> != NULL &amp;&amp;
<a name="l00701"></a>00701             strlen(new_name) == strlen(client-&gt;<a class="code" href="a00007.html#a14c9eb7f57edfd939ed2fada25e83916" title="Name (= window title).">name</a>) &amp;&amp;
<a name="l00702"></a>00702             strcmp(client-&gt;<a class="code" href="a00007.html#a14c9eb7f57edfd939ed2fada25e83916" title="Name (= window title).">name</a>, new_name) == 0) {
<a name="l00703"></a>00703                 free(new_name);
<a name="l00704"></a>00704                 <span class="keywordflow">return</span> 1;
<a name="l00705"></a>00705         }
<a name="l00706"></a>00706 
<a name="l00707"></a>00707         <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">&quot;Using legacy window title. Note that in order to get Unicode window titles in i3, &quot;</span>
<a name="l00708"></a>00708             <span class="stringliteral">&quot;the application has to set _NET_WM_NAME which is in UTF-8 encoding.\n&quot;</span>);
<a name="l00709"></a>00709 
<a name="l00710"></a>00710         <span class="keywordtype">char</span> *old_name = client-&gt;<a class="code" href="a00007.html#a14c9eb7f57edfd939ed2fada25e83916" title="Name (= window title).">name</a>;
<a name="l00711"></a>00711         client-&gt;<a class="code" href="a00007.html#a14c9eb7f57edfd939ed2fada25e83916" title="Name (= window title).">name</a> = new_name;
<a name="l00712"></a>00712         client-&gt;<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="l00713"></a>00713 
<a name="l00714"></a>00714         <span class="keywordflow">if</span> (old_name != NULL)
<a name="l00715"></a>00715                 free(old_name);
<a name="l00716"></a>00716 
<a name="l00717"></a>00717         <span class="comment">/* If the client is a dock window, we don’t need to render anything */</span>
<a name="l00718"></a>00718         <span class="keywordflow">if</span> (client-&gt;<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="l00719"></a>00719                 <span class="keywordflow">return</span> 1;
<a name="l00720"></a>00720 
<a name="l00721"></a>00721         <span class="keywordflow">if</span> (!<a class="code" href="a00078.html#a7a4e9d7994d904776ead4c8fc1b22091" title="Returns true if the workspace is currently visible.">workspace_is_visible</a>(client-&gt;<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="l00722"></a>00722                 <span class="keywordflow">return</span> 1;
<a name="l00723"></a>00723 
<a name="l00724"></a>00724         <span class="keywordflow">if</span> (client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a> != NULL &amp;&amp;
<a name="l00725"></a>00725             (client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>-&gt;<a class="code" href="a00013.html#ac094306ab77e360742aba04d7cbd0fe6">mode</a> == MODE_STACK ||
<a name="l00726"></a>00726              client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>-&gt;<a class="code" href="a00013.html#ac094306ab77e360742aba04d7cbd0fe6">mode</a> == MODE_TABBED))
<a name="l00727"></a>00727                 <a class="code" href="a00069.html#a2a1fee0aebdaf2497fb52ea57a1033a4" title="Renders the given container.">render_container</a>(conn, client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>);
<a name="l00728"></a>00728         <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-&gt;<a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, client-&gt;<a class="code" href="a00007.html#ab9525d9a134fa0d25a1352f8e58bee2e" title="The titlebar’s graphic context inside the frame.">titlegc</a>, 0, 0);
<a name="l00729"></a>00729         xcb_flush(conn);
<a name="l00730"></a>00730 
<a name="l00731"></a>00731         <span class="keywordflow">return</span> 1;
<a name="l00732"></a>00732 }
<a name="l00733"></a>00733 
<a name="l00734"></a>00734 <span class="comment">/*</span>
<a name="l00735"></a>00735 <span class="comment"> * Updates the client’s WM_CLASS property</span>
<a name="l00736"></a>00736 <span class="comment"> *</span>
<a name="l00737"></a>00737 <span class="comment"> */</span>
<a name="l00738"></a><a class="code" href="a00040.html#a3fdeb5f8c0fbef80784d1d62e4653ed9">00738</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#a3fdeb5f8c0fbef80784d1d62e4653ed9" title="Store the window classes for jumping to them later.">handle_windowclass_change</a>(<span class="keywordtype">void</span> *data, xcb_connection_t *conn, uint8_t state,
<a name="l00739"></a>00739                              xcb_window_t <a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a>, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
<a name="l00740"></a>00740         <span class="keywordflow">if</span> (prop == NULL || xcb_get_property_value_length(prop) == 0) {
<a name="l00741"></a>00741                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;prop == NULL\n&quot;</span>);
<a name="l00742"></a>00742                 <span class="keywordflow">return</span> 1;
<a name="l00743"></a>00743         }
<a name="l00744"></a>00744         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client = <a class="code" href="a00077.html#ae1529a1d81e2457f9a2402eda35735d7" title="Returns the value of the element of the given keyvalue-table with the given key.">table_get</a>(&amp;<a class="code" href="a00077.html#aadfb9c6f265623f83355191df37c86c8">by_child</a>, window);
<a name="l00745"></a>00745         <span class="keywordflow">if</span> (client == NULL)
<a name="l00746"></a>00746                 <span class="keywordflow">return</span> 1;
<a name="l00747"></a>00747 
<a name="l00748"></a>00748         <span class="comment">/* We cannot use asprintf here since this property contains two</span>
<a name="l00749"></a>00749 <span class="comment">         * null-terminated strings (for compatibility reasons). Instead, we</span>
<a name="l00750"></a>00750 <span class="comment">         * use strdup() on both strings */</span>
<a name="l00751"></a>00751         <span class="keywordtype">char</span> *new_class = xcb_get_property_value(prop);
<a name="l00752"></a>00752 
<a name="l00753"></a>00753         <a class="code" href="a00052.html#ae88e84de75be0b138a19509d288b4cf4">FREE</a>(client-&gt;<a class="code" href="a00007.html#ac39c70e8b92f752b81f2c5cca3522399" title="Holds the WM_CLASS (which consists of two strings, the instance and the class), useful...">window_class_instance</a>);
<a name="l00754"></a>00754         <a class="code" href="a00052.html#ae88e84de75be0b138a19509d288b4cf4">FREE</a>(client-&gt;<a class="code" href="a00007.html#a1c231d29bfbf4213354bb5ac43bacfa4">window_class_class</a>);
<a name="l00755"></a>00755 
<a name="l00756"></a>00756         client-&gt;<a class="code" href="a00007.html#ac39c70e8b92f752b81f2c5cca3522399" title="Holds the WM_CLASS (which consists of two strings, the instance and the class), useful...">window_class_instance</a> = strdup(new_class);
<a name="l00757"></a>00757         <span class="keywordflow">if</span> ((strlen(new_class) + 1) &lt; xcb_get_property_value_length(prop))
<a name="l00758"></a>00758                 client-&gt;<a class="code" href="a00007.html#a1c231d29bfbf4213354bb5ac43bacfa4">window_class_class</a> = strdup(new_class + strlen(new_class) + 1);
<a name="l00759"></a>00759         <span class="keywordflow">else</span> client-&gt;<a class="code" href="a00007.html#a1c231d29bfbf4213354bb5ac43bacfa4">window_class_class</a> = NULL;
<a name="l00760"></a>00760         <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">&quot;WM_CLASS changed to %s (instance), %s (class)\n&quot;</span>,
<a name="l00761"></a>00761             client-&gt;<a class="code" href="a00007.html#ac39c70e8b92f752b81f2c5cca3522399" title="Holds the WM_CLASS (which consists of two strings, the instance and the class), useful...">window_class_instance</a>, client-&gt;<a class="code" href="a00007.html#a1c231d29bfbf4213354bb5ac43bacfa4">window_class_class</a>);
<a name="l00762"></a>00762 
<a name="l00763"></a>00763         <span class="keywordflow">return</span> 0;
<a name="l00764"></a>00764 }
<a name="l00765"></a>00765 
<a name="l00766"></a>00766 <span class="comment">/*</span>
<a name="l00767"></a>00767 <span class="comment"> * Expose event means we should redraw our windows (= title bar)</span>
<a name="l00768"></a>00768 <span class="comment"> *</span>
<a name="l00769"></a>00769 <span class="comment"> */</span>
<a name="l00770"></a><a class="code" href="a00040.html#aef74cebc820b8224d196fa6eb9c13ac4">00770</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#aef74cebc820b8224d196fa6eb9c13ac4" title="Expose event means we should redraw our windows (= title bar).">handle_expose_event</a>(<span class="keywordtype">void</span> *data, xcb_connection_t *conn, xcb_expose_event_t *event) {
<a name="l00771"></a>00771         <span class="comment">/* event-&gt;count is the number of minimum remaining expose events for this window, so we</span>
<a name="l00772"></a>00772 <span class="comment">           skip all events but the last one */</span>
<a name="l00773"></a>00773         <span class="keywordflow">if</span> (event-&gt;count != 0)
<a name="l00774"></a>00774                 <span class="keywordflow">return</span> 1;
<a name="l00775"></a>00775         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;window = %08x\n&quot;</span>, event-&gt;window);
<a name="l00776"></a>00776 
<a name="l00777"></a>00777         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client = <a class="code" href="a00077.html#ae1529a1d81e2457f9a2402eda35735d7" title="Returns the value of the element of the given keyvalue-table with the given key.">table_get</a>(&amp;<a class="code" href="a00077.html#a38dffc58d761d720f7c63d35f2efd71d">by_parent</a>, event-&gt;window);
<a name="l00778"></a>00778         <span class="keywordflow">if</span> (client == NULL) {
<a name="l00779"></a>00779                 <span class="comment">/* There was no client in the table, so this is probably an expose event for</span>
<a name="l00780"></a>00780 <span class="comment">                   one of our stack_windows. */</span>
<a name="l00781"></a>00781                 <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;
<a name="l00782"></a>00782                 <a class="code" href="a00047.html#a05db87878125c27e3060dd641aa3b0f4">SLIST_FOREACH</a>(stack_win, &amp;<a class="code" href="a00071.html#ac38e5cddf6395c52d3755d7b368e4a2b">stack_wins</a>, stack_windows)
<a name="l00783"></a>00783                         <span class="keywordflow">if</span> (stack_win-&gt;<a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a> == event-&gt;window) {
<a name="l00784"></a>00784                                 <a class="code" href="a00069.html#a2a1fee0aebdaf2497fb52ea57a1033a4" title="Renders the given container.">render_container</a>(conn, stack_win-&gt;<a class="code" href="a00023.html#ad5f9402c2db288b0762e3a6467257dc8" title="Backpointer to the container this stack window is in.">container</a>);
<a name="l00785"></a>00785                                 <span class="keywordflow">return</span> 1;
<a name="l00786"></a>00786                         }
<a name="l00787"></a>00787 
<a name="l00788"></a>00788                 <span class="comment">/* …or one of the bars? */</span>
<a name="l00789"></a>00789                 <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output;
<a name="l00790"></a>00790                 <a class="code" href="a00047.html#a16e5fc168e7f3494d4b1df54447d871e">TAILQ_FOREACH</a>(output, &amp;<a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>, <a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>)
<a name="l00791"></a>00791                         <span class="keywordflow">if</span> (output-&gt;<a class="code" href="a00026.html#a479cef7d03401926d37ee89a6ee37aed" title="The bar window.">bar</a> == event-&gt;window)
<a name="l00792"></a>00792                                 <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>(conn);
<a name="l00793"></a>00793                 <span class="keywordflow">return</span> 1;
<a name="l00794"></a>00794         }
<a name="l00795"></a>00795 
<a name="l00796"></a>00796         <span class="keywordflow">if</span> (client-&gt;<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="l00797"></a>00797                 <span class="keywordflow">return</span> 1;
<a name="l00798"></a>00798 
<a name="l00799"></a>00799         <span class="keywordflow">if</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-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>, <span class="keyword">true</span>) == MODE_DEFAULT)
<a name="l00800"></a>00800                 <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-&gt;<a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, client-&gt;<a class="code" href="a00007.html#ab9525d9a134fa0d25a1352f8e58bee2e" title="The titlebar’s graphic context inside the frame.">titlegc</a>, 0, 0);
<a name="l00801"></a>00801         <span class="keywordflow">else</span> {
<a name="l00802"></a>00802                 uint32_t background_color;
<a name="l00803"></a>00803                 <span class="keywordflow">if</span> (client-&gt;<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="l00804"></a>00804                         background_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 class="code" href="a00009.html#a54065f4c7667110b00ece931b9a45348">background</a>;
<a name="l00805"></a>00805                 <span class="comment">/* Distinguish if the window is currently focused… */</span>
<a name="l00806"></a>00806                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="a00051.html#ac120dc3752e8ac2853ddd65d7737a2fd">CUR_CELL</a> != NULL &amp;&amp; <a class="code" href="a00051.html#ac120dc3752e8ac2853ddd65d7737a2fd">CUR_CELL</a>-&gt;currently_focused == client)
<a name="l00807"></a>00807                         background_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 class="code" href="a00009.html#a54065f4c7667110b00ece931b9a45348">background</a>;
<a name="l00808"></a>00808                 <span class="comment">/* …or if it is the focused window in a not focused container */</span>
<a name="l00809"></a>00809                 <span class="keywordflow">else</span> background_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 class="code" href="a00009.html#a54065f4c7667110b00ece931b9a45348">background</a>;
<a name="l00810"></a>00810 
<a name="l00811"></a>00811                 <span class="comment">/* Set foreground color to current focused color, line width to 2 */</span>
<a name="l00812"></a>00812                 uint32_t values[] = {background_color, 2};
<a name="l00813"></a>00813                 xcb_change_gc(conn, client-&gt;<a class="code" href="a00007.html#ab9525d9a134fa0d25a1352f8e58bee2e" title="The titlebar’s graphic context inside the frame.">titlegc</a>, XCB_GC_FOREGROUND | XCB_GC_LINE_WIDTH, values);
<a name="l00814"></a>00814 
<a name="l00815"></a>00815                 <span class="comment">/* Draw the border, the ±1 is for line width = 2 */</span>
<a name="l00816"></a>00816                 xcb_point_t points[] = {{1, 0},                                           <span class="comment">/* left upper edge */</span>
<a name="l00817"></a>00817                                         {1, client-&gt;<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},                       <span class="comment">/* left bottom edge */</span>
<a name="l00818"></a>00818                                         {client-&gt;<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, client-&gt;<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},    <span class="comment">/* right bottom edge */</span>
<a name="l00819"></a>00819                                         {client-&gt;<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, 0}};                       <span class="comment">/* right upper edge */</span>
<a name="l00820"></a>00820                 xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, client-&gt;<a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, client-&gt;<a class="code" href="a00007.html#ab9525d9a134fa0d25a1352f8e58bee2e" title="The titlebar’s graphic context inside the frame.">titlegc</a>, 4, points);
<a name="l00821"></a>00821 
<a name="l00822"></a>00822                 <span class="comment">/* Draw a black background */</span>
<a name="l00823"></a>00823                 <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-&gt;<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">&quot;#000000&quot;</span>));
<a name="l00824"></a>00824                 <span class="keywordflow">if</span> (client-&gt;<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 &amp;&amp; !client-&gt;<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="l00825"></a>00825                         xcb_rectangle_t crect = {1, 0, client-&gt;<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-&gt;<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};
<a name="l00826"></a>00826                         xcb_poly_fill_rectangle(conn, client-&gt;<a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, client-&gt;<a class="code" href="a00007.html#ab9525d9a134fa0d25a1352f8e58bee2e" title="The titlebar’s graphic context inside the frame.">titlegc</a>, 1, &amp;crect);
<a name="l00827"></a>00827                 } <span class="keywordflow">else</span> {
<a name="l00828"></a>00828                         xcb_rectangle_t crect = {2, 0, client-&gt;<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-&gt;<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="l00829"></a>00829                         xcb_poly_fill_rectangle(conn, client-&gt;<a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, client-&gt;<a class="code" href="a00007.html#ab9525d9a134fa0d25a1352f8e58bee2e" title="The titlebar’s graphic context inside the frame.">titlegc</a>, 1, &amp;crect);
<a name="l00830"></a>00830                 }
<a name="l00831"></a>00831         }
<a name="l00832"></a>00832         xcb_flush(conn);
<a name="l00833"></a>00833         <span class="keywordflow">return</span> 1;
<a name="l00834"></a>00834 }
<a name="l00835"></a>00835 
<a name="l00836"></a>00836 <span class="comment">/*</span>
<a name="l00837"></a>00837 <span class="comment"> * Handle client messages (EWMH)</span>
<a name="l00838"></a>00838 <span class="comment"> *</span>
<a name="l00839"></a>00839 <span class="comment"> */</span>
<a name="l00840"></a><a class="code" href="a00040.html#aa3ab831816987a97999392d7b54e4aee">00840</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#aa3ab831816987a97999392d7b54e4aee" title="Handle client messages (EWMH).">handle_client_message</a>(<span class="keywordtype">void</span> *data, xcb_connection_t *conn, xcb_client_message_event_t *event) {
<a name="l00841"></a>00841         <span class="keywordflow">if</span> (event-&gt;type == <a class="code" href="a00071.html#a327a6e1e08087496e9cb60b9e6f2a499">atoms</a>[<a class="code" href="a00054.html#a726ca809ffd3d67ab4b8476646f26635a555588bf6061a168cd7526a49dc4b0fa">_NET_WM_STATE</a>]) {
<a name="l00842"></a>00842                 <span class="keywordflow">if</span> (event-&gt;format != 32 || event-&gt;data.data32[1] != <a class="code" href="a00071.html#a327a6e1e08087496e9cb60b9e6f2a499">atoms</a>[<a class="code" href="a00054.html#a726ca809ffd3d67ab4b8476646f26635accdb5c5ee0d74dfffda6f4324a9abff5">_NET_WM_STATE_FULLSCREEN</a>])
<a name="l00843"></a>00843                         <span class="keywordflow">return</span> 0;
<a name="l00844"></a>00844 
<a name="l00845"></a>00845                 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client = <a class="code" href="a00077.html#ae1529a1d81e2457f9a2402eda35735d7" title="Returns the value of the element of the given keyvalue-table with the given key.">table_get</a>(&amp;<a class="code" href="a00077.html#aadfb9c6f265623f83355191df37c86c8">by_child</a>, event-&gt;window);
<a name="l00846"></a>00846                 <span class="keywordflow">if</span> (client == NULL)
<a name="l00847"></a>00847                         <span class="keywordflow">return</span> 0;
<a name="l00848"></a>00848 
<a name="l00849"></a>00849                 <span class="comment">/* Check if the fullscreen state should be toggled */</span>
<a name="l00850"></a>00850                 <span class="keywordflow">if</span> ((client-&gt;<a class="code" href="a00007.html#a9eeeb880b93223456c2eae445beccf94" title="fullscreen is pretty obvious">fullscreen</a> &amp;&amp;
<a name="l00851"></a>00851                      (event-&gt;data.data32[0] == <a class="code" href="a00054.html#a50026537f9f2afdb4a6a4f3bc5dad6d3">_NET_WM_STATE_REMOVE</a> ||
<a name="l00852"></a>00852                       event-&gt;data.data32[0] == <a class="code" href="a00054.html#a3e923d9844fde85f4a21c204f1f8dbd2">_NET_WM_STATE_TOGGLE</a>)) ||
<a name="l00853"></a>00853                     (!client-&gt;<a class="code" href="a00007.html#a9eeeb880b93223456c2eae445beccf94" title="fullscreen is pretty obvious">fullscreen</a> &amp;&amp;
<a name="l00854"></a>00854                      (event-&gt;data.data32[0] == <a class="code" href="a00054.html#af01584d4487719bb38125d1c5176a823">_NET_WM_STATE_ADD</a> ||
<a name="l00855"></a>00855                       event-&gt;data.data32[0] == <a class="code" href="a00054.html#a3e923d9844fde85f4a21c204f1f8dbd2">_NET_WM_STATE_TOGGLE</a>)))
<a name="l00856"></a>00856                         <a class="code" href="a00060.html#a6eaa454820104be1fe5a9c9f99ca46e9" title="Toggles fullscreen mode for the given client.">client_toggle_fullscreen</a>(conn, client);
<a name="l00857"></a>00857         } <span class="keywordflow">else</span> {
<a name="l00858"></a>00858                 <a class="code" href="a00044.html#a6828c68e0feb4b7fdfe0fc3ba9f3038b">ELOG</a>(<span class="stringliteral">&quot;unhandled clientmessage\n&quot;</span>);
<a name="l00859"></a>00859                 <span class="keywordflow">return</span> 0;
<a name="l00860"></a>00860         }
<a name="l00861"></a>00861 
<a name="l00862"></a>00862         <span class="keywordflow">return</span> 1;
<a name="l00863"></a>00863 }
<a name="l00864"></a>00864 
<a name="l00865"></a><a class="code" href="a00040.html#a9f7d547fc847e3dc11747b7d04077c46">00865</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#a9f7d547fc847e3dc11747b7d04077c46" title="Handles _NET_WM_WINDOW_TYPE changes.">handle_window_type</a>(<span class="keywordtype">void</span> *data, xcb_connection_t *conn, uint8_t state, xcb_window_t <a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a>,
<a name="l00866"></a>00866                         xcb_atom_t atom, xcb_get_property_reply_t *property) {
<a name="l00867"></a>00867         <span class="comment">/* TODO: Implement this one. To do this, implement a little test program which sleep(1)s</span>
<a name="l00868"></a>00868 <span class="comment">         before changing this property. */</span>
<a name="l00869"></a>00869         <a class="code" href="a00044.html#a6828c68e0feb4b7fdfe0fc3ba9f3038b">ELOG</a>(<span class="stringliteral">&quot;_NET_WM_WINDOW_TYPE changed, this is not yet implemented.\n&quot;</span>);
<a name="l00870"></a>00870         <span class="keywordflow">return</span> 0;
<a name="l00871"></a>00871 }
<a name="l00872"></a>00872 
<a name="l00873"></a>00873 <span class="comment">/*</span>
<a name="l00874"></a>00874 <span class="comment"> * Handles the size hints set by a window, but currently only the part necessary for displaying</span>
<a name="l00875"></a>00875 <span class="comment"> * clients proportionally inside their frames (mplayer for example)</span>
<a name="l00876"></a>00876 <span class="comment"> *</span>
<a name="l00877"></a>00877 <span class="comment"> * See ICCCM 4.1.2.3 for more details</span>
<a name="l00878"></a>00878 <span class="comment"> *</span>
<a name="l00879"></a>00879 <span class="comment"> */</span>
<a name="l00880"></a><a class="code" href="a00040.html#a37b6d4793feaffd6a4a25db3416c0d3f">00880</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#a37b6d4793feaffd6a4a25db3416c0d3f" title="Handles the size hints set by a window, but currently only the part necessary for...">handle_normal_hints</a>(<span class="keywordtype">void</span> *data, xcb_connection_t *conn, uint8_t state, xcb_window_t <a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a>,
<a name="l00881"></a>00881                         xcb_atom_t name, xcb_get_property_reply_t *reply) {
<a name="l00882"></a>00882         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client = <a class="code" href="a00077.html#ae1529a1d81e2457f9a2402eda35735d7" title="Returns the value of the element of the given keyvalue-table with the given key.">table_get</a>(&amp;<a class="code" href="a00077.html#aadfb9c6f265623f83355191df37c86c8">by_child</a>, window);
<a name="l00883"></a>00883         <span class="keywordflow">if</span> (client == NULL) {
<a name="l00884"></a>00884                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Received WM_SIZE_HINTS for unknown client\n&quot;</span>);
<a name="l00885"></a>00885                 <span class="keywordflow">return</span> 1;
<a name="l00886"></a>00886         }
<a name="l00887"></a>00887         xcb_size_hints_t size_hints;
<a name="l00888"></a>00888 
<a name="l00889"></a>00889         <a class="code" href="a00032.html#ad0346070ecde80a2181a4b87b533bea3" title="Pretty-prints the client’s information into the logfile.">CLIENT_LOG</a>(client);
<a name="l00890"></a>00890 
<a name="l00891"></a>00891         <span class="comment">/* If the hints were already in this event, use them, if not, request them */</span>
<a name="l00892"></a>00892         <span class="keywordflow">if</span> (reply != NULL)
<a name="l00893"></a>00893                 xcb_get_wm_size_hints_from_reply(&amp;size_hints, reply);
<a name="l00894"></a>00894         <span class="keywordflow">else</span>
<a name="l00895"></a>00895                 xcb_get_wm_normal_hints_reply(conn, xcb_get_wm_normal_hints_unchecked(conn, client-&gt;<a class="code" href="a00007.html#afba312b946fa74727ce619a33f8f28aa" title="The client’s window.">child</a>), &amp;size_hints, NULL);
<a name="l00896"></a>00896 
<a name="l00897"></a>00897         <span class="keywordflow">if</span> ((size_hints.flags &amp; XCB_SIZE_HINT_P_MIN_SIZE)) {
<a name="l00898"></a>00898                 <span class="comment">// TODO: Minimum size is not yet implemented</span>
<a name="l00899"></a>00899                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Minimum size: %d (width) x %d (height)\n&quot;</span>, size_hints.min_width, size_hints.min_height);
<a name="l00900"></a>00900         }
<a name="l00901"></a>00901 
<a name="l00902"></a>00902         <span class="keywordtype">bool</span> changed = <span class="keyword">false</span>;
<a name="l00903"></a>00903         <span class="keywordflow">if</span> ((size_hints.flags &amp; XCB_SIZE_HINT_P_RESIZE_INC)) {
<a name="l00904"></a>00904                 <span class="keywordflow">if</span> (size_hints.width_inc &gt; 0 &amp;&amp; size_hints.width_inc &lt; 0xFFFF)
<a name="l00905"></a>00905                         <span class="keywordflow">if</span> (client-&gt;<a class="code" href="a00007.html#a80130d5f48f9c1db1e9206b578873002" title="contains the minimum increment size as specified for the window (in pixels).">width_increment</a> != size_hints.width_inc) {
<a name="l00906"></a>00906                                 client-&gt;<a class="code" href="a00007.html#a80130d5f48f9c1db1e9206b578873002" title="contains the minimum increment size as specified for the window (in pixels).">width_increment</a> = size_hints.width_inc;
<a name="l00907"></a>00907                                 changed = <span class="keyword">true</span>;
<a name="l00908"></a>00908                         }
<a name="l00909"></a>00909                 <span class="keywordflow">if</span> (size_hints.height_inc &gt; 0 &amp;&amp; size_hints.height_inc &lt; 0xFFFF)
<a name="l00910"></a>00910                         <span class="keywordflow">if</span> (client-&gt;<a class="code" href="a00007.html#aec47a7c174216266483e8a6a9e51d2f7">height_increment</a> != size_hints.height_inc) {
<a name="l00911"></a>00911                                 client-&gt;<a class="code" href="a00007.html#aec47a7c174216266483e8a6a9e51d2f7">height_increment</a> = size_hints.height_inc;
<a name="l00912"></a>00912                                 changed = <span class="keyword">true</span>;
<a name="l00913"></a>00913                         }
<a name="l00914"></a>00914 
<a name="l00915"></a>00915                 <span class="keywordflow">if</span> (changed)
<a name="l00916"></a>00916                         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;resize increments changed\n&quot;</span>);
<a name="l00917"></a>00917         }
<a name="l00918"></a>00918 
<a name="l00919"></a>00919         <span class="keywordtype">int</span> base_width = 0, base_height = 0;
<a name="l00920"></a>00920 
<a name="l00921"></a>00921         <span class="comment">/* base_width/height are the desired size of the window.</span>
<a name="l00922"></a>00922 <span class="comment">           We check if either the program-specified size or the program-specified</span>
<a name="l00923"></a>00923 <span class="comment">           min-size is available */</span>
<a name="l00924"></a>00924         <span class="keywordflow">if</span> (size_hints.flags &amp; XCB_SIZE_HINT_BASE_SIZE) {
<a name="l00925"></a>00925                 base_width = size_hints.base_width;
<a name="l00926"></a>00926                 base_height = size_hints.base_height;
<a name="l00927"></a>00927         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (size_hints.flags &amp; XCB_SIZE_HINT_P_MIN_SIZE) {
<a name="l00928"></a>00928                 <span class="comment">/* TODO: is this right? icccm says not */</span>
<a name="l00929"></a>00929                 base_width = size_hints.min_width;
<a name="l00930"></a>00930                 base_height = size_hints.min_height;
<a name="l00931"></a>00931         }
<a name="l00932"></a>00932 
<a name="l00933"></a>00933         <span class="keywordflow">if</span> (base_width != client-&gt;<a class="code" href="a00007.html#a51ffa9095f0fba59737c1252cf0031cb">base_width</a> ||
<a name="l00934"></a>00934             base_height != client-&gt;<a class="code" href="a00007.html#a92916a2b042c07b01eb6e3a4269413cc">base_height</a>) {
<a name="l00935"></a>00935                 client-&gt;<a class="code" href="a00007.html#a51ffa9095f0fba59737c1252cf0031cb">base_width</a> = base_width;
<a name="l00936"></a>00936                 client-&gt;<a class="code" href="a00007.html#a92916a2b042c07b01eb6e3a4269413cc">base_height</a> = base_height;
<a name="l00937"></a>00937                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;client&#39;s base_height changed to %d\n&quot;</span>, base_height);
<a name="l00938"></a>00938                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;client&#39;s base_width changed to %d\n&quot;</span>, base_width);
<a name="l00939"></a>00939                 changed = <span class="keyword">true</span>;
<a name="l00940"></a>00940         }
<a name="l00941"></a>00941 
<a name="l00942"></a>00942         <span class="keywordflow">if</span> (changed) {
<a name="l00943"></a>00943                 <span class="keywordflow">if</span> (client-&gt;<a class="code" href="a00007.html#a9eeeb880b93223456c2eae445beccf94" title="fullscreen is pretty obvious">fullscreen</a>)
<a name="l00944"></a>00944                         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Not resizing client, it is in fullscreen mode\n&quot;</span>);
<a name="l00945"></a>00945                 <span class="keywordflow">else</span> {
<a name="l00946"></a>00946                         <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="l00947"></a>00947                         xcb_flush(conn);
<a name="l00948"></a>00948                 }
<a name="l00949"></a>00949         }
<a name="l00950"></a>00950 
<a name="l00951"></a>00951         <span class="comment">/* If no aspect ratio was set or if it was invalid, we ignore the hints */</span>
<a name="l00952"></a>00952         <span class="keywordflow">if</span> (!(size_hints.flags &amp; XCB_SIZE_HINT_P_ASPECT) ||
<a name="l00953"></a>00953             (size_hints.min_aspect_num &lt;= 0) ||
<a name="l00954"></a>00954             (size_hints.min_aspect_den &lt;= 0)) {
<a name="l00955"></a>00955                 <span class="keywordflow">return</span> 1;
<a name="l00956"></a>00956         }
<a name="l00957"></a>00957 
<a name="l00958"></a>00958         <span class="keywordtype">double</span> width = client-&gt;<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> - base_width;
<a name="l00959"></a>00959         <span class="keywordtype">double</span> height = client-&gt;<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> - base_height;
<a name="l00960"></a>00960         <span class="comment">/* Convert numerator/denominator to a double */</span>
<a name="l00961"></a>00961         <span class="keywordtype">double</span> min_aspect = (double)size_hints.min_aspect_num / size_hints.min_aspect_den;
<a name="l00962"></a>00962         <span class="keywordtype">double</span> max_aspect = (<span class="keywordtype">double</span>)size_hints.max_aspect_num / size_hints.min_aspect_den;
<a name="l00963"></a>00963 
<a name="l00964"></a>00964         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Aspect ratio set: minimum %f, maximum %f\n&quot;</span>, min_aspect, max_aspect);
<a name="l00965"></a>00965         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;width = %f, height = %f\n&quot;</span>, width, height);
<a name="l00966"></a>00966 
<a name="l00967"></a>00967         <span class="comment">/* Sanity checks, this is user-input, in a way */</span>
<a name="l00968"></a>00968         <span class="keywordflow">if</span> (max_aspect &lt;= 0 || min_aspect &lt;= 0 || height == 0 || (width / height) &lt;= 0)
<a name="l00969"></a>00969                 <span class="keywordflow">return</span> 1;
<a name="l00970"></a>00970 
<a name="l00971"></a>00971         <span class="comment">/* Check if we need to set proportional_* variables using the correct ratio */</span>
<a name="l00972"></a>00972         <span class="keywordflow">if</span> ((width / height) &lt; min_aspect) {
<a name="l00973"></a>00973                 client-&gt;<a class="code" href="a00007.html#a2324d36fb1ad3c0d9cae70f975cd3fe4">proportional_width</a> = width;
<a name="l00974"></a>00974                 client-&gt;<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> = width / min_aspect;
<a name="l00975"></a>00975         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((width / height) &gt; max_aspect) {
<a name="l00976"></a>00976                 client-&gt;<a class="code" href="a00007.html#a2324d36fb1ad3c0d9cae70f975cd3fe4">proportional_width</a> = width;
<a name="l00977"></a>00977                 client-&gt;<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> = width / max_aspect;
<a name="l00978"></a>00978         } <span class="keywordflow">else</span> <span class="keywordflow">return</span> 1;
<a name="l00979"></a>00979 
<a name="l00980"></a>00980         client-&gt;<a class="code" href="a00007.html#a873c62703ab51afe96b38df2b30ffa66">force_reconfigure</a> = <span class="keyword">true</span>;
<a name="l00981"></a>00981 
<a name="l00982"></a>00982         <span class="keywordflow">if</span> (client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a> != NULL &amp;&amp; <a class="code" href="a00078.html#a7a4e9d7994d904776ead4c8fc1b22091" title="Returns true if the workspace is currently visible.">workspace_is_visible</a>(client-&gt;<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="l00983"></a>00983                 <a class="code" href="a00069.html#a2a1fee0aebdaf2497fb52ea57a1033a4" title="Renders the given container.">render_container</a>(conn, client-&gt;<a class="code" href="a00007.html#a022927d41b4140a623f72fa360c46a17" title="Backpointer.">container</a>);
<a name="l00984"></a>00984                 xcb_flush(conn);
<a name="l00985"></a>00985         }
<a name="l00986"></a>00986 
<a name="l00987"></a>00987         <span class="keywordflow">return</span> 1;
<a name="l00988"></a>00988 }
<a name="l00989"></a>00989 
<a name="l00990"></a>00990 <span class="comment">/*</span>
<a name="l00991"></a>00991 <span class="comment"> * Handles the WM_HINTS property for extracting the urgency state of the window.</span>
<a name="l00992"></a>00992 <span class="comment"> *</span>
<a name="l00993"></a>00993 <span class="comment"> */</span>
<a name="l00994"></a><a class="code" href="a00040.html#a875fb3362eee6f327b57a6033ed29a51">00994</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#a875fb3362eee6f327b57a6033ed29a51" title="Handles the WM_HINTS property for extracting the urgency state of the window.">handle_hints</a>(<span class="keywordtype">void</span> *data, xcb_connection_t *conn, uint8_t state, xcb_window_t <a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a>,
<a name="l00995"></a>00995                   xcb_atom_t name, xcb_get_property_reply_t *reply) {
<a name="l00996"></a>00996         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client = <a class="code" href="a00077.html#ae1529a1d81e2457f9a2402eda35735d7" title="Returns the value of the element of the given keyvalue-table with the given key.">table_get</a>(&amp;<a class="code" href="a00077.html#aadfb9c6f265623f83355191df37c86c8">by_child</a>, window);
<a name="l00997"></a>00997         <span class="keywordflow">if</span> (client == NULL) {
<a name="l00998"></a>00998                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Received WM_HINTS for unknown client\n&quot;</span>);
<a name="l00999"></a>00999                 <span class="keywordflow">return</span> 1;
<a name="l01000"></a>01000         }
<a name="l01001"></a>01001         xcb_wm_hints_t hints;
<a name="l01002"></a>01002 
<a name="l01003"></a>01003         <span class="keywordflow">if</span> (reply != NULL) {
<a name="l01004"></a>01004                 <span class="keywordflow">if</span> (!xcb_get_wm_hints_from_reply(&amp;hints, reply))
<a name="l01005"></a>01005                         <span class="keywordflow">return</span> 1;
<a name="l01006"></a>01006         } <span class="keywordflow">else</span> {
<a name="l01007"></a>01007                 <span class="keywordflow">if</span> (!xcb_get_wm_hints_reply(conn, xcb_get_wm_hints_unchecked(conn, client-&gt;<a class="code" href="a00007.html#afba312b946fa74727ce619a33f8f28aa" title="The client’s window.">child</a>), &amp;hints, NULL))
<a name="l01008"></a>01008                         <span class="keywordflow">return</span> 1;
<a name="l01009"></a>01009         }
<a name="l01010"></a>01010 
<a name="l01011"></a>01011         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *last_focused = <a class="code" href="a00047.html#a91bac7d0d32e3ec56bc579ace45ed8cd">SLIST_FIRST</a>(&amp;(<a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;focus_stack));
<a name="l01012"></a>01012         <span class="keywordflow">if</span> (!client-&gt;<a class="code" href="a00007.html#ad169bd46b1c1edf6f7cddf2c0c5306c7" title="True if the client set the urgency flag in its WM_HINTS property.">urgent</a> &amp;&amp; client == last_focused) {
<a name="l01013"></a>01013                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Ignoring urgency flag for current client\n&quot;</span>);
<a name="l01014"></a>01014                 <span class="keywordflow">return</span> 1;
<a name="l01015"></a>01015         }
<a name="l01016"></a>01016 
<a name="l01017"></a>01017         <span class="comment">/* Update the flag on the client directly */</span>
<a name="l01018"></a>01018         client-&gt;<a class="code" href="a00007.html#ad169bd46b1c1edf6f7cddf2c0c5306c7" title="True if the client set the urgency flag in its WM_HINTS property.">urgent</a> = (xcb_wm_hints_get_urgency(&amp;hints) != 0);
<a name="l01019"></a>01019         <a class="code" href="a00032.html#ad0346070ecde80a2181a4b87b533bea3" title="Pretty-prints the client’s information into the logfile.">CLIENT_LOG</a>(client);
<a name="l01020"></a>01020         <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">&quot;Urgency flag changed to %d\n&quot;</span>, client-&gt;<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="l01021"></a>01021 
<a name="l01022"></a>01022         <a class="code" href="a00078.html#a2c43568cc3492bd24992d93f4552bbe9" title="Goes through all clients on the given workspace and updates the workspace’s urgent...">workspace_update_urgent_flag</a>(client-&gt;<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="l01023"></a>01023 
<a name="l01024"></a>01024         <span class="comment">/* If the workspace this client is on is not visible, we need to redraw</span>
<a name="l01025"></a>01025 <span class="comment">         * the workspace bar */</span>
<a name="l01026"></a>01026         <span class="keywordflow">if</span> (!<a class="code" href="a00078.html#a7a4e9d7994d904776ead4c8fc1b22091" title="Returns true if the workspace is currently visible.">workspace_is_visible</a>(client-&gt;<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="l01027"></a>01027                 <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output = client-&gt;<a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a>-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>;
<a name="l01028"></a>01028                 <a class="code" href="a00069.html#ab3e248d886080e290648c0d791a40b64" title="Renders the given workspace on the given screen.">render_workspace</a>(conn, output, output-&gt;<a class="code" href="a00026.html#a9bcf702b65d8f47f98eafbefff529ffe" title="Current workspace selected on this virtual screen.">current_workspace</a>);
<a name="l01029"></a>01029                 xcb_flush(conn);
<a name="l01030"></a>01030         } <span class="keywordflow">else</span> {
<a name="l01031"></a>01031                 <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="l01032"></a>01032         }
<a name="l01033"></a>01033 
<a name="l01034"></a>01034         <span class="keywordflow">return</span> 1;
<a name="l01035"></a>01035 }
<a name="l01036"></a>01036 
<a name="l01037"></a>01037 <span class="comment">/*</span>
<a name="l01038"></a>01038 <span class="comment"> * Handles the transient for hints set by a window, signalizing that this window is a popup window</span>
<a name="l01039"></a>01039 <span class="comment"> * for some other window.</span>
<a name="l01040"></a>01040 <span class="comment"> *</span>
<a name="l01041"></a>01041 <span class="comment"> * See ICCCM 4.1.2.6 for more details</span>
<a name="l01042"></a>01042 <span class="comment"> *</span>
<a name="l01043"></a>01043 <span class="comment"> */</span>
<a name="l01044"></a><a class="code" href="a00040.html#a770ba9d5b30d95d843fe637e2b3910eb">01044</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#a770ba9d5b30d95d843fe637e2b3910eb" title="Handles the transient for hints set by a window, signalizing that this window is...">handle_transient_for</a>(<span class="keywordtype">void</span> *data, xcb_connection_t *conn, uint8_t state, xcb_window_t <a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a>,
<a name="l01045"></a>01045                          xcb_atom_t name, xcb_get_property_reply_t *reply) {
<a name="l01046"></a>01046         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client = <a class="code" href="a00077.html#ae1529a1d81e2457f9a2402eda35735d7" title="Returns the value of the element of the given keyvalue-table with the given key.">table_get</a>(&amp;<a class="code" href="a00077.html#aadfb9c6f265623f83355191df37c86c8">by_child</a>, window);
<a name="l01047"></a>01047         <span class="keywordflow">if</span> (client == NULL) {
<a name="l01048"></a>01048                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;No such client\n&quot;</span>);
<a name="l01049"></a>01049                 <span class="keywordflow">return</span> 1;
<a name="l01050"></a>01050         }
<a name="l01051"></a>01051 
<a name="l01052"></a>01052         xcb_window_t transient_for;
<a name="l01053"></a>01053 
<a name="l01054"></a>01054         <span class="keywordflow">if</span> (reply != NULL) {
<a name="l01055"></a>01055                 <span class="keywordflow">if</span> (!xcb_get_wm_transient_for_from_reply(&amp;transient_for, reply))
<a name="l01056"></a>01056                         <span class="keywordflow">return</span> 1;
<a name="l01057"></a>01057         } <span class="keywordflow">else</span> {
<a name="l01058"></a>01058                 <span class="keywordflow">if</span> (!xcb_get_wm_transient_for_reply(conn, xcb_get_wm_transient_for_unchecked(conn, window),
<a name="l01059"></a>01059                                                     &amp;transient_for, NULL))
<a name="l01060"></a>01060                         <span class="keywordflow">return</span> 1;
<a name="l01061"></a>01061         }
<a name="l01062"></a>01062 
<a name="l01063"></a>01063         <span class="keywordflow">if</span> (client-&gt;<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_OFF) {
<a name="l01064"></a>01064                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;This is a popup window, putting into floating\n&quot;</span>);
<a name="l01065"></a>01065                 <a class="code" href="a00066.html#aa8af48aadcf7753f5efc97b65a4cfd91" title="Enters floating mode for the given client.">toggle_floating_mode</a>(conn, client, <span class="keyword">true</span>);
<a name="l01066"></a>01066         }
<a name="l01067"></a>01067 
<a name="l01068"></a>01068         <span class="keywordflow">return</span> 1;
<a name="l01069"></a>01069 }
<a name="l01070"></a>01070 
<a name="l01071"></a>01071 <span class="comment">/*</span>
<a name="l01072"></a>01072 <span class="comment"> * Handles changes of the WM_CLIENT_LEADER atom which specifies if this is a</span>
<a name="l01073"></a>01073 <span class="comment"> * toolwindow (or similar) and to which window it belongs (logical parent).</span>
<a name="l01074"></a>01074 <span class="comment"> *</span>
<a name="l01075"></a>01075 <span class="comment"> */</span>
<a name="l01076"></a><a class="code" href="a00040.html#a3651e94bba743f088fd461a90892ff2f">01076</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#a3651e94bba743f088fd461a90892ff2f" title="Handles changes of the WM_CLIENT_LEADER atom which specifies if this is a toolwindow...">handle_clientleader_change</a>(<span class="keywordtype">void</span> *data, xcb_connection_t *conn, uint8_t state, xcb_window_t <a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a>,
<a name="l01077"></a>01077                         xcb_atom_t name, xcb_get_property_reply_t *prop) {
<a name="l01078"></a>01078         <span class="keywordflow">if</span> (prop == NULL) {
<a name="l01079"></a>01079                 prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn,
<a name="l01080"></a>01080                                         <span class="keyword">false</span>, window, <a class="code" href="a00054.html#a726ca809ffd3d67ab4b8476646f26635a13d4dbc6987347bcc7c535570b4e6c2b">WM_CLIENT_LEADER</a>, WINDOW, 0, 32), NULL);
<a name="l01081"></a>01081                 <span class="keywordflow">if</span> (prop == NULL)
<a name="l01082"></a>01082                         <span class="keywordflow">return</span> 1;
<a name="l01083"></a>01083         }
<a name="l01084"></a>01084 
<a name="l01085"></a>01085         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client = <a class="code" href="a00077.html#ae1529a1d81e2457f9a2402eda35735d7" title="Returns the value of the element of the given keyvalue-table with the given key.">table_get</a>(&amp;<a class="code" href="a00077.html#aadfb9c6f265623f83355191df37c86c8">by_child</a>, window);
<a name="l01086"></a>01086         <span class="keywordflow">if</span> (client == NULL)
<a name="l01087"></a>01087                 <span class="keywordflow">return</span> 1;
<a name="l01088"></a>01088 
<a name="l01089"></a>01089         xcb_window_t *leader = xcb_get_property_value(prop);
<a name="l01090"></a>01090         <span class="keywordflow">if</span> (leader == NULL)
<a name="l01091"></a>01091                 <span class="keywordflow">return</span> 1;
<a name="l01092"></a>01092 
<a name="l01093"></a>01093         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Client leader changed to %08x\n&quot;</span>, *leader);
<a name="l01094"></a>01094 
<a name="l01095"></a>01095         client-&gt;<a class="code" href="a00007.html#a0385211b35d62a177e4eed5e58fbb693" title="Holds the xcb_window_t (just an ID) for the leader window (logical parent for toolwindows...">leader</a> = *leader;
<a name="l01096"></a>01096 
<a name="l01097"></a>01097         <span class="keywordflow">return</span> 1;
<a name="l01098"></a>01098 }
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated by&nbsp;
<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>