Sophie

Sophie

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

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/click.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/click.c</h1><a href="a00059.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * vim:ts=8:expandtab</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * i3 - an improved dynamic tiling window manager</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * © 2009-2010 Michael Stapelberg and contributors</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> * See file LICENSE for license information.</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> * src/click.c: Contains the handlers for button press (mouse click) events</span>
<a name="l00011"></a>00011 <span class="comment"> *              because they are quite large.</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> */</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &lt;assert.h&gt;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;time.h&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;stdbool.h&gt;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;math.h&gt;</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;xcb/xcb.h&gt;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;xcb/xcb_atom.h&gt;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;xcb/xcb_icccm.h&gt;</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;X11/XKBlib.h&gt;</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="preprocessor">#include &quot;<a class="code" href="a00041.html">i3.h</a>&quot;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &quot;<a class="code" href="a00047.html">queue.h</a>&quot;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &quot;<a class="code" href="a00051.html">table.h</a>&quot;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &quot;<a class="code" href="a00034.html">config.h</a>&quot;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &quot;<a class="code" href="a00052.html">util.h</a>&quot;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &quot;<a class="code" href="a00054.html">xcb.h</a>&quot;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &quot;<a class="code" href="a00032.html">client.h</a>&quot;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &quot;<a class="code" href="a00053.html">workspace.h</a>&quot;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &quot;<a class="code" href="a00033.html">commands.h</a>&quot;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &quot;<a class="code" href="a00039.html">floating.h</a>&quot;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &quot;<a class="code" href="a00049.html">resize.h</a>&quot;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &quot;<a class="code" href="a00044.html">log.h</a>&quot;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &quot;<a class="code" href="a00048.html">randr.h</a>&quot;</span>
<a name="l00041"></a>00041 
<a name="l00042"></a><a class="code" href="a00059.html#a50998b0795a55494eee733fb83743161">00042</a> <span class="keyword">static</span> <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> *<a class="code" href="a00059.html#a50998b0795a55494eee733fb83743161">get_stack_window</a>(xcb_window_t window_id) {
<a name="l00043"></a>00043         <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> *current;
<a name="l00044"></a>00044 
<a name="l00045"></a>00045         <a class="code" href="a00047.html#a05db87878125c27e3060dd641aa3b0f4">SLIST_FOREACH</a>(current, &amp;<a class="code" href="a00071.html#ac38e5cddf6395c52d3755d7b368e4a2b">stack_wins</a>, stack_windows) {
<a name="l00046"></a>00046                 <span class="keywordflow">if</span> (current-&gt;<a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a> != window_id)
<a name="l00047"></a>00047                         <span class="keywordflow">continue</span>;
<a name="l00048"></a>00048 
<a name="l00049"></a>00049                 <span class="keywordflow">return</span> current;
<a name="l00050"></a>00050         }
<a name="l00051"></a>00051 
<a name="l00052"></a>00052         <span class="keywordflow">return</span> NULL;
<a name="l00053"></a>00053 }
<a name="l00054"></a>00054 
<a name="l00055"></a>00055 <span class="comment">/*</span>
<a name="l00056"></a>00056 <span class="comment"> * Checks if the button press was on a stack window, handles focus setting and returns true</span>
<a name="l00057"></a>00057 <span class="comment"> * if so, or false otherwise.</span>
<a name="l00058"></a>00058 <span class="comment"> *</span>
<a name="l00059"></a>00059 <span class="comment"> */</span>
<a name="l00060"></a><a class="code" href="a00059.html#a2d18c18dfda759f1c2c3abf2819e9bc8">00060</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="a00059.html#a2d18c18dfda759f1c2c3abf2819e9bc8">button_press_stackwin</a>(xcb_connection_t *conn, xcb_button_press_event_t *event) {
<a name="l00061"></a>00061         <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="l00062"></a>00062 
<a name="l00063"></a>00063         <span class="comment">/* If we find a corresponding stack window, we can handle the event */</span>
<a name="l00064"></a>00064         <span class="keywordflow">if</span> ((stack_win = <a class="code" href="a00059.html#a50998b0795a55494eee733fb83743161">get_stack_window</a>(event-&gt;event)) == NULL)
<a name="l00065"></a>00065                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00066"></a>00066 
<a name="l00067"></a>00067         <span class="comment">/* A stack window was clicked, we check if it was button4 or button5</span>
<a name="l00068"></a>00068 <span class="comment">           which are scroll up / scroll down. */</span>
<a name="l00069"></a>00069         <span class="keywordflow">if</span> (event-&gt;detail == XCB_BUTTON_INDEX_4 || event-&gt;detail == XCB_BUTTON_INDEX_5) {
<a name="l00070"></a>00070                 <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6b">direction_t</a> direction = (<span class="keyword">event</span>-&gt;detail == XCB_BUTTON_INDEX_4 ? <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6bae8b5f804952c228061ed205833ae7083">D_UP</a> : <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6baee5b9399d89b358fa6fb0adef67d3a4b">D_DOWN</a>);
<a name="l00071"></a>00071                 <a class="code" href="a00061.html#a66ea1b5aca9851f7dae1d949fc8e8894">focus_window_in_container</a>(conn, <a class="code" href="a00051.html#ac120dc3752e8ac2853ddd65d7737a2fd">CUR_CELL</a>, direction);
<a name="l00072"></a>00072                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00073"></a>00073         }
<a name="l00074"></a>00074 
<a name="l00075"></a>00075         <span class="comment">/* It was no scrolling, so we calculate the destination client by</span>
<a name="l00076"></a>00076 <span class="comment">           dividing the Y position of the event through the height of a window</span>
<a name="l00077"></a>00077 <span class="comment">           decoration and then set the focus to this client. */</span>
<a name="l00078"></a>00078         <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="l00079"></a>00079         <span class="keywordtype">int</span> decoration_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);
<a name="l00080"></a>00080         <span class="keywordtype">int</span> destination = (<span class="keyword">event</span>-&gt;event_y / decoration_height),
<a name="l00081"></a>00081             c = 0,
<a name="l00082"></a>00082             num_clients = 0;
<a name="l00083"></a>00083         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client;
<a name="l00084"></a>00084         <a class="code" href="a00013.html" title="A container is either in default, stacking or tabbed mode.">Container</a> *<a class="code" href="a00023.html#ad5f9402c2db288b0762e3a6467257dc8" title="Backpointer to the container this stack window is in.">container</a> = stack_win-&gt;<a class="code" href="a00023.html#ad5f9402c2db288b0762e3a6467257dc8" title="Backpointer to the container this stack window is in.">container</a>;
<a name="l00085"></a>00085 
<a name="l00086"></a>00086         <a class="code" href="a00047.html#ae97f4eb5724477c63699fafea4614b46">CIRCLEQ_FOREACH</a>(client, &amp;(container-&gt;clients), clients)
<a name="l00087"></a>00087                 num_clients++;
<a name="l00088"></a>00088 
<a name="l00089"></a>00089         <span class="comment">/* If we don’t have any clients in this container, we cannot do</span>
<a name="l00090"></a>00090 <span class="comment">         * anything useful anyways. */</span>
<a name="l00091"></a>00091         <span class="keywordflow">if</span> (num_clients == 0)
<a name="l00092"></a>00092                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00093"></a>00093 
<a name="l00094"></a>00094         <span class="keywordflow">if</span> (container-&gt;<a class="code" href="a00013.html#ac094306ab77e360742aba04d7cbd0fe6">mode</a> == MODE_TABBED)
<a name="l00095"></a>00095                 destination = (<span class="keyword">event</span>-&gt;event_x / (container-&gt;<a class="code" href="a00013.html#af9b566fc3a8a208897503254747ae720">width</a> / num_clients));
<a name="l00096"></a>00096         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (container-&gt;<a class="code" href="a00013.html#ac094306ab77e360742aba04d7cbd0fe6">mode</a> == MODE_STACK &amp;&amp;
<a name="l00097"></a>00097                  container-&gt;<a class="code" href="a00013.html#a8d99003f0507fe6554189568f84505be">stack_limit</a> != STACK_LIMIT_NONE) {
<a name="l00098"></a>00098                 <span class="keywordflow">if</span> (container-&gt;<a class="code" href="a00013.html#a8d99003f0507fe6554189568f84505be">stack_limit</a> == STACK_LIMIT_COLS) {
<a name="l00099"></a>00099                         <span class="keywordtype">int</span> wrap = ceil((<span class="keywordtype">float</span>)num_clients / container-&gt;<a class="code" href="a00013.html#ad0e9b50a01da48b57f9ecbe97bc00582">stack_limit_value</a>);
<a name="l00100"></a>00100                         <span class="keywordtype">int</span> clicked_column = (<span class="keyword">event</span>-&gt;event_x / (stack_win-&gt;<a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> / container-&gt;<a class="code" href="a00013.html#ad0e9b50a01da48b57f9ecbe97bc00582">stack_limit_value</a>));
<a name="l00101"></a>00101                         <span class="keywordtype">int</span> clicked_row = (<span class="keyword">event</span>-&gt;event_y / decoration_height);
<a name="l00102"></a>00102                         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;clicked on column %d, row %d\n&quot;</span>, clicked_column, clicked_row);
<a name="l00103"></a>00103                         destination = (wrap * clicked_column) + clicked_row;
<a name="l00104"></a>00104                 } <span class="keywordflow">else</span> {
<a name="l00105"></a>00105                         <span class="keywordtype">int</span> width = (stack_win-&gt;<a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> / ceil((<span class="keywordtype">float</span>)num_clients / container-&gt;<a class="code" href="a00013.html#ad0e9b50a01da48b57f9ecbe97bc00582">stack_limit_value</a>));
<a name="l00106"></a>00106                         <span class="keywordtype">int</span> clicked_column = (<span class="keyword">event</span>-&gt;event_x / width);
<a name="l00107"></a>00107                         <span class="keywordtype">int</span> clicked_row = (<span class="keyword">event</span>-&gt;event_y / decoration_height);
<a name="l00108"></a>00108                         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;clicked on column %d, row %d\n&quot;</span>, clicked_column, clicked_row);
<a name="l00109"></a>00109                         destination = (container-&gt;<a class="code" href="a00013.html#ad0e9b50a01da48b57f9ecbe97bc00582">stack_limit_value</a> * clicked_column) + clicked_row;
<a name="l00110"></a>00110                 }
<a name="l00111"></a>00111         }
<a name="l00112"></a>00112 
<a name="l00113"></a>00113         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Click on stack_win for client %d\n&quot;</span>, destination);
<a name="l00114"></a>00114         <a class="code" href="a00047.html#ae97f4eb5724477c63699fafea4614b46">CIRCLEQ_FOREACH</a>(client, &amp;(stack_win-&gt;<a class="code" href="a00023.html#ad5f9402c2db288b0762e3a6467257dc8" title="Backpointer to the container this stack window is in.">container</a>-&gt;clients), clients)
<a name="l00115"></a>00115                 <span class="keywordflow">if</span> (c++ == destination) {
<a name="l00116"></a>00116                         <a class="code" href="a00077.html#a323dcf30475bb3bf165100e74d225b48" title="Sets the given client as focused by updating the data structures correctly, updating...">set_focus</a>(conn, client, <span class="keyword">true</span>);
<a name="l00117"></a>00117                         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00118"></a>00118                 }
<a name="l00119"></a>00119 
<a name="l00120"></a>00120         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00121"></a>00121 }
<a name="l00122"></a>00122 
<a name="l00123"></a>00123 <span class="comment">/*</span>
<a name="l00124"></a>00124 <span class="comment"> * Checks if the button press was on a bar, switches to the workspace and returns true</span>
<a name="l00125"></a>00125 <span class="comment"> * if so, or false otherwise.</span>
<a name="l00126"></a>00126 <span class="comment"> *</span>
<a name="l00127"></a>00127 <span class="comment"> */</span>
<a name="l00128"></a><a class="code" href="a00059.html#aae48d4ad42c0215fd08b8b0df6924097">00128</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="a00059.html#aae48d4ad42c0215fd08b8b0df6924097">button_press_bar</a>(xcb_connection_t *conn, xcb_button_press_event_t *event) {
<a name="l00129"></a>00129         <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output;
<a name="l00130"></a>00130         <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="l00131"></a>00131                 <span class="keywordflow">if</span> (output-&gt;<a class="code" href="a00026.html#a479cef7d03401926d37ee89a6ee37aed" title="The bar window.">bar</a> != event-&gt;event)
<a name="l00132"></a>00132                         <span class="keywordflow">continue</span>;
<a name="l00133"></a>00133 
<a name="l00134"></a>00134                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Click on a bar\n&quot;</span>);
<a name="l00135"></a>00135 
<a name="l00136"></a>00136                 <span class="comment">/* Check if the button was one of button4 or button5 (scroll up / scroll down) */</span>
<a name="l00137"></a>00137                 <span class="keywordflow">if</span> (event-&gt;detail == XCB_BUTTON_INDEX_4 || event-&gt;detail == XCB_BUTTON_INDEX_5) {
<a name="l00138"></a>00138                         <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws = <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>;
<a name="l00139"></a>00139                         <span class="keywordflow">if</span> (event-&gt;detail == XCB_BUTTON_INDEX_5) {
<a name="l00140"></a>00140                                 <span class="keywordflow">while</span> ((ws = <a class="code" href="a00047.html#abd57fe9bdea6007a602f8c7d61bd5265">TAILQ_NEXT</a>(ws, <a class="code" href="a00076.html#afb45f3a3a9c66c3e3a5e4d372ae24da7">workspaces</a>)) != <a class="code" href="a00047.html#a4322b8461a6ab7632435ff4f57bb3a2e">TAILQ_END</a>(workspaces_head)) {
<a name="l00141"></a>00141                                         <span class="keywordflow">if</span> (ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a> == output) {
<a name="l00142"></a>00142                                                 <a class="code" href="a00078.html#a2f31983877c705919ed85c985220855e" title="Switches to the given workspace.">workspace_show</a>(conn, ws-&gt;<a class="code" href="a00025.html#a7dfb9b375b2740db75bb82eb0b2be41d" title="Number of this workspace, starting from 0.">num</a> + 1);
<a name="l00143"></a>00143                                                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00144"></a>00144                                         }
<a name="l00145"></a>00145                                 }
<a name="l00146"></a>00146                         } <span class="keywordflow">else</span> {
<a name="l00147"></a>00147                                 <span class="keywordflow">while</span> ((ws = <a class="code" href="a00047.html#a524f93a0c21c390683fab4c27e840a10">TAILQ_PREV</a>(ws, workspaces_head, <a class="code" href="a00076.html#afb45f3a3a9c66c3e3a5e4d372ae24da7">workspaces</a>)) != <a class="code" href="a00047.html#a4322b8461a6ab7632435ff4f57bb3a2e">TAILQ_END</a>(<a class="code" href="a00076.html#afb45f3a3a9c66c3e3a5e4d372ae24da7">workspaces</a>)) {
<a name="l00148"></a>00148                                         <span class="keywordflow">if</span> (ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a> == output) {
<a name="l00149"></a>00149                                                 <a class="code" href="a00078.html#a2f31983877c705919ed85c985220855e" title="Switches to the given workspace.">workspace_show</a>(conn, ws-&gt;<a class="code" href="a00025.html#a7dfb9b375b2740db75bb82eb0b2be41d" title="Number of this workspace, starting from 0.">num</a> + 1);
<a name="l00150"></a>00150                                                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00151"></a>00151                                         }
<a name="l00152"></a>00152                                 }
<a name="l00153"></a>00153                         }
<a name="l00154"></a>00154                         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00155"></a>00155                 }
<a name="l00156"></a>00156                 <span class="keywordtype">int</span> drawn = 0;
<a name="l00157"></a>00157                 <span class="comment">/* Because workspaces can be on different outputs, we need to loop</span>
<a name="l00158"></a>00158 <span class="comment">                   through all of them and decide to count it based on its -&gt;output */</span>
<a name="l00159"></a>00159                 <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws;
<a name="l00160"></a>00160                 <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="l00161"></a>00161                         <span class="keywordflow">if</span> (ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a> != output)
<a name="l00162"></a>00162                                 <span class="keywordflow">continue</span>;
<a name="l00163"></a>00163                         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Checking if click was on workspace %d with drawn = %d, tw = %d\n&quot;</span>,
<a name="l00164"></a>00164                                         ws-&gt;<a class="code" href="a00025.html#a7dfb9b375b2740db75bb82eb0b2be41d" title="Number of this workspace, starting from 0.">num</a>, drawn, ws-&gt;<a class="code" href="a00025.html#ad7c51613ba7339af44071f450af5f37d" title="Width of the workspace’s name (in pixels) rendered in config.font.">text_width</a>);
<a name="l00165"></a>00165                         <span class="keywordflow">if</span> (event-&gt;event_x &gt; (drawn + 1) &amp;&amp;
<a name="l00166"></a>00166                             event-&gt;event_x &lt;= (drawn + 1 + ws-&gt;<a class="code" href="a00025.html#ad7c51613ba7339af44071f450af5f37d" title="Width of the workspace’s name (in pixels) rendered in config.font.">text_width</a> + 5 + 5)) {
<a name="l00167"></a>00167                                 <a class="code" href="a00078.html#a2f31983877c705919ed85c985220855e" title="Switches to the given workspace.">workspace_show</a>(conn, ws-&gt;<a class="code" href="a00025.html#a7dfb9b375b2740db75bb82eb0b2be41d" title="Number of this workspace, starting from 0.">num</a> + 1);
<a name="l00168"></a>00168                                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00169"></a>00169                         }
<a name="l00170"></a>00170 
<a name="l00171"></a>00171                         drawn += ws-&gt;<a class="code" href="a00025.html#ad7c51613ba7339af44071f450af5f37d" title="Width of the workspace’s name (in pixels) rendered in config.font.">text_width</a> + 5 + 5 + 2;
<a name="l00172"></a>00172                 }
<a name="l00173"></a>00173                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00174"></a>00174         }
<a name="l00175"></a>00175 
<a name="l00176"></a>00176         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00177"></a>00177 }
<a name="l00178"></a>00178 
<a name="l00179"></a>00179 <span class="comment">/*</span>
<a name="l00180"></a>00180 <span class="comment"> * Called when the user clicks using the floating_modifier, but the client is in</span>
<a name="l00181"></a>00181 <span class="comment"> * tiling layout.</span>
<a name="l00182"></a>00182 <span class="comment"> *</span>
<a name="l00183"></a>00183 <span class="comment"> * Returns false if it does not do anything (that is, the click should be sent</span>
<a name="l00184"></a>00184 <span class="comment"> * to the client).</span>
<a name="l00185"></a>00185 <span class="comment"> *</span>
<a name="l00186"></a>00186 <span class="comment"> */</span>
<a name="l00187"></a><a class="code" href="a00059.html#aaecf36bc71be706314569ed075f6ed50">00187</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="a00059.html#aaecf36bc71be706314569ed075f6ed50">floating_mod_on_tiled_client</a>(xcb_connection_t *conn, <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client,
<a name="l00188"></a>00188                                          xcb_button_press_event_t *event) {
<a name="l00189"></a>00189         <span class="comment">/* Only the right mouse button is interesting for us at the moment */</span>
<a name="l00190"></a>00190         <span class="keywordflow">if</span> (event-&gt;detail != 3)
<a name="l00191"></a>00191                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00192"></a>00192 
<a name="l00193"></a>00193         <span class="comment">/* The client is in tiling layout. We can still</span>
<a name="l00194"></a>00194 <span class="comment">         * initiate a resize with the right mouse button,</span>
<a name="l00195"></a>00195 <span class="comment">         * by chosing the border which is the most near one</span>
<a name="l00196"></a>00196 <span class="comment">         * to the position of the mouse pointer */</span>
<a name="l00197"></a>00197         <span class="keywordtype">int</span> to_right = 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;event_x,
<a name="l00198"></a>00198             to_left = <span class="keyword">event</span>-&gt;event_x,
<a name="l00199"></a>00199             to_top = <span class="keyword">event</span>-&gt;event_y,
<a name="l00200"></a>00200             to_bottom = 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;event_y;
<a name="l00201"></a>00201         <a class="code" href="a00049.html#a71bd35b8b1c20409e895e1d16db16048">resize_orientation_t</a> orientation = <a class="code" href="a00049.html#a71bd35b8b1c20409e895e1d16db16048adf2421ce8287797fba766ef7785fd15f">O_VERTICAL</a>;
<a name="l00202"></a>00202         <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="l00203"></a>00203         <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws = con-&gt;<a class="code" href="a00013.html#a98ed501e1088ccf2e7c75399ab7e6031">workspace</a>;
<a name="l00204"></a>00204         <span class="keywordtype">int</span> first = 0, second = 0;
<a name="l00205"></a>00205 
<a name="l00206"></a>00206         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;click was %d px to the right, %d px to the left, %d px to top, %d px to bottom\n&quot;</span>,
<a name="l00207"></a>00207                         to_right, to_left, to_top, to_bottom);
<a name="l00208"></a>00208 
<a name="l00209"></a>00209         <span class="keywordflow">if</span> (to_right &lt; to_left &amp;&amp;
<a name="l00210"></a>00210             to_right &lt; to_top &amp;&amp;
<a name="l00211"></a>00211             to_right &lt; to_bottom) {
<a name="l00212"></a>00212                 <span class="comment">/* …right border */</span>
<a name="l00213"></a>00213                 first = con-&gt;<a class="code" href="a00013.html#ad20f57a89cdcc15b1e656c67d7b4861a">col</a> + (con-&gt;<a class="code" href="a00013.html#abb706ed35dd8c6303633d4c45c97d855">colspan</a> - 1);
<a name="l00214"></a>00214                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;column %d\n&quot;</span>, first);
<a name="l00215"></a>00215 
<a name="l00216"></a>00216                 <span class="keywordflow">if</span> (!<a class="code" href="a00076.html#a35612ca2e7ae4fc1fe4e396957215065" title="Performs simple bounds checking for the given column/row.">cell_exists</a>(ws, first, con-&gt;<a class="code" href="a00013.html#a4fefa5b1b97f096cbee9cd24cc3d6c34">row</a>) ||
<a name="l00217"></a>00217                     (first == (ws-&gt;<a class="code" href="a00025.html#a1d295f430fa92fc0b91c7f85a4b499b2" title="table dimensions">cols</a>-1)))
<a name="l00218"></a>00218                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00219"></a>00219 
<a name="l00220"></a>00220                 second = first + 1;
<a name="l00221"></a>00221         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (to_left &lt; to_right &amp;&amp;
<a name="l00222"></a>00222                    to_left &lt; to_top &amp;&amp;
<a name="l00223"></a>00223                    to_left &lt; to_bottom) {
<a name="l00224"></a>00224                 <span class="comment">/* …left border */</span>
<a name="l00225"></a>00225                 <span class="keywordflow">if</span> (con-&gt;<a class="code" href="a00013.html#ad20f57a89cdcc15b1e656c67d7b4861a">col</a> == 0)
<a name="l00226"></a>00226                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00227"></a>00227 
<a name="l00228"></a>00228                 first = con-&gt;<a class="code" href="a00013.html#ad20f57a89cdcc15b1e656c67d7b4861a">col</a> - 1;
<a name="l00229"></a>00229                 second = con-&gt;<a class="code" href="a00013.html#ad20f57a89cdcc15b1e656c67d7b4861a">col</a>;
<a name="l00230"></a>00230         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (to_top &lt; to_right &amp;&amp;
<a name="l00231"></a>00231                    to_top &lt; to_left &amp;&amp;
<a name="l00232"></a>00232                    to_top &lt; to_bottom) {
<a name="l00233"></a>00233                 <span class="comment">/* This was a press on the top border */</span>
<a name="l00234"></a>00234                 <span class="keywordflow">if</span> (con-&gt;<a class="code" href="a00013.html#a4fefa5b1b97f096cbee9cd24cc3d6c34">row</a> == 0)
<a name="l00235"></a>00235                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00236"></a>00236                 first = con-&gt;<a class="code" href="a00013.html#a4fefa5b1b97f096cbee9cd24cc3d6c34">row</a> - 1;
<a name="l00237"></a>00237                 second = con-&gt;<a class="code" href="a00013.html#a4fefa5b1b97f096cbee9cd24cc3d6c34">row</a>;
<a name="l00238"></a>00238                 orientation = <a class="code" href="a00049.html#a71bd35b8b1c20409e895e1d16db16048aab98751893c49db72a388d69fbeaaaea">O_HORIZONTAL</a>;
<a name="l00239"></a>00239         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (to_bottom &lt; to_right &amp;&amp;
<a name="l00240"></a>00240                    to_bottom &lt; to_left &amp;&amp;
<a name="l00241"></a>00241                    to_bottom &lt; to_top) {
<a name="l00242"></a>00242                 <span class="comment">/* …bottom border */</span>
<a name="l00243"></a>00243                 first = con-&gt;<a class="code" href="a00013.html#a4fefa5b1b97f096cbee9cd24cc3d6c34">row</a> + (con-&gt;<a class="code" href="a00013.html#ac87ec920de798c8f06a131af45af1fa6">rowspan</a> - 1);
<a name="l00244"></a>00244                 <span class="keywordflow">if</span> (!<a class="code" href="a00076.html#a35612ca2e7ae4fc1fe4e396957215065" title="Performs simple bounds checking for the given column/row.">cell_exists</a>(ws, con-&gt;<a class="code" href="a00013.html#ad20f57a89cdcc15b1e656c67d7b4861a">col</a>, first) ||
<a name="l00245"></a>00245                     (first == (ws-&gt;<a class="code" href="a00025.html#ae4fee0126eb1ae8484bf7281709c3fdb" title="table dimensions">rows</a>-1)))
<a name="l00246"></a>00246                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00247"></a>00247 
<a name="l00248"></a>00248                 second = first + 1;
<a name="l00249"></a>00249                 orientation = <a class="code" href="a00049.html#a71bd35b8b1c20409e895e1d16db16048aab98751893c49db72a388d69fbeaaaea">O_HORIZONTAL</a>;
<a name="l00250"></a>00250         }
<a name="l00251"></a>00251 
<a name="l00252"></a>00252        <span class="keywordflow">return</span> <a class="code" href="a00074.html#a27c4cf5725c0f69ee91992c98f38dc5c" title="Renders the resize window between the first/second container and resizes the table...">resize_graphical_handler</a>(conn, ws, first, second, orientation, event);
<a name="l00253"></a>00253 }
<a name="l00254"></a>00254 
<a name="l00255"></a><a class="code" href="a00040.html#ac97f2eddd5082f584d9370459628f503">00255</a> <span class="keywordtype">int</span> <a class="code" href="a00059.html#ac97f2eddd5082f584d9370459628f503" title="Checks if the button press was on a stack window, handles focus setting and returns...">handle_button_press</a>(<span class="keywordtype">void</span> *ignored, xcb_connection_t *conn, xcb_button_press_event_t *event) {
<a name="l00256"></a>00256         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Button %d pressed\n&quot;</span>, event-&gt;state);
<a name="l00257"></a>00257         <span class="comment">/* This was either a focus for a client’s parent (= titlebar)… */</span>
<a name="l00258"></a>00258         <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;event);
<a name="l00259"></a>00259         <span class="keywordtype">bool</span> border_click = <span class="keyword">false</span>;
<a name="l00260"></a>00260         <span class="keywordflow">if</span> (client == NULL) {
<a name="l00261"></a>00261                 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="l00262"></a>00262                 border_click = <span class="keyword">true</span>;
<a name="l00263"></a>00263         }
<a name="l00264"></a>00264         <span class="comment">/* See if this was a click with the configured modifier. If so, we need</span>
<a name="l00265"></a>00265 <span class="comment">         * to move around the client if it was floating. if not, we just process</span>
<a name="l00266"></a>00266 <span class="comment">         * as usual. */</span>
<a name="l00267"></a>00267         <span class="keywordflow">if</span> (<a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#a9329d3d7ebf1895185346ec50f7b54c2" title="The modifier which needs to be pressed in combination with your mouse buttons to...">floating_modifier</a> != 0 &amp;&amp;
<a name="l00268"></a>00268             (event-&gt;state &amp; <a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#a9329d3d7ebf1895185346ec50f7b54c2" title="The modifier which needs to be pressed in combination with your mouse buttons to...">floating_modifier</a>) == <a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#a9329d3d7ebf1895185346ec50f7b54c2" title="The modifier which needs to be pressed in combination with your mouse buttons to...">floating_modifier</a>) {
<a name="l00269"></a>00269                 <span class="keywordflow">if</span> (client == NULL) {
<a name="l00270"></a>00270                         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Not handling, floating_modifier was pressed and no client found\n&quot;</span>);
<a name="l00271"></a>00271                         xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event-&gt;time);
<a name="l00272"></a>00272                         xcb_flush(conn);
<a name="l00273"></a>00273                         <span class="keywordflow">return</span> 1;
<a name="l00274"></a>00274                 }
<a name="l00275"></a>00275                 <span class="keywordflow">if</span> (client-&gt;<a class="code" href="a00007.html#a9eeeb880b93223456c2eae445beccf94" title="fullscreen is pretty obvious">fullscreen</a>) {
<a name="l00276"></a>00276                         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Not handling, client is in fullscreen mode\n&quot;</span>);
<a name="l00277"></a>00277                         xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event-&gt;time);
<a name="l00278"></a>00278                         xcb_flush(conn);
<a name="l00279"></a>00279                         <span class="keywordflow">return</span> 1;
<a name="l00280"></a>00280                 }
<a name="l00281"></a>00281                 <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="l00282"></a>00282                         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;button %d pressed\n&quot;</span>, event-&gt;detail);
<a name="l00283"></a>00283                         <span class="keywordflow">if</span> (event-&gt;detail == 1) {
<a name="l00284"></a>00284                                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;left mouse button, dragging\n&quot;</span>);
<a name="l00285"></a>00285                                 <a class="code" href="a00066.html#ade1139a34e35e87474ee701231d57945" title="Called when the user clicked on the titlebar of a floating window.">floating_drag_window</a>(conn, client, event);
<a name="l00286"></a>00286                         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (event-&gt;detail == 3) {
<a name="l00287"></a>00287                                 <span class="keywordtype">bool</span> proportional = (<span class="keyword">event</span>-&gt;state &amp; <a class="code" href="a00036.html#a06fc87d81c62e9abb8790b6e5713c55ba346e87d049ecf80d0dc9e39543600229">BIND_SHIFT</a>);
<a name="l00288"></a>00288                                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;right mouse button\n&quot;</span>);
<a name="l00289"></a>00289                                 <a class="code" href="a00066.html#a7ad8b1f1b348648ed8d56facc5a1ccdb" title="Called when the user clicked on a floating window while holding the floating_modifier...">floating_resize_window</a>(conn, client, proportional, event);
<a name="l00290"></a>00290                         }
<a name="l00291"></a>00291                         <span class="keywordflow">return</span> 1;
<a name="l00292"></a>00292                 }
<a name="l00293"></a>00293 
<a name="l00294"></a>00294                 <span class="keywordflow">if</span> (!<a class="code" href="a00059.html#aaecf36bc71be706314569ed075f6ed50">floating_mod_on_tiled_client</a>(conn, client, event)) {
<a name="l00295"></a>00295                         xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event-&gt;time);
<a name="l00296"></a>00296                         xcb_flush(conn);
<a name="l00297"></a>00297                 }
<a name="l00298"></a>00298 
<a name="l00299"></a>00299                 <span class="keywordflow">return</span> 1;
<a name="l00300"></a>00300         }
<a name="l00301"></a>00301 
<a name="l00302"></a>00302         <span class="keywordflow">if</span> (client == NULL) {
<a name="l00303"></a>00303                 <span class="comment">/* The client was neither on a client’s titlebar nor on a client itself, maybe on a stack_window? */</span>
<a name="l00304"></a>00304                 <span class="keywordflow">if</span> (<a class="code" href="a00059.html#a2d18c18dfda759f1c2c3abf2819e9bc8">button_press_stackwin</a>(conn, event))
<a name="l00305"></a>00305                         <span class="keywordflow">return</span> 1;
<a name="l00306"></a>00306 
<a name="l00307"></a>00307                 <span class="comment">/* Or on a bar? */</span>
<a name="l00308"></a>00308                 <span class="keywordflow">if</span> (<a class="code" href="a00059.html#aae48d4ad42c0215fd08b8b0df6924097">button_press_bar</a>(conn, event))
<a name="l00309"></a>00309                         <span class="keywordflow">return</span> 1;
<a name="l00310"></a>00310 
<a name="l00311"></a>00311                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Could not handle this button press\n&quot;</span>);
<a name="l00312"></a>00312                 <span class="keywordflow">return</span> 1;
<a name="l00313"></a>00313         }
<a name="l00314"></a>00314 
<a name="l00315"></a>00315         <span class="comment">/* Set focus in any case */</span>
<a name="l00316"></a>00316         <a class="code" href="a00077.html#a323dcf30475bb3bf165100e74d225b48" title="Sets the given client as focused by updating the data structures correctly, updating...">set_focus</a>(conn, client, <span class="keyword">true</span>);
<a name="l00317"></a>00317 
<a name="l00318"></a>00318         <span class="comment">/* Let’s see if this was on the borders (= resize). If not, we’re done */</span>
<a name="l00319"></a>00319         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;press button on x=%d, y=%d\n&quot;</span>, event-&gt;event_x, event-&gt;event_y);
<a name="l00320"></a>00320         <a class="code" href="a00049.html#a71bd35b8b1c20409e895e1d16db16048">resize_orientation_t</a> orientation = <a class="code" href="a00049.html#a71bd35b8b1c20409e895e1d16db16048adf2421ce8287797fba766ef7785fd15f">O_VERTICAL</a>;
<a name="l00321"></a>00321         <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="l00322"></a>00322         <span class="keywordtype">int</span> first, second;
<a name="l00323"></a>00323 
<a name="l00324"></a>00324         <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="l00325"></a>00325                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;dock. done.\n&quot;</span>);
<a name="l00326"></a>00326                 xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event-&gt;time);
<a name="l00327"></a>00327                 xcb_flush(conn);
<a name="l00328"></a>00328                 <span class="keywordflow">return</span> 1;
<a name="l00329"></a>00329         }
<a name="l00330"></a>00330 
<a name="l00331"></a>00331         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;event-&gt;event_x = %d, client-&gt;rect.width = %d\n&quot;</span>, event-&gt;event_x, 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>);
<a name="l00332"></a>00332 
<a name="l00333"></a>00333         <span class="comment">/* Some clients (xfontsel for example) seem to pass clicks on their</span>
<a name="l00334"></a>00334 <span class="comment">         * window to the parent window, thus we receive an event here which in</span>
<a name="l00335"></a>00335 <span class="comment">         * reality is a border_click. Check for the position and fix state. */</span>
<a name="l00336"></a>00336         <span class="keywordflow">if</span> (border_click &amp;&amp;
<a name="l00337"></a>00337             event-&gt;event_x &gt;= client-&gt;<a class="code" href="a00007.html#a694f6f127e048521451f931174a6e140" title="x, y, width, height of the child (relative to its frame)">child_rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> &amp;&amp;
<a name="l00338"></a>00338             event-&gt;event_x &lt;= (client-&gt;<a class="code" href="a00007.html#a694f6f127e048521451f931174a6e140" title="x, y, width, height of the child (relative to its frame)">child_rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> + client-&gt;<a class="code" href="a00007.html#a694f6f127e048521451f931174a6e140" title="x, y, width, height of the child (relative to its frame)">child_rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>) &amp;&amp;
<a name="l00339"></a>00339             event-&gt;event_y &gt;= client-&gt;<a class="code" href="a00007.html#a694f6f127e048521451f931174a6e140" title="x, y, width, height of the child (relative to its frame)">child_rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> &amp;&amp;
<a name="l00340"></a>00340             event-&gt;event_y &lt;= (client-&gt;<a class="code" href="a00007.html#a694f6f127e048521451f931174a6e140" title="x, y, width, height of the child (relative to its frame)">child_rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> + client-&gt;<a class="code" href="a00007.html#a694f6f127e048521451f931174a6e140" title="x, y, width, height of the child (relative to its frame)">child_rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>)) {
<a name="l00341"></a>00341                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Fixing border_click = false because of click in child\n&quot;</span>);
<a name="l00342"></a>00342                 border_click = <span class="keyword">false</span>;
<a name="l00343"></a>00343         }
<a name="l00344"></a>00344 
<a name="l00345"></a>00345         <span class="keywordflow">if</span> (!border_click) {
<a name="l00346"></a>00346                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;client. done.\n&quot;</span>);
<a name="l00347"></a>00347                 xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event-&gt;time);
<a name="l00348"></a>00348                 <span class="comment">/* Floating clients should be raised on click */</span>
<a name="l00349"></a>00349                 <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="l00350"></a>00350                         <a class="code" href="a00079.html#a6ea5ab6082e87ce76340a38034f7b513" title="Raises the given window (typically client-&amp;gt;frame) above all other windows.">xcb_raise_window</a>(conn, client-&gt;<a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>);
<a name="l00351"></a>00351                 xcb_flush(conn);
<a name="l00352"></a>00352                 <span class="keywordflow">return</span> 1;
<a name="l00353"></a>00353         }
<a name="l00354"></a>00354 
<a name="l00355"></a>00355         <span class="comment">/* Don’t handle events inside the titlebar, only borders are interesting */</span>
<a name="l00356"></a>00356         <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="l00357"></a>00357         <span class="keywordflow">if</span> (event-&gt;event_y &gt;= 2 &amp;&amp; event-&gt;event_y &lt;= (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="l00358"></a>00358                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;click on titlebar\n&quot;</span>);
<a name="l00359"></a>00359 
<a name="l00360"></a>00360                 <span class="comment">/* Floating clients can be dragged by grabbing their titlebar */</span>
<a name="l00361"></a>00361                 <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="l00362"></a>00362                         <span class="comment">/* Firstly, we raise it. Maybe the user just wanted to raise it without grabbing */</span>
<a name="l00363"></a>00363                         <a class="code" href="a00079.html#a6ea5ab6082e87ce76340a38034f7b513" title="Raises the given window (typically client-&amp;gt;frame) above all other windows.">xcb_raise_window</a>(conn, client-&gt;<a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>);
<a name="l00364"></a>00364                         xcb_flush(conn);
<a name="l00365"></a>00365 
<a name="l00366"></a>00366                         <a class="code" href="a00066.html#ade1139a34e35e87474ee701231d57945" title="Called when the user clicked on the titlebar of a floating window.">floating_drag_window</a>(conn, client, event);
<a name="l00367"></a>00367                 }
<a name="l00368"></a>00368                 <span class="keywordflow">return</span> 1;
<a name="l00369"></a>00369         }
<a name="l00370"></a>00370 
<a name="l00371"></a>00371         <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="l00372"></a>00372                 <span class="keywordflow">return</span> <a class="code" href="a00066.html#a45f1fa09855e7264dba2e040b1a7eb7a" title="Called whenever the user clicks on a border (not the titlebar!) of a floating window...">floating_border_click</a>(conn, client, event);
<a name="l00373"></a>00373 
<a name="l00374"></a>00374         <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws = con-&gt;<a class="code" href="a00013.html#a98ed501e1088ccf2e7c75399ab7e6031">workspace</a>;
<a name="l00375"></a>00375 
<a name="l00376"></a>00376         <span class="keywordflow">if</span> (event-&gt;event_y &lt; 2) {
<a name="l00377"></a>00377                 <span class="comment">/* This was a press on the top border */</span>
<a name="l00378"></a>00378                 <span class="keywordflow">if</span> (con-&gt;<a class="code" href="a00013.html#a4fefa5b1b97f096cbee9cd24cc3d6c34">row</a> == 0)
<a name="l00379"></a>00379                         <span class="keywordflow">return</span> 1;
<a name="l00380"></a>00380                 first = con-&gt;<a class="code" href="a00013.html#a4fefa5b1b97f096cbee9cd24cc3d6c34">row</a> - 1;
<a name="l00381"></a>00381                 second = con-&gt;<a class="code" href="a00013.html#a4fefa5b1b97f096cbee9cd24cc3d6c34">row</a>;
<a name="l00382"></a>00382                 orientation = <a class="code" href="a00049.html#a71bd35b8b1c20409e895e1d16db16048aab98751893c49db72a388d69fbeaaaea">O_HORIZONTAL</a>;
<a name="l00383"></a>00383         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (event-&gt;event_y &gt;= (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="l00384"></a>00384                 <span class="comment">/* …bottom border */</span>
<a name="l00385"></a>00385                 first = con-&gt;<a class="code" href="a00013.html#a4fefa5b1b97f096cbee9cd24cc3d6c34">row</a> + (con-&gt;<a class="code" href="a00013.html#ac87ec920de798c8f06a131af45af1fa6">rowspan</a> - 1);
<a name="l00386"></a>00386                 <span class="keywordflow">if</span> (!<a class="code" href="a00076.html#a35612ca2e7ae4fc1fe4e396957215065" title="Performs simple bounds checking for the given column/row.">cell_exists</a>(ws, con-&gt;<a class="code" href="a00013.html#ad20f57a89cdcc15b1e656c67d7b4861a">col</a>, first) ||
<a name="l00387"></a>00387                     (first == (ws-&gt;<a class="code" href="a00025.html#ae4fee0126eb1ae8484bf7281709c3fdb" title="table dimensions">rows</a>-1)))
<a name="l00388"></a>00388                         <span class="keywordflow">return</span> 1;
<a name="l00389"></a>00389 
<a name="l00390"></a>00390                 second = first + 1;
<a name="l00391"></a>00391                 orientation = <a class="code" href="a00049.html#a71bd35b8b1c20409e895e1d16db16048aab98751893c49db72a388d69fbeaaaea">O_HORIZONTAL</a>;
<a name="l00392"></a>00392         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (event-&gt;event_x &lt;= 2) {
<a name="l00393"></a>00393                 <span class="comment">/* …left border */</span>
<a name="l00394"></a>00394                 <span class="keywordflow">if</span> (con-&gt;<a class="code" href="a00013.html#ad20f57a89cdcc15b1e656c67d7b4861a">col</a> == 0)
<a name="l00395"></a>00395                         <span class="keywordflow">return</span> 1;
<a name="l00396"></a>00396 
<a name="l00397"></a>00397                 first = con-&gt;<a class="code" href="a00013.html#ad20f57a89cdcc15b1e656c67d7b4861a">col</a> - 1;
<a name="l00398"></a>00398                 second = con-&gt;<a class="code" href="a00013.html#ad20f57a89cdcc15b1e656c67d7b4861a">col</a>;
<a name="l00399"></a>00399         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (event-&gt;event_x &gt; 2) {
<a name="l00400"></a>00400                 <span class="comment">/* …right border */</span>
<a name="l00401"></a>00401                 first = con-&gt;<a class="code" href="a00013.html#ad20f57a89cdcc15b1e656c67d7b4861a">col</a> + (con-&gt;<a class="code" href="a00013.html#abb706ed35dd8c6303633d4c45c97d855">colspan</a> - 1);
<a name="l00402"></a>00402                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;column %d\n&quot;</span>, first);
<a name="l00403"></a>00403 
<a name="l00404"></a>00404                 <span class="keywordflow">if</span> (!<a class="code" href="a00076.html#a35612ca2e7ae4fc1fe4e396957215065" title="Performs simple bounds checking for the given column/row.">cell_exists</a>(ws, first, con-&gt;<a class="code" href="a00013.html#a4fefa5b1b97f096cbee9cd24cc3d6c34">row</a>) ||
<a name="l00405"></a>00405                     (first == (ws-&gt;<a class="code" href="a00025.html#a1d295f430fa92fc0b91c7f85a4b499b2" title="table dimensions">cols</a>-1)))
<a name="l00406"></a>00406                         <span class="keywordflow">return</span> 1;
<a name="l00407"></a>00407 
<a name="l00408"></a>00408                 second = first + 1;
<a name="l00409"></a>00409         }
<a name="l00410"></a>00410 
<a name="l00411"></a>00411         <span class="keywordflow">return</span> <a class="code" href="a00074.html#a27c4cf5725c0f69ee91992c98f38dc5c" title="Renders the resize window between the first/second container and resizes the table...">resize_graphical_handler</a>(conn, ws, first, second, orientation, event);
<a name="l00412"></a>00412 }
</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>