<!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/randr.c Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.2-20100208 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <h1>src/randr.c</h1><a href="a00073.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"> * For more information on RandR, please see the X.org RandR specification at</span> <a name="l00011"></a>00011 <span class="comment"> * http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt</span> <a name="l00012"></a>00012 <span class="comment"> * (take your time to read it completely, it answers all questions).</span> <a name="l00013"></a>00013 <span class="comment"> *</span> <a name="l00014"></a>00014 <span class="comment"> */</span> <a name="l00015"></a>00015 <span class="preprocessor">#include <stdio.h></span> <a name="l00016"></a>00016 <span class="preprocessor">#include <stdlib.h></span> <a name="l00017"></a>00017 <span class="preprocessor">#include <string.h></span> <a name="l00018"></a>00018 <span class="preprocessor">#include <stdbool.h></span> <a name="l00019"></a>00019 <span class="preprocessor">#include <assert.h></span> <a name="l00020"></a>00020 <span class="preprocessor">#include <time.h></span> <a name="l00021"></a>00021 <span class="preprocessor">#include <unistd.h></span> <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="preprocessor">#include <xcb/xcb.h></span> <a name="l00024"></a>00024 <span class="preprocessor">#include <xcb/randr.h></span> <a name="l00025"></a>00025 <a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="a00047.html">queue.h</a>"</span> <a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="a00041.html">i3.h</a>"</span> <a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="a00036.html">data.h</a>"</span> <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="a00051.html">table.h</a>"</span> <a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="a00052.html">util.h</a>"</span> <a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="a00043.html">layout.h</a>"</span> <a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="a00054.html">xcb.h</a>"</span> <a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="a00034.html">config.h</a>"</span> <a name="l00034"></a>00034 <span class="preprocessor">#include "<a class="code" href="a00053.html">workspace.h</a>"</span> <a name="l00035"></a>00035 <span class="preprocessor">#include "<a class="code" href="a00044.html">log.h</a>"</span> <a name="l00036"></a>00036 <span class="preprocessor">#include "<a class="code" href="a00038.html">ewmh.h</a>"</span> <a name="l00037"></a>00037 <span class="preprocessor">#include "<a class="code" href="a00042.html">ipc.h</a>"</span> <a name="l00038"></a>00038 <span class="preprocessor">#include "<a class="code" href="a00032.html">client.h</a>"</span> <a name="l00039"></a>00039 <a name="l00040"></a>00040 <span class="comment">/* While a clean namespace is usually a pretty good thing, we really need</span> <a name="l00041"></a>00041 <span class="comment"> * to use shorter names than the whole xcb_randr_* default names. */</span> <a name="l00042"></a><a class="code" href="a00073.html#a9245e8649a64978e379c7fb613823869">00042</a> <span class="keyword">typedef</span> xcb_randr_get_crtc_info_reply_t <a class="code" href="a00073.html#a9245e8649a64978e379c7fb613823869">crtc_info</a>; <a name="l00043"></a><a class="code" href="a00073.html#a0e9a01a2276ee7092ebeaeb6effb4ec4">00043</a> <span class="keyword">typedef</span> xcb_randr_mode_info_t <a class="code" href="a00073.html#a0e9a01a2276ee7092ebeaeb6effb4ec4">mode_info</a>; <a name="l00044"></a><a class="code" href="a00073.html#a97f36df51cdd1efbad0a2b067f63c7bc">00044</a> <span class="keyword">typedef</span> xcb_randr_get_screen_resources_current_reply_t <a class="code" href="a00073.html#a97f36df51cdd1efbad0a2b067f63c7bc">resources_reply</a>; <a name="l00045"></a>00045 <a name="l00046"></a>00046 <span class="comment">/* Stores all outputs available in your current session. */</span> <a name="l00047"></a><a class="code" href="a00048.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">00047</a> <span class="keyword">struct </span>outputs_head <a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a> = <a class="code" href="a00047.html#ac269df7d4126ed9885156cbad2cbf8af">TAILQ_HEAD_INITIALIZER</a>(<a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>); <a name="l00048"></a>00048 <a name="l00049"></a><a class="code" href="a00073.html#a93c5408e1e62034f8b292cc65ee9ab7f">00049</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="a00073.html#a93c5408e1e62034f8b292cc65ee9ab7f">randr_disabled</a> = <span class="keyword">false</span>; <a name="l00050"></a>00050 <a name="l00051"></a>00051 <span class="comment">/*</span> <a name="l00052"></a>00052 <span class="comment"> * Get a specific output by its internal X11 id. Used by randr_query_outputs</span> <a name="l00053"></a>00053 <span class="comment"> * to check if the output is new (only in the first scan) or if we are</span> <a name="l00054"></a>00054 <span class="comment"> * re-scanning.</span> <a name="l00055"></a>00055 <span class="comment"> *</span> <a name="l00056"></a>00056 <span class="comment"> */</span> <a name="l00057"></a><a class="code" href="a00073.html#aa855dcabb5bc4a5f61663aea37b63f5b">00057</a> <span class="keyword">static</span> <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *<a class="code" href="a00073.html#aa855dcabb5bc4a5f61663aea37b63f5b">get_output_by_id</a>(xcb_randr_output_t <span class="keywordtype">id</span>) { <a name="l00058"></a>00058 <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output; <a name="l00059"></a>00059 <a class="code" href="a00047.html#a16e5fc168e7f3494d4b1df54447d871e">TAILQ_FOREACH</a>(output, &<a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>, <a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>) <a name="l00060"></a>00060 <span class="keywordflow">if</span> (output-><a class="code" href="a00026.html#ac1db5d4876f5f1889f055467cdf603fb" title="Output id, so that we can requery the output directly later.">id</a> == <span class="keywordtype">id</span>) <a name="l00061"></a>00061 <span class="keywordflow">return</span> output; <a name="l00062"></a>00062 <a name="l00063"></a>00063 <span class="keywordflow">return</span> NULL; <a name="l00064"></a>00064 } <a name="l00065"></a>00065 <a name="l00066"></a>00066 <span class="comment">/*</span> <a name="l00067"></a>00067 <span class="comment"> * Returns the output with the given name if it is active (!) or NULL.</span> <a name="l00068"></a>00068 <span class="comment"> *</span> <a name="l00069"></a>00069 <span class="comment"> */</span> <a name="l00070"></a><a class="code" href="a00048.html#a2c185a55a45ce9d522bc3b3b69e06132">00070</a> <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *<a class="code" href="a00073.html#a2c185a55a45ce9d522bc3b3b69e06132" title="Returns the output with the given name if it is active (!) or NULL.">get_output_by_name</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *name) { <a name="l00071"></a>00071 <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output; <a name="l00072"></a>00072 <a class="code" href="a00047.html#a16e5fc168e7f3494d4b1df54447d871e">TAILQ_FOREACH</a>(output, &<a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>, <a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>) <a name="l00073"></a>00073 <span class="keywordflow">if</span> (output-><a class="code" href="a00026.html#a7c56e7415ebe0aa040614d1244e2da6b" title="Whether the output is currently active (has a CRTC attached with a valid mode).">active</a> && <a name="l00074"></a>00074 strcasecmp(output-><a class="code" href="a00026.html#a4c8b185b15cf45e3ca300cb54b2d4650" title="Name of the output.">name</a>, name) == 0) <a name="l00075"></a>00075 <span class="keywordflow">return</span> output; <a name="l00076"></a>00076 <a name="l00077"></a>00077 <span class="keywordflow">return</span> NULL; <a name="l00078"></a>00078 } <a name="l00079"></a>00079 <a name="l00080"></a>00080 <span class="comment">/*</span> <a name="l00081"></a>00081 <span class="comment"> * Returns the first output which is active.</span> <a name="l00082"></a>00082 <span class="comment"> *</span> <a name="l00083"></a>00083 <span class="comment"> */</span> <a name="l00084"></a><a class="code" href="a00048.html#a514adc4dcfc06b1e9329e41633c65fb0">00084</a> <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *<a class="code" href="a00073.html#a514adc4dcfc06b1e9329e41633c65fb0" title="Returns the first output which is active.">get_first_output</a>() { <a name="l00085"></a>00085 <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output; <a name="l00086"></a>00086 <a name="l00087"></a>00087 <a class="code" href="a00047.html#a16e5fc168e7f3494d4b1df54447d871e">TAILQ_FOREACH</a>(output, &<a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>, <a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>) <a name="l00088"></a>00088 <span class="keywordflow">if</span> (output-><a class="code" href="a00026.html#a7c56e7415ebe0aa040614d1244e2da6b" title="Whether the output is currently active (has a CRTC attached with a valid mode).">active</a>) <a name="l00089"></a>00089 <span class="keywordflow">return</span> output; <a name="l00090"></a>00090 <a name="l00091"></a>00091 <span class="keywordflow">return</span> NULL; <a name="l00092"></a>00092 } <a name="l00093"></a>00093 <a name="l00094"></a>00094 <span class="comment">/*</span> <a name="l00095"></a>00095 <span class="comment"> * Returns the active (!) output which contains the coordinates x, y or NULL</span> <a name="l00096"></a>00096 <span class="comment"> * if there is no output which contains these coordinates.</span> <a name="l00097"></a>00097 <span class="comment"> *</span> <a name="l00098"></a>00098 <span class="comment"> */</span> <a name="l00099"></a><a class="code" href="a00048.html#abb7e75366265212195afd09ab85235f6">00099</a> <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *<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>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> <a class="code" href="a00068.html#a16e56e533e1eb98fda15e06fdec03da6">y</a>) { <a name="l00100"></a>00100 <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output; <a name="l00101"></a>00101 <a class="code" href="a00047.html#a16e5fc168e7f3494d4b1df54447d871e">TAILQ_FOREACH</a>(output, &<a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>, <a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>) { <a name="l00102"></a>00102 <span class="keywordflow">if</span> (!output-><a class="code" href="a00026.html#a7c56e7415ebe0aa040614d1244e2da6b" title="Whether the output is currently active (has a CRTC attached with a valid mode).">active</a>) <a name="l00103"></a>00103 <span class="keywordflow">continue</span>; <a name="l00104"></a>00104 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"comparing x=%d y=%d with x=%d and y=%d width %d height %d\n"</span>, <a name="l00105"></a>00105 x, y, output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>, output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>); <a name="l00106"></a>00106 <span class="keywordflow">if</span> (x >= output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> && x < (output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> + output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>) && <a name="l00107"></a>00107 y >= output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> && y < (output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> + output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>)) <a name="l00108"></a>00108 <span class="keywordflow">return</span> output; <a name="l00109"></a>00109 } <a name="l00110"></a>00110 <a name="l00111"></a>00111 <span class="keywordflow">return</span> NULL; <a name="l00112"></a>00112 } <a name="l00113"></a>00113 <a name="l00114"></a>00114 <span class="comment">/*</span> <a name="l00115"></a>00115 <span class="comment"> * Gets the output which is the last one in the given direction, for example</span> <a name="l00116"></a>00116 <span class="comment"> * the output on the most bottom when direction == D_DOWN, the output most</span> <a name="l00117"></a>00117 <span class="comment"> * right when direction == D_RIGHT and so on.</span> <a name="l00118"></a>00118 <span class="comment"> *</span> <a name="l00119"></a>00119 <span class="comment"> * This function always returns a output.</span> <a name="l00120"></a>00120 <span class="comment"> *</span> <a name="l00121"></a>00121 <span class="comment"> */</span> <a name="l00122"></a><a class="code" href="a00048.html#ab437b557cdb16bda702e52c99efcfe4a">00122</a> <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *<a class="code" href="a00073.html#ab437b557cdb16bda702e52c99efcfe4a" title="Gets the output which is the last one in the given direction, for example the output...">get_output_most</a>(<a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6b">direction_t</a> direction, <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *current) { <a name="l00123"></a>00123 <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output, *candidate = NULL; <a name="l00124"></a>00124 <span class="keywordtype">int</span> position = 0; <a name="l00125"></a>00125 <a class="code" href="a00047.html#a16e5fc168e7f3494d4b1df54447d871e">TAILQ_FOREACH</a>(output, &<a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>, <a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>) { <a name="l00126"></a>00126 <span class="keywordflow">if</span> (!output-><a class="code" href="a00026.html#a7c56e7415ebe0aa040614d1244e2da6b" title="Whether the output is currently active (has a CRTC attached with a valid mode).">active</a>) <a name="l00127"></a>00127 <span class="keywordflow">continue</span>; <a name="l00128"></a>00128 <a name="l00129"></a>00129 <span class="comment">/* Repeated calls of WIN determine the winner of the comparison */</span> <a name="l00130"></a>00130 <span class="preprocessor"> #define WIN(variable, condition) \</span> <a name="l00131"></a>00131 <span class="preprocessor"> if (variable condition) { \</span> <a name="l00132"></a>00132 <span class="preprocessor"> candidate = output; \</span> <a name="l00133"></a>00133 <span class="preprocessor"> position = variable; \</span> <a name="l00134"></a>00134 <span class="preprocessor"> } \</span> <a name="l00135"></a>00135 <span class="preprocessor"> break;</span> <a name="l00136"></a>00136 <span class="preprocessor"></span> <a name="l00137"></a>00137 <span class="keywordflow">if</span> (((direction == <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6bae8b5f804952c228061ed205833ae7083">D_UP</a>) || (direction == <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6baee5b9399d89b358fa6fb0adef67d3a4b">D_DOWN</a>)) && <a name="l00138"></a>00138 (current-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> != output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>)) <a name="l00139"></a>00139 <span class="keywordflow">continue</span>; <a name="l00140"></a>00140 <a name="l00141"></a>00141 <span class="keywordflow">if</span> (((direction == <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6babbac3b12101a9c0c07dbdfcd6bbb212c">D_LEFT</a>) || (direction == <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6ba07fb0d616c46d4120eb541871fbdfd2d">D_RIGHT</a>)) && <a name="l00142"></a>00142 (current-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> != output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>)) <a name="l00143"></a>00143 <span class="keywordflow">continue</span>; <a name="l00144"></a>00144 <a name="l00145"></a>00145 <span class="keywordflow">switch</span> (direction) { <a name="l00146"></a>00146 <span class="keywordflow">case</span> <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6bae8b5f804952c228061ed205833ae7083">D_UP</a>: <a name="l00147"></a>00147 <a class="code" href="a00073.html#af9b4a4c33615b5ed4920fc012eed3e33">WIN</a>(output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>, <= position); <a name="l00148"></a>00148 <span class="keywordflow">case</span> <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6baee5b9399d89b358fa6fb0adef67d3a4b">D_DOWN</a>: <a name="l00149"></a>00149 <a class="code" href="a00073.html#af9b4a4c33615b5ed4920fc012eed3e33">WIN</a>(output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>, >= position); <a name="l00150"></a>00150 <span class="keywordflow">case</span> <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6babbac3b12101a9c0c07dbdfcd6bbb212c">D_LEFT</a>: <a name="l00151"></a>00151 <a class="code" href="a00073.html#af9b4a4c33615b5ed4920fc012eed3e33">WIN</a>(output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, <= position); <a name="l00152"></a>00152 <span class="keywordflow">case</span> <a class="code" href="a00036.html#ae9ae980041e438eed7a3af43ce4e9f6ba07fb0d616c46d4120eb541871fbdfd2d">D_RIGHT</a>: <a name="l00153"></a>00153 <a class="code" href="a00073.html#af9b4a4c33615b5ed4920fc012eed3e33">WIN</a>(output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, >= position); <a name="l00154"></a>00154 } <a name="l00155"></a>00155 } <a name="l00156"></a>00156 <a name="l00157"></a>00157 assert(candidate != NULL); <a name="l00158"></a>00158 <a name="l00159"></a>00159 <span class="keywordflow">return</span> candidate; <a name="l00160"></a>00160 } <a name="l00161"></a>00161 <a name="l00162"></a>00162 <span class="comment">/*</span> <a name="l00163"></a>00163 <span class="comment"> * Initializes the specified output, assigning the specified workspace to it.</span> <a name="l00164"></a>00164 <span class="comment"> *</span> <a name="l00165"></a>00165 <span class="comment"> */</span> <a name="l00166"></a><a class="code" href="a00048.html#a3b4d451b80a25c4d2df53a45f85ee637">00166</a> <span class="keywordtype">void</span> <a class="code" href="a00073.html#a3b4d451b80a25c4d2df53a45f85ee637" title="Initializes the specified output, assigning the specified workspace to it.">initialize_output</a>(xcb_connection_t *conn, <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output, <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *workspace) { <a name="l00167"></a>00167 <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="l00168"></a>00168 <a name="l00169"></a>00169 workspace-><a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a> = output; <a name="l00170"></a>00170 output-><a class="code" href="a00026.html#a9bcf702b65d8f47f98eafbefff529ffe" title="Current workspace selected on this virtual screen.">current_workspace</a> = workspace; <a name="l00171"></a>00171 <a name="l00172"></a>00172 <span class="comment">/* Copy rect for the workspace */</span> <a name="l00173"></a>00173 memcpy(&(workspace-><a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>), &(output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>), <span class="keyword">sizeof</span>(<a class="code" href="a00020.html" title="Stores a rectangle, for example the size of a window, the child window etc.">Rect</a>)); <a name="l00174"></a>00174 <a name="l00175"></a>00175 <span class="comment">/* Map clients on the workspace, if any */</span> <a name="l00176"></a>00176 <a class="code" href="a00078.html#a88c6ab06ad8ce02a23811e2ee2d84285" title="Maps all clients (and stack windows) of the given workspace.">workspace_map_clients</a>(conn, workspace); <a name="l00177"></a>00177 <a name="l00178"></a>00178 <span class="comment">/* Create a bar window on each output */</span> <a name="l00179"></a>00179 <span class="keywordflow">if</span> (!<a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#ae4e1660269cdac461dac45368e592b4c" title="By default, a workspace bar is drawn at the bottom of the screen.">disable_workspace_bar</a>) { <a name="l00180"></a>00180 <a class="code" href="a00020.html" title="Stores a rectangle, for example the size of a window, the child window etc.">Rect</a> bar_rect = {output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, <a name="l00181"></a>00181 output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> + output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> - (font-><a class="code" href="a00015.html#a89ceb86bb4ad2694315d846e69893399" title="The height of the font, built from font_ascent + font_descent.">height</a> + 6), <a name="l00182"></a>00182 output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> + output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, <a name="l00183"></a>00183 font-><a class="code" href="a00015.html#a89ceb86bb4ad2694315d846e69893399" title="The height of the font, built from font_ascent + font_descent.">height</a> + 6}; <a name="l00184"></a>00184 uint32_t mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK; <a name="l00185"></a>00185 uint32_t values[] = {1, XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS}; <a name="l00186"></a>00186 output-><a class="code" href="a00026.html#a479cef7d03401926d37ee89a6ee37aed" title="The bar window.">bar</a> = <a class="code" href="a00079.html#a1c6bb71a9f8e0501e2228dd3dca3bd6a" title="Convenience wrapper around xcb_create_window which takes care of depth, generating...">create_window</a>(conn, bar_rect, XCB_WINDOW_CLASS_INPUT_OUTPUT, <a class="code" href="a00054.html#ada5e89d9bddd5e5feff900639db2e208" title="This is the equivalent of XC_left_ptr.">XCB_CURSOR_LEFT_PTR</a>, <span class="keyword">true</span>, mask, values); <a name="l00187"></a>00187 output-><a class="code" href="a00026.html#a1463701491a3a9454f7a3a6efdabf566">bargc</a> = xcb_generate_id(conn); <a name="l00188"></a>00188 xcb_create_gc(conn, output-><a class="code" href="a00026.html#a1463701491a3a9454f7a3a6efdabf566">bargc</a>, output-><a class="code" href="a00026.html#a479cef7d03401926d37ee89a6ee37aed" title="The bar window.">bar</a>, 0, 0); <a name="l00189"></a>00189 } <a name="l00190"></a>00190 <a name="l00191"></a>00191 <a class="code" href="a00047.html#a361ac8e88cf066cc4d46d28b54fd3031">SLIST_INIT</a>(&(output->dock_clients)); <a name="l00192"></a>00192 <a name="l00193"></a>00193 <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">"workspace"</span>, I3_IPC_EVENT_WORKSPACE, <span class="stringliteral">"{\"change\":\"init\"}"</span>); <a name="l00194"></a>00194 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"initialized output at (%d, %d) with %d x %d\n"</span>, <a name="l00195"></a>00195 output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>, output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>); <a name="l00196"></a>00196 <a name="l00197"></a>00197 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"assigning configured workspaces to this output...\n"</span>); <a name="l00198"></a>00198 <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws; <a name="l00199"></a>00199 <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="l00200"></a>00200 <span class="keywordflow">if</span> (ws == workspace) <a name="l00201"></a>00201 <span class="keywordflow">continue</span>; <a name="l00202"></a>00202 <span class="keywordflow">if</span> (ws-><a class="code" href="a00025.html#a01a0ddbbb125bc568e312a07d44823a2" title="The name of the RandR output this screen should be on.">preferred_output</a> == NULL || <a name="l00203"></a>00203 <a class="code" href="a00073.html#a2c185a55a45ce9d522bc3b3b69e06132" title="Returns the output with the given name if it is active (!) or NULL.">get_output_by_name</a>(ws-><a class="code" href="a00025.html#a01a0ddbbb125bc568e312a07d44823a2" title="The name of the RandR output this screen should be on.">preferred_output</a>) != output) <a name="l00204"></a>00204 <span class="keywordflow">continue</span>; <a name="l00205"></a>00205 <a name="l00206"></a>00206 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"assigning ws %d\n"</span>, ws-><a class="code" href="a00025.html#a7dfb9b375b2740db75bb82eb0b2be41d" title="Number of this workspace, starting from 0.">num</a> + 1); <a name="l00207"></a>00207 <a class="code" href="a00078.html#adadfb8fab9d410f05869cc1808f3922f" title="Assigns the given workspace to the given screen by correctly updating its state and...">workspace_assign_to</a>(ws, output, <span class="keyword">true</span>); <a name="l00208"></a>00208 } <a name="l00209"></a>00209 } <a name="l00210"></a>00210 <a name="l00211"></a>00211 <span class="comment">/*</span> <a name="l00212"></a>00212 <span class="comment"> * Disables RandR support by creating exactly one output with the size of the</span> <a name="l00213"></a>00213 <span class="comment"> * X11 screen.</span> <a name="l00214"></a>00214 <span class="comment"> *</span> <a name="l00215"></a>00215 <span class="comment"> */</span> <a name="l00216"></a><a class="code" href="a00048.html#a0d7c5d1d6273f607dc9285621e988e08">00216</a> <span class="keywordtype">void</span> <a class="code" href="a00073.html#a0d7c5d1d6273f607dc9285621e988e08" title="Disables RandR support by creating exactly one output with the size of the X11 screen...">disable_randr</a>(xcb_connection_t *conn) { <a name="l00217"></a>00217 xcb_screen_t *root_screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data; <a name="l00218"></a>00218 <a name="l00219"></a>00219 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"RandR extension unusable, disabling.\n"</span>); <a name="l00220"></a>00220 <a name="l00221"></a>00221 <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *s = <a class="code" href="a00077.html#ad475e1b898d9da9b2a8b92e3da51b3dd" title="Safe-wrapper around calloc which exits if malloc returns NULL (meaning that there...">scalloc</a>(<span class="keyword">sizeof</span>(<a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a>)); <a name="l00222"></a>00222 <a name="l00223"></a>00223 s-><a class="code" href="a00026.html#a7c56e7415ebe0aa040614d1244e2da6b" title="Whether the output is currently active (has a CRTC attached with a valid mode).">active</a> = <span class="keyword">true</span>; <a name="l00224"></a>00224 s-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> = 0; <a name="l00225"></a>00225 s-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> = 0; <a name="l00226"></a>00226 s-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> = root_screen->width_in_pixels; <a name="l00227"></a>00227 s-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> = root_screen->height_in_pixels; <a name="l00228"></a>00228 s-><a class="code" href="a00026.html#a4c8b185b15cf45e3ca300cb54b2d4650" title="Name of the output.">name</a> = <span class="stringliteral">"xroot-0"</span>; <a name="l00229"></a>00229 <a name="l00230"></a>00230 <a class="code" href="a00047.html#a512bee16b46f601078c96c776d2648c3">TAILQ_INSERT_TAIL</a>(&<a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>, s, <a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>); <a name="l00231"></a>00231 <a name="l00232"></a>00232 <a class="code" href="a00073.html#a93c5408e1e62034f8b292cc65ee9ab7f">randr_disabled</a> = <span class="keyword">true</span>; <a name="l00233"></a>00233 } <a name="l00234"></a>00234 <a name="l00235"></a>00235 <span class="comment">/*</span> <a name="l00236"></a>00236 <span class="comment"> * This function needs to be called when changing the mode of an output when</span> <a name="l00237"></a>00237 <span class="comment"> * it already has some workspaces (or a bar window) assigned.</span> <a name="l00238"></a>00238 <span class="comment"> *</span> <a name="l00239"></a>00239 <span class="comment"> * It reconfigures the bar window for the new mode, copies the new rect into</span> <a name="l00240"></a>00240 <span class="comment"> * each workspace on this output and forces all windows on the affected</span> <a name="l00241"></a>00241 <span class="comment"> * workspaces to be reconfigured.</span> <a name="l00242"></a>00242 <span class="comment"> *</span> <a name="l00243"></a>00243 <span class="comment"> * It is necessary to call render_layout() afterwards.</span> <a name="l00244"></a>00244 <span class="comment"> *</span> <a name="l00245"></a>00245 <span class="comment"> */</span> <a name="l00246"></a><a class="code" href="a00073.html#a601f4c6e49b7082de5d5a228030bbe40">00246</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="a00073.html#a601f4c6e49b7082de5d5a228030bbe40">output_change_mode</a>(xcb_connection_t *conn, <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output) { <a name="l00247"></a>00247 <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="l00248"></a>00248 <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws; <a name="l00249"></a>00249 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client; <a name="l00250"></a>00250 <a name="l00251"></a>00251 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Output mode changed, reconfiguring bar, updating workspaces\n"</span>); <a name="l00252"></a>00252 <a class="code" href="a00020.html" title="Stores a rectangle, for example the size of a window, the child window etc.">Rect</a> bar_rect = {output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, <a name="l00253"></a>00253 output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> + output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> - (font-><a class="code" href="a00015.html#a89ceb86bb4ad2694315d846e69893399" title="The height of the font, built from font_ascent + font_descent.">height</a> + 6), <a name="l00254"></a>00254 output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> + output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, <a name="l00255"></a>00255 font-><a class="code" href="a00015.html#a89ceb86bb4ad2694315d846e69893399" title="The height of the font, built from font_ascent + font_descent.">height</a> + 6}; <a name="l00256"></a>00256 <a name="l00257"></a>00257 <a class="code" href="a00079.html#a7bbb53cdd77036e67c997f0c93e67cef" title="Configures the given window to have the size/position specified by given rect.">xcb_set_window_rect</a>(conn, output-><a class="code" href="a00026.html#a479cef7d03401926d37ee89a6ee37aed" title="The bar window.">bar</a>, bar_rect); <a name="l00258"></a>00258 <a name="l00259"></a>00259 <span class="comment">/* go through all workspaces and set force_reconfigure */</span> <a name="l00260"></a>00260 <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="l00261"></a>00261 <span class="keywordflow">if</span> (ws-><a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a> != output) <a name="l00262"></a>00262 <span class="keywordflow">continue</span>; <a name="l00263"></a>00263 <a name="l00264"></a>00264 <a class="code" href="a00047.html#a05db87878125c27e3060dd641aa3b0f4">SLIST_FOREACH</a>(client, &(ws->focus_stack), focus_clients) { <a name="l00265"></a>00265 client-><a class="code" href="a00007.html#a873c62703ab51afe96b38df2b30ffa66">force_reconfigure</a> = <span class="keyword">true</span>; <a name="l00266"></a>00266 <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="l00267"></a>00267 <span class="keywordflow">continue</span>; <a name="l00268"></a>00268 <span class="comment">/* For floating clients we need to translate the</span> <a name="l00269"></a>00269 <span class="comment"> * coordinates (old workspace to new workspace) */</span> <a name="l00270"></a>00270 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"old: (%x, %x)\n"</span>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>); <a name="l00271"></a>00271 client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> -= ws-><a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>; <a name="l00272"></a>00272 client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> -= ws-><a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>; <a name="l00273"></a>00273 client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> += ws-><a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>; <a name="l00274"></a>00274 client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> += ws-><a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>; <a name="l00275"></a>00275 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"new: (%x, %x)\n"</span>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, client-><a class="code" href="a00007.html#aea76187592ae1a87eb8bb1af77af62d4" title="x, y, width, height of the frame">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>); <a name="l00276"></a>00276 } <a name="l00277"></a>00277 <a name="l00278"></a>00278 <span class="comment">/* Update dimensions from output */</span> <a name="l00279"></a>00279 memcpy(&(ws-><a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>), &(ws-><a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>), <span class="keyword">sizeof</span>(<a class="code" href="a00020.html" title="Stores a rectangle, for example the size of a window, the child window etc.">Rect</a>)); <a name="l00280"></a>00280 <a name="l00281"></a>00281 <span class="comment">/* Update the dimensions of a fullscreen client, if any */</span> <a name="l00282"></a>00282 <span class="keywordflow">if</span> (ws-><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="l00283"></a>00283 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Updating fullscreen client size\n"</span>); <a name="l00284"></a>00284 client = ws-><a class="code" href="a00025.html#a918ace3a3d2f03c58ec8fa05ac97275e" title="the client who is started in fullscreen mode on this workspace, NULL if there is...">fullscreen_client</a>; <a name="l00285"></a>00285 <a class="code" href="a00020.html" title="Stores a rectangle, for example the size of a window, the child window etc.">Rect</a> r = ws-><a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>; <a name="l00286"></a>00286 <a class="code" href="a00079.html#a7bbb53cdd77036e67c997f0c93e67cef" title="Configures the given window to have the size/position specified by given rect.">xcb_set_window_rect</a>(conn, client-><a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, r); <a name="l00287"></a>00287 <a name="l00288"></a>00288 r.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> = 0; <a name="l00289"></a>00289 r.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> = 0; <a name="l00290"></a>00290 <a class="code" href="a00079.html#a7bbb53cdd77036e67c997f0c93e67cef" title="Configures the given window to have the size/position specified by given rect.">xcb_set_window_rect</a>(conn, client-><a class="code" href="a00007.html#afba312b946fa74727ce619a33f8f28aa" title="The client’s window.">child</a>, r); <a name="l00291"></a>00291 } <a name="l00292"></a>00292 } <a name="l00293"></a>00293 } <a name="l00294"></a>00294 <a name="l00295"></a>00295 <span class="comment">/*</span> <a name="l00296"></a>00296 <span class="comment"> * Gets called by randr_query_outputs() for each output. The function adds new</span> <a name="l00297"></a>00297 <span class="comment"> * outputs to the list of outputs, checks if the mode of existing outputs has</span> <a name="l00298"></a>00298 <span class="comment"> * been changed or if an existing output has been disabled. It will then change</span> <a name="l00299"></a>00299 <span class="comment"> * either the "changed" or the "to_be_deleted" flag of the output, if</span> <a name="l00300"></a>00300 <span class="comment"> * appropriate.</span> <a name="l00301"></a>00301 <span class="comment"> *</span> <a name="l00302"></a>00302 <span class="comment"> */</span> <a name="l00303"></a><a class="code" href="a00073.html#a80da9f337292bbd64123b233f0a43a7a">00303</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="a00073.html#a80da9f337292bbd64123b233f0a43a7a">handle_output</a>(xcb_connection_t *conn, xcb_randr_output_t <span class="keywordtype">id</span>, <a name="l00304"></a>00304 xcb_randr_get_output_info_reply_t *output, <a name="l00305"></a>00305 xcb_timestamp_t cts, <a class="code" href="a00073.html#a97f36df51cdd1efbad0a2b067f63c7bc">resources_reply</a> *res) { <a name="l00306"></a>00306 <span class="comment">/* each CRT controller has a position in which we are interested in */</span> <a name="l00307"></a>00307 <a class="code" href="a00073.html#a9245e8649a64978e379c7fb613823869">crtc_info</a> *crtc; <a name="l00308"></a>00308 <a name="l00309"></a>00309 <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *<span class="keyword">new</span> = <a class="code" href="a00073.html#aa855dcabb5bc4a5f61663aea37b63f5b">get_output_by_id</a>(<span class="keywordtype">id</span>); <a name="l00310"></a>00310 <span class="keywordtype">bool</span> existing = (<span class="keyword">new</span> != NULL); <a name="l00311"></a>00311 <span class="keywordflow">if</span> (!existing) <a name="l00312"></a>00312 <span class="keyword">new</span> = <a class="code" href="a00077.html#ad475e1b898d9da9b2a8b92e3da51b3dd" title="Safe-wrapper around calloc which exits if malloc returns NULL (meaning that there...">scalloc</a>(<span class="keyword">sizeof</span>(<a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a>)); <a name="l00313"></a>00313 <span class="keyword">new</span>->id = id; <a name="l00314"></a>00314 <a class="code" href="a00052.html#ae88e84de75be0b138a19509d288b4cf4">FREE</a>(new->name); <a name="l00315"></a>00315 asprintf(&new->name, <span class="stringliteral">"%.*s"</span>, <a name="l00316"></a>00316 xcb_randr_get_output_info_name_length(output), <a name="l00317"></a>00317 xcb_randr_get_output_info_name(output)); <a name="l00318"></a>00318 <a name="l00319"></a>00319 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"found output with name %s\n"</span>, new->name); <a name="l00320"></a>00320 <a name="l00321"></a>00321 <span class="comment">/* Even if no CRTC is used at the moment, we store the output so that</span> <a name="l00322"></a>00322 <span class="comment"> * we do not need to change the list ever again (we only update the</span> <a name="l00323"></a>00323 <span class="comment"> * position/size) */</span> <a name="l00324"></a>00324 <span class="keywordflow">if</span> (output->crtc == XCB_NONE) { <a name="l00325"></a>00325 <span class="keywordflow">if</span> (!existing) <a name="l00326"></a>00326 <a class="code" href="a00047.html#a512bee16b46f601078c96c776d2648c3">TAILQ_INSERT_TAIL</a>(&<a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>, <span class="keyword">new</span>, <a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>); <a name="l00327"></a>00327 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (new->active) <a name="l00328"></a>00328 <span class="keyword">new</span>->to_be_disabled = <span class="keyword">true</span>; <a name="l00329"></a>00329 <span class="keywordflow">return</span>; <a name="l00330"></a>00330 } <a name="l00331"></a>00331 <a name="l00332"></a>00332 xcb_randr_get_crtc_info_cookie_t icookie; <a name="l00333"></a>00333 icookie = xcb_randr_get_crtc_info(conn, output->crtc, cts); <a name="l00334"></a>00334 <span class="keywordflow">if</span> ((crtc = xcb_randr_get_crtc_info_reply(conn, icookie, NULL)) == NULL) { <a name="l00335"></a>00335 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Skipping output %s: could not get CRTC (%p)\n"</span>, <a name="l00336"></a>00336 new->name, crtc); <a name="l00337"></a>00337 free(<span class="keyword">new</span>); <a name="l00338"></a>00338 <span class="keywordflow">return</span>; <a name="l00339"></a>00339 } <a name="l00340"></a>00340 <a name="l00341"></a>00341 <span class="keywordtype">bool</span> updated = <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(new->rect.x), crtc->x) | <a name="l00342"></a>00342 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(new->rect.y), crtc->y) | <a name="l00343"></a>00343 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(new->rect.width), crtc->width) | <a name="l00344"></a>00344 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(new->rect.height), crtc->height); <a name="l00345"></a>00345 free(crtc); <a name="l00346"></a>00346 <span class="keyword">new</span>->active = (<span class="keyword">new</span>->rect.width != 0 && <span class="keyword">new</span>->rect.height != 0); <a name="l00347"></a>00347 <span class="keywordflow">if</span> (!new->active) { <a name="l00348"></a>00348 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"width/height 0/0, disabling output\n"</span>); <a name="l00349"></a>00349 <span class="keywordflow">return</span>; <a name="l00350"></a>00350 } <a name="l00351"></a>00351 <a name="l00352"></a>00352 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"mode: %dx%d+%d+%d\n"</span>, new->rect.width, new->rect.height, <a name="l00353"></a>00353 new->rect.x, new->rect.y); <a name="l00354"></a>00354 <a name="l00355"></a>00355 <span class="comment">/* If we don’t need to change an existing output or if the output</span> <a name="l00356"></a>00356 <span class="comment"> * does not exist in the first place, the case is simple: we either</span> <a name="l00357"></a>00357 <span class="comment"> * need to insert the new output or we are done. */</span> <a name="l00358"></a>00358 <span class="keywordflow">if</span> (!updated || !existing) { <a name="l00359"></a>00359 <span class="keywordflow">if</span> (!existing) <a name="l00360"></a>00360 <a class="code" href="a00047.html#a512bee16b46f601078c96c776d2648c3">TAILQ_INSERT_TAIL</a>(&<a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>, <span class="keyword">new</span>, <a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>); <a name="l00361"></a>00361 <span class="keywordflow">return</span>; <a name="l00362"></a>00362 } <a name="l00363"></a>00363 <a name="l00364"></a>00364 <span class="keyword">new</span>->changed = <span class="keyword">true</span>; <a name="l00365"></a>00365 } <a name="l00366"></a>00366 <a name="l00367"></a><a class="code" href="a00073.html#aaf667527eed0bcd14d62a3dd1e4484d7">00367</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="a00073.html#aaf667527eed0bcd14d62a3dd1e4484d7">init_workspaces</a>() { <a name="l00368"></a>00368 <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output; <a name="l00369"></a>00369 <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws; <a name="l00370"></a>00370 <a name="l00371"></a>00371 <span class="comment">/* Just go through each active output and associate one workspace */</span> <a name="l00372"></a>00372 <a class="code" href="a00047.html#a16e5fc168e7f3494d4b1df54447d871e">TAILQ_FOREACH</a>(output, &<a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>, <a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>) { <a name="l00373"></a>00373 <span class="keywordflow">if</span> (!output-><a class="code" href="a00026.html#a7c56e7415ebe0aa040614d1244e2da6b" title="Whether the output is currently active (has a CRTC attached with a valid mode).">active</a> || output-><a class="code" href="a00026.html#a9bcf702b65d8f47f98eafbefff529ffe" title="Current workspace selected on this virtual screen.">current_workspace</a> != NULL) <a name="l00374"></a>00374 <span class="keywordflow">continue</span>; <a name="l00375"></a>00375 ws = <a class="code" href="a00078.html#a3fae69bcec850a9a117b9f0cee6a19c0" title="Gets the first unused workspace for the given screen, taking into account the preferred_screen...">get_first_workspace_for_output</a>(output); <a name="l00376"></a>00376 <a class="code" href="a00073.html#a3b4d451b80a25c4d2df53a45f85ee637" title="Initializes the specified output, assigning the specified workspace to it.">initialize_output</a>(<a class="code" href="a00071.html#ada13c42121d64521629e06e7a5e1db16">global_conn</a>, output, ws); <a name="l00377"></a>00377 } <a name="l00378"></a>00378 <a name="l00379"></a>00379 <span class="comment">/* render_layout flushes */</span> <a name="l00380"></a>00380 <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>(<a class="code" href="a00071.html#ada13c42121d64521629e06e7a5e1db16">global_conn</a>); <a name="l00381"></a>00381 } <a name="l00382"></a>00382 <a name="l00383"></a>00383 <span class="comment">/*</span> <a name="l00384"></a>00384 <span class="comment"> * (Re-)queries the outputs via RandR and stores them in the list of outputs.</span> <a name="l00385"></a>00385 <span class="comment"> *</span> <a name="l00386"></a>00386 <span class="comment"> */</span> <a name="l00387"></a><a class="code" href="a00048.html#ace31eff56142111b49e1e88608c8964a">00387</a> <span class="keywordtype">void</span> <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>(xcb_connection_t *conn) { <a name="l00388"></a>00388 <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws; <a name="l00389"></a>00389 <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output, *other, *first; <a name="l00390"></a>00390 xcb_randr_get_screen_resources_current_cookie_t rcookie; <a name="l00391"></a>00391 <a class="code" href="a00073.html#a97f36df51cdd1efbad0a2b067f63c7bc">resources_reply</a> *res; <a name="l00392"></a>00392 <span class="comment">/* timestamp of the configuration so that we get consistent replies to all</span> <a name="l00393"></a>00393 <span class="comment"> * requests (if the configuration changes between our different calls) */</span> <a name="l00394"></a>00394 xcb_timestamp_t cts; <a name="l00395"></a>00395 <a name="l00396"></a>00396 <span class="comment">/* an output is VGA-1, LVDS-1, etc. (usually physical video outputs) */</span> <a name="l00397"></a>00397 xcb_randr_output_t *randr_outputs; <a name="l00398"></a>00398 <a name="l00399"></a>00399 <span class="keywordflow">if</span> (<a class="code" href="a00073.html#a93c5408e1e62034f8b292cc65ee9ab7f">randr_disabled</a>) <a name="l00400"></a>00400 <span class="keywordflow">return</span>; <a name="l00401"></a>00401 <a name="l00402"></a>00402 <span class="comment">/* Get screen resources (crtcs, outputs, modes) */</span> <a name="l00403"></a>00403 rcookie = xcb_randr_get_screen_resources_current(conn, <a class="code" href="a00071.html#a768f07da9e11ab88732a5c550ff49257">root</a>); <a name="l00404"></a>00404 <span class="keywordflow">if</span> ((res = xcb_randr_get_screen_resources_current_reply(conn, rcookie, NULL)) == NULL) { <a name="l00405"></a>00405 <a class="code" href="a00073.html#a0d7c5d1d6273f607dc9285621e988e08" title="Disables RandR support by creating exactly one output with the size of the X11 screen...">disable_randr</a>(conn); <a name="l00406"></a>00406 <a class="code" href="a00073.html#aaf667527eed0bcd14d62a3dd1e4484d7">init_workspaces</a>(); <a name="l00407"></a>00407 <span class="keywordflow">return</span>; <a name="l00408"></a>00408 } <a name="l00409"></a>00409 cts = res->config_timestamp; <a name="l00410"></a>00410 <a name="l00411"></a>00411 <span class="keywordtype">int</span> len = xcb_randr_get_screen_resources_current_outputs_length(res); <a name="l00412"></a>00412 randr_outputs = xcb_randr_get_screen_resources_current_outputs(res); <a name="l00413"></a>00413 <a name="l00414"></a>00414 <span class="comment">/* Request information for each output */</span> <a name="l00415"></a>00415 xcb_randr_get_output_info_cookie_t ocookie[len]; <a name="l00416"></a>00416 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < len; i++) <a name="l00417"></a>00417 ocookie[i] = xcb_randr_get_output_info(conn, randr_outputs[i], cts); <a name="l00418"></a>00418 <a name="l00419"></a>00419 <span class="comment">/* Loop through all outputs available for this X11 screen */</span> <a name="l00420"></a>00420 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < len; i++) { <a name="l00421"></a>00421 xcb_randr_get_output_info_reply_t *output; <a name="l00422"></a>00422 <a name="l00423"></a>00423 <span class="keywordflow">if</span> ((output = xcb_randr_get_output_info_reply(conn, ocookie[i], NULL)) == NULL) <a name="l00424"></a>00424 <span class="keywordflow">continue</span>; <a name="l00425"></a>00425 <a name="l00426"></a>00426 <a class="code" href="a00073.html#a80da9f337292bbd64123b233f0a43a7a">handle_output</a>(conn, randr_outputs[i], output, cts, res); <a name="l00427"></a>00427 free(output); <a name="l00428"></a>00428 } <a name="l00429"></a>00429 <a name="l00430"></a>00430 free(res); <a name="l00431"></a>00431 <span class="comment">/* Check for clones, disable the clones and reduce the mode to the</span> <a name="l00432"></a>00432 <span class="comment"> * lowest common mode */</span> <a name="l00433"></a>00433 <a class="code" href="a00047.html#a16e5fc168e7f3494d4b1df54447d871e">TAILQ_FOREACH</a>(output, &<a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>, <a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>) { <a name="l00434"></a>00434 <span class="keywordflow">if</span> (!output-><a class="code" href="a00026.html#a7c56e7415ebe0aa040614d1244e2da6b" title="Whether the output is currently active (has a CRTC attached with a valid mode).">active</a> || output-><a class="code" href="a00026.html#a7b4041fff9af92986ea35fe167760c76">to_be_disabled</a>) <a name="l00435"></a>00435 <span class="keywordflow">continue</span>; <a name="l00436"></a>00436 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"output %p, position (%d, %d), checking for clones\n"</span>, <a name="l00437"></a>00437 output, output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a>, output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>); <a name="l00438"></a>00438 <a name="l00439"></a>00439 <span class="keywordflow">for</span> (other = output; <a name="l00440"></a>00440 other != <a class="code" href="a00047.html#a4322b8461a6ab7632435ff4f57bb3a2e">TAILQ_END</a>(&<a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>); <a name="l00441"></a>00441 other = <a class="code" href="a00047.html#abd57fe9bdea6007a602f8c7d61bd5265">TAILQ_NEXT</a>(other, <a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>)) { <a name="l00442"></a>00442 <span class="keywordflow">if</span> (other == output || !other-><a class="code" href="a00026.html#a7c56e7415ebe0aa040614d1244e2da6b" title="Whether the output is currently active (has a CRTC attached with a valid mode).">active</a> || other-><a class="code" href="a00026.html#a7b4041fff9af92986ea35fe167760c76">to_be_disabled</a>) <a name="l00443"></a>00443 <span class="keywordflow">continue</span>; <a name="l00444"></a>00444 <a name="l00445"></a>00445 <span class="keywordflow">if</span> (other-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> != output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> || <a name="l00446"></a>00446 other-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> != output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a>) <a name="l00447"></a>00447 <span class="keywordflow">continue</span>; <a name="l00448"></a>00448 <a name="l00449"></a>00449 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"output %p has the same position, his mode = %d x %d\n"</span>, <a name="l00450"></a>00450 other, other-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, other-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>); <a name="l00451"></a>00451 uint32_t width = <a class="code" href="a00077.html#abd8bbcfabb3ddef2ccaafb9928a37b95">min</a>(other-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>); <a name="l00452"></a>00452 uint32_t height = <a class="code" href="a00077.html#abd8bbcfabb3ddef2ccaafb9928a37b95">min</a>(other-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>, output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>); <a name="l00453"></a>00453 <a name="l00454"></a>00454 <span class="keywordflow">if</span> (<a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>), width) | <a name="l00455"></a>00455 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>), height)) <a name="l00456"></a>00456 output-><a class="code" href="a00026.html#a48ee50473c1b9df6dc1e2439f2c24c44" title="Internal flags, necessary for querying RandR screens (happens in two stages).">changed</a> = <span class="keyword">true</span>; <a name="l00457"></a>00457 <a name="l00458"></a>00458 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(other-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>), width); <a name="l00459"></a>00459 <a class="code" href="a00077.html#a4dfa7907c5f327e6383b32d6e8acde8f" title="Updates *destination with new_value and returns true if it was changed or false if...">update_if_necessary</a>(&(other-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>), height); <a name="l00460"></a>00460 <a name="l00461"></a>00461 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"disabling output %p (%s)\n"</span>, other, other-><a class="code" href="a00026.html#a4c8b185b15cf45e3ca300cb54b2d4650" title="Name of the output.">name</a>); <a name="l00462"></a>00462 other-><a class="code" href="a00026.html#a7b4041fff9af92986ea35fe167760c76">to_be_disabled</a> = <span class="keyword">true</span>; <a name="l00463"></a>00463 <a name="l00464"></a>00464 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"new output mode %d x %d, other mode %d x %d\n"</span>, <a name="l00465"></a>00465 output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, output-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>, <a name="l00466"></a>00466 other-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>, other-><a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>); <a name="l00467"></a>00467 } <a name="l00468"></a>00468 } <a name="l00469"></a>00469 <a name="l00470"></a>00470 <span class="comment">/* Handle outputs which have a new mode or are disabled now (either</span> <a name="l00471"></a>00471 <span class="comment"> * because the user disabled them or because they are clones) */</span> <a name="l00472"></a>00472 <a class="code" href="a00047.html#a16e5fc168e7f3494d4b1df54447d871e">TAILQ_FOREACH</a>(output, &<a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>, <a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>) { <a name="l00473"></a>00473 <span class="keywordflow">if</span> (output-><a class="code" href="a00026.html#a7b4041fff9af92986ea35fe167760c76">to_be_disabled</a>) { <a name="l00474"></a>00474 output-><a class="code" href="a00026.html#a7c56e7415ebe0aa040614d1244e2da6b" title="Whether the output is currently active (has a CRTC attached with a valid mode).">active</a> = <span class="keyword">false</span>; <a name="l00475"></a>00475 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">"Output %s disabled, re-assigning workspaces/docks\n"</span>, output-><a class="code" href="a00026.html#a4c8b185b15cf45e3ca300cb54b2d4650" title="Name of the output.">name</a>); <a name="l00476"></a>00476 <a name="l00477"></a>00477 <span class="keywordflow">if</span> ((first = <a class="code" href="a00073.html#a514adc4dcfc06b1e9329e41633c65fb0" title="Returns the first output which is active.">get_first_output</a>()) == NULL) <a name="l00478"></a>00478 <a class="code" href="a00052.html#a0b2164ee75646f16a7388a36e6800c35">die</a>(<span class="stringliteral">"No usable outputs available\n"</span>); <a name="l00479"></a>00479 <a name="l00480"></a>00480 <span class="keywordtype">bool</span> needs_init = (first-><a class="code" href="a00026.html#a9bcf702b65d8f47f98eafbefff529ffe" title="Current workspace selected on this virtual screen.">current_workspace</a> == NULL); <a name="l00481"></a>00481 <a name="l00482"></a>00482 <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="l00483"></a>00483 <span class="keywordflow">if</span> (ws-><a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a> != output) <a name="l00484"></a>00484 <span class="keywordflow">continue</span>; <a name="l00485"></a>00485 <a name="l00486"></a>00486 <a class="code" href="a00078.html#adadfb8fab9d410f05869cc1808f3922f" title="Assigns the given workspace to the given screen by correctly updating its state and...">workspace_assign_to</a>(ws, first, <span class="keyword">true</span>); <a name="l00487"></a>00487 <span class="keywordflow">if</span> (!needs_init) <a name="l00488"></a>00488 <span class="keywordflow">continue</span>; <a name="l00489"></a>00489 <a class="code" href="a00073.html#a3b4d451b80a25c4d2df53a45f85ee637" title="Initializes the specified output, assigning the specified workspace to it.">initialize_output</a>(conn, first, ws); <a name="l00490"></a>00490 needs_init = <span class="keyword">false</span>; <a name="l00491"></a>00491 } <a name="l00492"></a>00492 <a name="l00493"></a>00493 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *dock; <a name="l00494"></a>00494 <span class="keywordflow">while</span> (!<a class="code" href="a00047.html#a59bcc4e6f4bf63b897bdc0644566c583">SLIST_EMPTY</a>(&(output->dock_clients))) { <a name="l00495"></a>00495 dock = <a class="code" href="a00047.html#a91bac7d0d32e3ec56bc579ace45ed8cd">SLIST_FIRST</a>(&(output->dock_clients)); <a name="l00496"></a>00496 <a class="code" href="a00047.html#aeb10c664372b3b680455274170f4c897">SLIST_REMOVE_HEAD</a>(&(output->dock_clients), dock_clients); <a name="l00497"></a>00497 <a class="code" href="a00047.html#a48df7439e09a419afabdd1f2f8551e73">SLIST_INSERT_HEAD</a>(&(first->dock_clients), dock, dock_clients); <a name="l00498"></a>00498 } <a name="l00499"></a>00499 output-><a class="code" href="a00026.html#a9bcf702b65d8f47f98eafbefff529ffe" title="Current workspace selected on this virtual screen.">current_workspace</a> = NULL; <a name="l00500"></a>00500 output-><a class="code" href="a00026.html#a7b4041fff9af92986ea35fe167760c76">to_be_disabled</a> = <span class="keyword">false</span>; <a name="l00501"></a>00501 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (output-><a class="code" href="a00026.html#a48ee50473c1b9df6dc1e2439f2c24c44" title="Internal flags, necessary for querying RandR screens (happens in two stages).">changed</a>) { <a name="l00502"></a>00502 <a class="code" href="a00073.html#a601f4c6e49b7082de5d5a228030bbe40">output_change_mode</a>(conn, output); <a name="l00503"></a>00503 output-><a class="code" href="a00026.html#a48ee50473c1b9df6dc1e2439f2c24c44" title="Internal flags, necessary for querying RandR screens (happens in two stages).">changed</a> = <span class="keyword">false</span>; <a name="l00504"></a>00504 } <a name="l00505"></a>00505 } <a name="l00506"></a>00506 <a name="l00507"></a>00507 <span class="keywordflow">if</span> (<a class="code" href="a00047.html#ac3c9da7ac712eacbbad5cc54d7a3477e">TAILQ_EMPTY</a>(&<a class="code" href="a00073.html#a9fecba0738529e3d9ff0d4fa7c31ffa9">outputs</a>)) { <a name="l00508"></a>00508 <a class="code" href="a00044.html#a6828c68e0feb4b7fdfe0fc3ba9f3038b">ELOG</a>(<span class="stringliteral">"No outputs found via RandR, disabling\n"</span>); <a name="l00509"></a>00509 <a class="code" href="a00073.html#a0d7c5d1d6273f607dc9285621e988e08" title="Disables RandR support by creating exactly one output with the size of the X11 screen...">disable_randr</a>(conn); <a name="l00510"></a>00510 } <a name="l00511"></a>00511 <a name="l00512"></a>00512 <a class="code" href="a00065.html#aefdaf6a17c2aa3979c49e3ff74cfee56" title="Updates the workarea for each desktop.">ewmh_update_workarea</a>(); <a name="l00513"></a>00513 <a name="l00514"></a>00514 <a class="code" href="a00073.html#aaf667527eed0bcd14d62a3dd1e4484d7">init_workspaces</a>(); <a name="l00515"></a>00515 } <a name="l00516"></a>00516 <a name="l00517"></a>00517 <span class="comment">/*</span> <a name="l00518"></a>00518 <span class="comment"> * We have just established a connection to the X server and need the initial</span> <a name="l00519"></a>00519 <span class="comment"> * XRandR information to setup workspaces for each screen.</span> <a name="l00520"></a>00520 <span class="comment"> *</span> <a name="l00521"></a>00521 <span class="comment"> */</span> <a name="l00522"></a><a class="code" href="a00048.html#a6a7a017cf0668c2b9aba5011bdd7e9f3">00522</a> <span class="keywordtype">void</span> <a class="code" href="a00073.html#a6a7a017cf0668c2b9aba5011bdd7e9f3" title="We have just established a connection to the X server and need the initial XRandR...">initialize_randr</a>(xcb_connection_t *conn, <span class="keywordtype">int</span> *event_base) { <a name="l00523"></a>00523 <span class="keyword">const</span> xcb_query_extension_reply_t *extreply; <a name="l00524"></a>00524 <a name="l00525"></a>00525 extreply = xcb_get_extension_data(conn, &xcb_randr_id); <a name="l00526"></a>00526 <span class="keywordflow">if</span> (!extreply->present) <a name="l00527"></a>00527 <a class="code" href="a00073.html#a0d7c5d1d6273f607dc9285621e988e08" title="Disables RandR support by creating exactly one output with the size of the X11 screen...">disable_randr</a>(conn); <a name="l00528"></a>00528 <span class="keywordflow">else</span> <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="l00529"></a>00529 <a name="l00530"></a>00530 <span class="keywordflow">if</span> (event_base != NULL) <a name="l00531"></a>00531 *event_base = extreply->first_event; <a name="l00532"></a>00532 <a name="l00533"></a>00533 xcb_randr_select_input(conn, <a class="code" href="a00071.html#a768f07da9e11ab88732a5c550ff49257">root</a>, <a name="l00534"></a>00534 XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE | <a name="l00535"></a>00535 XCB_RANDR_NOTIFY_MASK_OUTPUT_CHANGE | <a name="l00536"></a>00536 XCB_RANDR_NOTIFY_MASK_CRTC_CHANGE | <a name="l00537"></a>00537 XCB_RANDR_NOTIFY_MASK_OUTPUT_PROPERTY); <a name="l00538"></a>00538 <a name="l00539"></a>00539 xcb_flush(conn); <a name="l00540"></a>00540 } </pre></div></div> <hr class="footer"/><address style="text-align: right;"><small>Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.2-20100208 </small></address> </body> </html>