Sophie

Sophie

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

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/workspace.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/workspace.c</h1><a href="a00078.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"> * workspace.c: Functions for modifying workspaces</span>
<a name="l00011"></a>00011 <span class="comment"> *</span>
<a name="l00012"></a>00012 <span class="comment"> */</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;limits.h&gt;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;err.h&gt;</span>
<a name="l00018"></a>00018 
<a name="l00019"></a>00019 <span class="preprocessor">#include &quot;<a class="code" href="a00052.html">util.h</a>&quot;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;<a class="code" href="a00036.html">data.h</a>&quot;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &quot;<a class="code" href="a00041.html">i3.h</a>&quot;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &quot;<a class="code" href="a00034.html">config.h</a>&quot;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &quot;<a class="code" href="a00054.html">xcb.h</a>&quot;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &quot;<a class="code" href="a00051.html">table.h</a>&quot;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &quot;<a class="code" href="a00048.html">randr.h</a>&quot;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &quot;<a class="code" href="a00043.html">layout.h</a>&quot;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &quot;<a class="code" href="a00053.html">workspace.h</a>&quot;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &quot;<a class="code" href="a00032.html">client.h</a>&quot;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &quot;<a class="code" href="a00044.html">log.h</a>&quot;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &quot;<a class="code" href="a00038.html">ewmh.h</a>&quot;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &quot;<a class="code" href="a00042.html">ipc.h</a>&quot;</span>
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 <span class="comment">/*</span>
<a name="l00034"></a>00034 <span class="comment"> * Returns a pointer to the workspace with the given number (starting at 0),</span>
<a name="l00035"></a>00035 <span class="comment"> * creating the workspace if necessary (by allocating the necessary amount of</span>
<a name="l00036"></a>00036 <span class="comment"> * memory and initializing the data structures correctly).</span>
<a name="l00037"></a>00037 <span class="comment"> *</span>
<a name="l00038"></a>00038 <span class="comment"> */</span>
<a name="l00039"></a><a class="code" href="a00053.html#a73833335a85bfc97bdff285b151ab1c5">00039</a> <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *<a class="code" href="a00078.html#a73833335a85bfc97bdff285b151ab1c5" title="Returns a pointer to the workspace with the given number (starting at 0), creating...">workspace_get</a>(<span class="keywordtype">int</span> number) {
<a name="l00040"></a>00040         <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws = NULL;
<a name="l00041"></a>00041         <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="l00042"></a>00042                 <span class="keywordflow">if</span> (ws-&gt;<a class="code" href="a00025.html#a7dfb9b375b2740db75bb82eb0b2be41d" title="Number of this workspace, starting from 0.">num</a> == number)
<a name="l00043"></a>00043                         <span class="keywordflow">return</span> ws;
<a name="l00044"></a>00044 
<a name="l00045"></a>00045         <span class="comment">/* If we are still there, we could not find the requested workspace. */</span>
<a name="l00046"></a>00046         <span class="keywordtype">int</span> last_ws = <a class="code" href="a00047.html#ac9154a9aebb3c15a3f2356349a1cc14f">TAILQ_LAST</a>(<a class="code" href="a00076.html#afb45f3a3a9c66c3e3a5e4d372ae24da7">workspaces</a>, workspaces_head)-&gt;num;
<a name="l00047"></a>00047 
<a name="l00048"></a>00048         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;We need to initialize that one, last ws = %d\n&quot;</span>, last_ws);
<a name="l00049"></a>00049 
<a name="l00050"></a>00050         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> c = last_ws; c &lt; number; c++) {
<a name="l00051"></a>00051                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Creating new ws\n&quot;</span>);
<a name="l00052"></a>00052 
<a name="l00053"></a>00053                 ws = <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="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a>));
<a name="l00054"></a>00054                 ws-&gt;<a class="code" href="a00025.html#a7dfb9b375b2740db75bb82eb0b2be41d" title="Number of this workspace, starting from 0.">num</a> = c+1;
<a name="l00055"></a>00055                 <a class="code" href="a00047.html#a449d224023780e46253b83b61e0a50a9">TAILQ_INIT</a>(&amp;(ws-&gt;floating_clients));
<a name="l00056"></a>00056                 <a class="code" href="a00076.html#ac58314a435fd187ce2ed416b9dc8019f" title="Add one column to the table.">expand_table_cols</a>(ws);
<a name="l00057"></a>00057                 <a class="code" href="a00076.html#a8fb9ac616cc935e2fd54c6bcb6563df1" title="Add one row to the table.">expand_table_rows</a>(ws);
<a name="l00058"></a>00058                 <a class="code" href="a00078.html#a492c5885bad35ce073562238ab5bc72d" title="Sets the name (or just its number) for the given workspace.">workspace_set_name</a>(ws, NULL);
<a name="l00059"></a>00059 
<a name="l00060"></a>00060                 <a class="code" href="a00047.html#a512bee16b46f601078c96c776d2648c3">TAILQ_INSERT_TAIL</a>(<a class="code" href="a00076.html#afb45f3a3a9c66c3e3a5e4d372ae24da7">workspaces</a>, ws, <a class="code" href="a00076.html#afb45f3a3a9c66c3e3a5e4d372ae24da7">workspaces</a>);
<a name="l00061"></a>00061 
<a name="l00062"></a>00062                 <a class="code" href="a00068.html#ad525c6fad9f4978ae1f06282ad9de6c6" title="Sends the specified event to all IPC clients which are currently connected and subscribed...">ipc_send_event</a>(<span class="stringliteral">&quot;workspace&quot;</span>, I3_IPC_EVENT_WORKSPACE, <span class="stringliteral">&quot;{\&quot;change\&quot;:\&quot;init\&quot;}&quot;</span>);
<a name="l00063"></a>00063         }
<a name="l00064"></a>00064         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;done\n&quot;</span>);
<a name="l00065"></a>00065 
<a name="l00066"></a>00066         <a class="code" href="a00065.html#aefdaf6a17c2aa3979c49e3ff74cfee56" title="Updates the workarea for each desktop.">ewmh_update_workarea</a>();
<a name="l00067"></a>00067 
<a name="l00068"></a>00068         <span class="keywordflow">return</span> ws;
<a name="l00069"></a>00069 }
<a name="l00070"></a>00070 
<a name="l00071"></a>00071 <span class="comment">/*</span>
<a name="l00072"></a>00072 <span class="comment"> * Sets the name (or just its number) for the given workspace. This has to</span>
<a name="l00073"></a>00073 <span class="comment"> * be called for every workspace as the rendering function</span>
<a name="l00074"></a>00074 <span class="comment"> * (render_internal_bar) relies on workspace-&gt;name and workspace-&gt;name_len</span>
<a name="l00075"></a>00075 <span class="comment"> * being ready-to-use.</span>
<a name="l00076"></a>00076 <span class="comment"> *</span>
<a name="l00077"></a>00077 <span class="comment"> */</span>
<a name="l00078"></a><a class="code" href="a00053.html#a492c5885bad35ce073562238ab5bc72d">00078</a> <span class="keywordtype">void</span> <a class="code" href="a00078.html#a492c5885bad35ce073562238ab5bc72d" title="Sets the name (or just its number) for the given workspace.">workspace_set_name</a>(<a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws, <span class="keyword">const</span> <span class="keywordtype">char</span> *name) {
<a name="l00079"></a>00079         <span class="keywordtype">char</span> *label;
<a name="l00080"></a>00080         <span class="keywordtype">int</span> ret;
<a name="l00081"></a>00081 
<a name="l00082"></a>00082         <span class="keywordflow">if</span> (name != NULL)
<a name="l00083"></a>00083                 ret = asprintf(&amp;label, <span class="stringliteral">&quot;%d: %s&quot;</span>, ws-&gt;<a class="code" href="a00025.html#a7dfb9b375b2740db75bb82eb0b2be41d" title="Number of this workspace, starting from 0.">num</a> + 1, name);
<a name="l00084"></a>00084         <span class="keywordflow">else</span> ret = asprintf(&amp;label, <span class="stringliteral">&quot;%d&quot;</span>, ws-&gt;<a class="code" href="a00025.html#a7dfb9b375b2740db75bb82eb0b2be41d" title="Number of this workspace, starting from 0.">num</a> + 1);
<a name="l00085"></a>00085 
<a name="l00086"></a>00086         <span class="keywordflow">if</span> (ret == -1)
<a name="l00087"></a>00087                 errx(1, <span class="stringliteral">&quot;asprintf() failed&quot;</span>);
<a name="l00088"></a>00088 
<a name="l00089"></a>00089         <a class="code" href="a00052.html#ae88e84de75be0b138a19509d288b4cf4">FREE</a>(ws-&gt;<a class="code" href="a00025.html#a2db20d0a3a8866278611898710445017" title="Name of the workspace (in UCS-2).">name</a>);
<a name="l00090"></a>00090         <a class="code" href="a00052.html#ae88e84de75be0b138a19509d288b4cf4">FREE</a>(ws-&gt;<a class="code" href="a00025.html#a2cf7e70b45757f1c61a34f5b50767765" title="Name of the workspace (in UTF-8).">utf8_name</a>);
<a name="l00091"></a>00091 
<a name="l00092"></a>00092         ws-&gt;<a class="code" href="a00025.html#a2db20d0a3a8866278611898710445017" title="Name of the workspace (in UCS-2).">name</a> = <a class="code" href="a00077.html#a1d926a6371d3d87f2dd85c1a27d83f4b" title="Converts the given string to UCS-2 big endian for use with xcb_image_text_16().">convert_utf8_to_ucs2</a>(label, &amp;(ws-&gt;<a class="code" href="a00025.html#a190c6f4026f0bff8b0d49340823fc1e1" title="Length of the workspace’s name (in glyphs).">name_len</a>));
<a name="l00093"></a>00093         <span class="keywordflow">if</span> (<a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#aff568f0d5ca7a51971f4c3006a842019">font</a> != NULL)
<a name="l00094"></a>00094                 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 class="code" href="a00079.html#a01397b2251980ca02d24194293fc79d0" title="Calculate the width of the given text (16-bit characters, UCS) with given real length...">predict_text_width</a>(<a class="code" href="a00071.html#ada13c42121d64521629e06e7a5e1db16">global_conn</a>, <a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#aff568f0d5ca7a51971f4c3006a842019">font</a>, ws-&gt;<a class="code" href="a00025.html#a2db20d0a3a8866278611898710445017" title="Name of the workspace (in UCS-2).">name</a>, ws-&gt;<a class="code" href="a00025.html#a190c6f4026f0bff8b0d49340823fc1e1" title="Length of the workspace’s name (in glyphs).">name_len</a>);
<a name="l00095"></a>00095         <span class="keywordflow">else</span> 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> = 0;
<a name="l00096"></a>00096         ws-&gt;<a class="code" href="a00025.html#a2cf7e70b45757f1c61a34f5b50767765" title="Name of the workspace (in UTF-8).">utf8_name</a> = label;
<a name="l00097"></a>00097 }
<a name="l00098"></a>00098 
<a name="l00099"></a>00099 <span class="comment">/*</span>
<a name="l00100"></a>00100 <span class="comment"> * Returns true if the workspace is currently visible. Especially important for</span>
<a name="l00101"></a>00101 <span class="comment"> * multi-monitor environments, as they can have multiple currenlty active</span>
<a name="l00102"></a>00102 <span class="comment"> * workspaces.</span>
<a name="l00103"></a>00103 <span class="comment"> *</span>
<a name="l00104"></a>00104 <span class="comment"> */</span>
<a name="l00105"></a><a class="code" href="a00053.html#a7a4e9d7994d904776ead4c8fc1b22091">00105</a> <span class="keywordtype">bool</span> <a class="code" href="a00078.html#a7a4e9d7994d904776ead4c8fc1b22091" title="Returns true if the workspace is currently visible.">workspace_is_visible</a>(<a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws) {
<a name="l00106"></a>00106         <span class="keywordflow">return</span> (ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a> != NULL &amp;&amp; ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>-&gt;<a class="code" href="a00026.html#a9bcf702b65d8f47f98eafbefff529ffe" title="Current workspace selected on this virtual screen.">current_workspace</a> == ws);
<a name="l00107"></a>00107 }
<a name="l00108"></a>00108 
<a name="l00109"></a>00109 <span class="comment">/*</span>
<a name="l00110"></a>00110 <span class="comment"> * Switches to the given workspace</span>
<a name="l00111"></a>00111 <span class="comment"> *</span>
<a name="l00112"></a>00112 <span class="comment"> */</span>
<a name="l00113"></a><a class="code" href="a00053.html#a2f31983877c705919ed85c985220855e">00113</a> <span class="keywordtype">void</span> <a class="code" href="a00078.html#a2f31983877c705919ed85c985220855e" title="Switches to the given workspace.">workspace_show</a>(xcb_connection_t *conn, <span class="keywordtype">int</span> workspace) {
<a name="l00114"></a>00114         <span class="keywordtype">bool</span> need_warp = <span class="keyword">false</span>;
<a name="l00115"></a>00115         xcb_window_t <a class="code" href="a00071.html#a768f07da9e11ab88732a5c550ff49257">root</a> = xcb_setup_roots_iterator(xcb_get_setup(conn)).data-&gt;root;
<a name="l00116"></a>00116         <span class="comment">/* t_ws (to workspace) is just a convenience pointer to the workspace we’re switching to */</span>
<a name="l00117"></a>00117         <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *t_ws = <a class="code" href="a00078.html#a73833335a85bfc97bdff285b151ab1c5" title="Returns a pointer to the workspace with the given number (starting at 0), creating...">workspace_get</a>(workspace-1);
<a name="l00118"></a>00118 
<a name="l00119"></a>00119         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;show_workspace(%d)\n&quot;</span>, workspace);
<a name="l00120"></a>00120 
<a name="l00121"></a>00121         <span class="comment">/* Store current_row/current_col */</span>
<a name="l00122"></a>00122         <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#a86fefbdc838f2b5593ea2521378e4ddd" title="These are stored here only while this workspace is _not_ shown (see show_workspace())...">current_row</a> = <a class="code" href="a00076.html#a40ba377d6a3a574ff03b859bc7cdd4b0">current_row</a>;
<a name="l00123"></a>00123         <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#ab683091dfe46963b2dd0761e8e5f9e16" title="These are stored here only while this workspace is _not_ shown (see show_workspace())...">current_col</a> = <a class="code" href="a00076.html#a5f839b3ac61c0771c9f8fbef974afe76">current_col</a>;
<a name="l00124"></a>00124 
<a name="l00125"></a>00125         <span class="comment">/* Check if the workspace has not been used yet */</span>
<a name="l00126"></a>00126         <a class="code" href="a00078.html#a8339966acb1a826e826e9b20bfb754f6" title="Initializes the given workspace if it is not already initialized.">workspace_initialize</a>(t_ws, <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>, <span class="keyword">false</span>);
<a name="l00127"></a>00127 
<a name="l00128"></a>00128         <span class="keywordflow">if</span> (<a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a> != t_ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>) {
<a name="l00129"></a>00129                 <span class="comment">/* We need to switch to the other output first */</span>
<a name="l00130"></a>00130                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;moving over to other output.\n&quot;</span>);
<a name="l00131"></a>00131 
<a name="l00132"></a>00132                 <span class="comment">/* Store the old client */</span>
<a name="l00133"></a>00133                 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *old_client = <a class="code" href="a00051.html#ac120dc3752e8ac2853ddd65d7737a2fd">CUR_CELL</a>-&gt;currently_focused;
<a name="l00134"></a>00134 
<a name="l00135"></a>00135                 <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a> = t_ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>-&gt;<a class="code" href="a00026.html#a9bcf702b65d8f47f98eafbefff529ffe" title="Current workspace selected on this virtual screen.">current_workspace</a>;
<a name="l00136"></a>00136                 <a class="code" href="a00076.html#a5f839b3ac61c0771c9f8fbef974afe76">current_col</a> = <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#ab683091dfe46963b2dd0761e8e5f9e16" title="These are stored here only while this workspace is _not_ shown (see show_workspace())...">current_col</a>;
<a name="l00137"></a>00137                 <a class="code" href="a00076.html#a40ba377d6a3a574ff03b859bc7cdd4b0">current_row</a> = <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#a86fefbdc838f2b5593ea2521378e4ddd" title="These are stored here only while this workspace is _not_ shown (see show_workspace())...">current_row</a>;
<a name="l00138"></a>00138                 <span class="keywordflow">if</span> (<a class="code" href="a00051.html#ac120dc3752e8ac2853ddd65d7737a2fd">CUR_CELL</a>-&gt;currently_focused != NULL)
<a name="l00139"></a>00139                         need_warp = <span class="keyword">true</span>;
<a name="l00140"></a>00140                 <span class="keywordflow">else</span> {
<a name="l00141"></a>00141                         <a class="code" href="a00020.html" title="Stores a rectangle, for example the size of a window, the child window etc.">Rect</a> *dims = &amp;(<a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>-&gt;<a class="code" href="a00026.html#aedbb714bf5d5ef9a28b5ff048321ed99" title="x, y, width, height">rect</a>);
<a name="l00142"></a>00142                         xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0,
<a name="l00143"></a>00143                                          dims-&gt;<a class="code" href="a00020.html#a6f5ab43ec9da45a9c3ddbc45d9aa3bbc">x</a> + (dims-&gt;<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a> / 2), dims-&gt;<a class="code" href="a00020.html#ac77eddc4cc31fe7881da4a23cdca0ea5">y</a> + (dims-&gt;<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> / 2));
<a name="l00144"></a>00144                 }
<a name="l00145"></a>00145 
<a name="l00146"></a>00146                 <span class="comment">/* Re-decorate the old client, it’s not focused anymore */</span>
<a name="l00147"></a>00147                 <span class="keywordflow">if</span> ((old_client != NULL) &amp;&amp; !old_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="l00148"></a>00148                         <a class="code" href="a00069.html#ac78b8a4b371d2c4c2800c765f46e5df3" title="Redecorates the given client correctly by checking if it’s in a stacking container...">redecorate_window</a>(conn, old_client);
<a name="l00149"></a>00149                 <span class="keywordflow">else</span> xcb_flush(conn);
<a name="l00150"></a>00150 
<a name="l00151"></a>00151                 <span class="comment">/* We need to check if a global fullscreen-client is blocking</span>
<a name="l00152"></a>00152 <span class="comment">                 * the t_ws and if necessary switch that to local fullscreen */</span>
<a name="l00153"></a>00153                 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a>* client = <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#a918ace3a3d2f03c58ec8fa05ac97275e" title="the client who is started in fullscreen mode on this workspace, NULL if there is...">fullscreen_client</a>;
<a name="l00154"></a>00154                 <span class="keywordflow">if</span> (client != NULL &amp;&amp; client-&gt;<a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a> != <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>) {
<a name="l00155"></a>00155                         <span class="keywordflow">if</span> (<a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#a918ace3a3d2f03c58ec8fa05ac97275e" title="the client who is started in fullscreen mode on this workspace, NULL if there is...">fullscreen_client</a>-&gt;<a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a> != <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>)
<a name="l00156"></a>00156                                 <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#a918ace3a3d2f03c58ec8fa05ac97275e" title="the client who is started in fullscreen mode on this workspace, NULL if there is...">fullscreen_client</a> = NULL;
<a name="l00157"></a>00157                         <a class="code" href="a00060.html#a9ec4f35452bd2af99fbc1e8cbf0917f4" title="Enters fullscreen mode for the given client.">client_enter_fullscreen</a>(conn, client, <span class="keyword">false</span>);
<a name="l00158"></a>00158                 }
<a name="l00159"></a>00159         }
<a name="l00160"></a>00160 
<a name="l00161"></a>00161         <span class="comment">/* Check if we need to change something or if we’re already there */</span>
<a name="l00162"></a>00162         <span class="keywordflow">if</span> (<a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>-&gt;<a class="code" href="a00026.html#a9bcf702b65d8f47f98eafbefff529ffe" title="Current workspace selected on this virtual screen.">current_workspace</a>-&gt;<a class="code" href="a00025.html#a7dfb9b375b2740db75bb82eb0b2be41d" title="Number of this workspace, starting from 0.">num</a> == (workspace-1)) {
<a name="l00163"></a>00163                 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *last_focused = <a class="code" href="a00047.html#a91bac7d0d32e3ec56bc579ace45ed8cd">SLIST_FIRST</a>(&amp;(<a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;focus_stack));
<a name="l00164"></a>00164                 <span class="keywordflow">if</span> (last_focused != <a class="code" href="a00047.html#a33283f951b262b1ac57d20c0e4e0862c">SLIST_END</a>(&amp;(<a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;focus_stack)))
<a name="l00165"></a>00165                         <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, last_focused, <span class="keyword">true</span>);
<a name="l00166"></a>00166                 <span class="keywordflow">if</span> (need_warp) {
<a name="l00167"></a>00167                         <a class="code" href="a00060.html#a4f8920c26884a6afe27211af25500135" title="Warps the pointer into the given client (in the middle of it, to be specific), therefore...">client_warp_pointer_into</a>(conn, last_focused);
<a name="l00168"></a>00168                         xcb_flush(conn);
<a name="l00169"></a>00169                 }
<a name="l00170"></a>00170 
<a name="l00171"></a>00171                 <a class="code" href="a00068.html#ad525c6fad9f4978ae1f06282ad9de6c6" title="Sends the specified event to all IPC clients which are currently connected and subscribed...">ipc_send_event</a>(<span class="stringliteral">&quot;workspace&quot;</span>, I3_IPC_EVENT_WORKSPACE, <span class="stringliteral">&quot;{\&quot;change\&quot;:\&quot;focus\&quot;}&quot;</span>);
<a name="l00172"></a>00172 
<a name="l00173"></a>00173                 <span class="keywordflow">return</span>;
<a name="l00174"></a>00174         }
<a name="l00175"></a>00175 
<a name="l00176"></a>00176         <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *old_workspace = <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>;
<a name="l00177"></a>00177         <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a> = t_ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>-&gt;<a class="code" href="a00026.html#a9bcf702b65d8f47f98eafbefff529ffe" title="Current workspace selected on this virtual screen.">current_workspace</a> = <a class="code" href="a00078.html#a73833335a85bfc97bdff285b151ab1c5" title="Returns a pointer to the workspace with the given number (starting at 0), creating...">workspace_get</a>(workspace-1);
<a name="l00178"></a>00178 
<a name="l00179"></a>00179         <span class="comment">/* Unmap all clients of the old workspace */</span>
<a name="l00180"></a>00180         <a class="code" href="a00078.html#a5994190a13e9afaf2fddb99e8ec1f25d" title="Unmaps all clients (and stack windows) of the given workspace.">workspace_unmap_clients</a>(conn, old_workspace);
<a name="l00181"></a>00181 
<a name="l00182"></a>00182         <a class="code" href="a00076.html#a40ba377d6a3a574ff03b859bc7cdd4b0">current_row</a> = <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#a86fefbdc838f2b5593ea2521378e4ddd" title="These are stored here only while this workspace is _not_ shown (see show_workspace())...">current_row</a>;
<a name="l00183"></a>00183         <a class="code" href="a00076.html#a5f839b3ac61c0771c9f8fbef974afe76">current_col</a> = <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;<a class="code" href="a00025.html#ab683091dfe46963b2dd0761e8e5f9e16" title="These are stored here only while this workspace is _not_ shown (see show_workspace())...">current_col</a>;
<a name="l00184"></a>00184         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;new current row = %d, current col = %d\n&quot;</span>, <a class="code" href="a00076.html#a40ba377d6a3a574ff03b859bc7cdd4b0">current_row</a>, <a class="code" href="a00076.html#a5f839b3ac61c0771c9f8fbef974afe76">current_col</a>);
<a name="l00185"></a>00185 
<a name="l00186"></a>00186         <a class="code" href="a00068.html#ad525c6fad9f4978ae1f06282ad9de6c6" title="Sends the specified event to all IPC clients which are currently connected and subscribed...">ipc_send_event</a>(<span class="stringliteral">&quot;workspace&quot;</span>, I3_IPC_EVENT_WORKSPACE, <span class="stringliteral">&quot;{\&quot;change\&quot;:\&quot;focus\&quot;}&quot;</span>);
<a name="l00187"></a>00187 
<a name="l00188"></a>00188         <a class="code" href="a00078.html#a88c6ab06ad8ce02a23811e2ee2d84285" title="Maps all clients (and stack windows) of the given workspace.">workspace_map_clients</a>(conn, <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>);
<a name="l00189"></a>00189 
<a name="l00190"></a>00190         <span class="comment">/* POTENTIAL TO IMPROVE HERE: due to the call to _map_clients first and</span>
<a name="l00191"></a>00191 <span class="comment">         * render_layout afterwards, there is a short flickering on the source</span>
<a name="l00192"></a>00192 <span class="comment">         * workspace (assign ws 3 to output 0, ws 4 to output 1, create single</span>
<a name="l00193"></a>00193 <span class="comment">         * client on ws 4, move it to ws 3, switch to ws 3, you’ll see the</span>
<a name="l00194"></a>00194 <span class="comment">         * flickering). */</span>
<a name="l00195"></a>00195 
<a name="l00196"></a>00196         <span class="comment">/* Restore focus on the new workspace */</span>
<a name="l00197"></a>00197         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *last_focused = <a class="code" href="a00047.html#a91bac7d0d32e3ec56bc579ace45ed8cd">SLIST_FIRST</a>(&amp;(<a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;focus_stack));
<a name="l00198"></a>00198         <span class="keywordflow">if</span> (last_focused != <a class="code" href="a00047.html#a33283f951b262b1ac57d20c0e4e0862c">SLIST_END</a>(&amp;(<a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;focus_stack)))
<a name="l00199"></a>00199                 <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, last_focused, <span class="keyword">true</span>);
<a name="l00200"></a>00200         <span class="keywordflow">else</span> xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME);
<a name="l00201"></a>00201 
<a name="l00202"></a>00202         <a class="code" href="a00069.html#a47ffef7db851301198762179187ac997" title="Renders the whole layout, that is: Go through each screen, each workspace, each container...">render_layout</a>(conn);
<a name="l00203"></a>00203 
<a name="l00204"></a>00204         <span class="comment">/* We can warp the pointer only after the window has been</span>
<a name="l00205"></a>00205 <span class="comment">         * reconfigured in render_layout, otherwise the pointer will</span>
<a name="l00206"></a>00206 <span class="comment">         * be warped to the old position, which will not work when we</span>
<a name="l00207"></a>00207 <span class="comment">         * moved it to another output. */</span>
<a name="l00208"></a>00208         <span class="keywordflow">if</span> (last_focused != <a class="code" href="a00047.html#a33283f951b262b1ac57d20c0e4e0862c">SLIST_END</a>(&amp;(<a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>-&gt;focus_stack)) &amp;&amp; need_warp) {
<a name="l00209"></a>00209                 <a class="code" href="a00060.html#a4f8920c26884a6afe27211af25500135" title="Warps the pointer into the given client (in the middle of it, to be specific), therefore...">client_warp_pointer_into</a>(conn, last_focused);
<a name="l00210"></a>00210                 xcb_flush(conn);
<a name="l00211"></a>00211         }
<a name="l00212"></a>00212 }
<a name="l00213"></a>00213 
<a name="l00214"></a>00214 <span class="comment">/*</span>
<a name="l00215"></a>00215 <span class="comment"> * Assigns the given workspace to the given output by correctly updating its</span>
<a name="l00216"></a>00216 <span class="comment"> * state and reconfiguring all the clients on this workspace.</span>
<a name="l00217"></a>00217 <span class="comment"> *</span>
<a name="l00218"></a>00218 <span class="comment"> * This is called when initializing a output and when re-assigning it to a</span>
<a name="l00219"></a>00219 <span class="comment"> * different output which just got available (if you configured it to be on</span>
<a name="l00220"></a>00220 <span class="comment"> * output 1 and you just plugged in output 1).</span>
<a name="l00221"></a>00221 <span class="comment"> *</span>
<a name="l00222"></a>00222 <span class="comment"> */</span>
<a name="l00223"></a><a class="code" href="a00053.html#a26c93a2dc53d98a66ed59f7152c42687">00223</a> <span class="keywordtype">void</span> <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>(<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="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output, <span class="keywordtype">bool</span> hide_it) {
<a name="l00224"></a>00224         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client;
<a name="l00225"></a>00225         <span class="keywordtype">bool</span> empty = <span class="keyword">true</span>;
<a name="l00226"></a>00226         <span class="keywordtype">bool</span> visible = <a class="code" href="a00078.html#a7a4e9d7994d904776ead4c8fc1b22091" title="Returns true if the workspace is currently visible.">workspace_is_visible</a>(ws);
<a name="l00227"></a>00227 
<a name="l00228"></a>00228         ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a> = output;
<a name="l00229"></a>00229 
<a name="l00230"></a>00230         <span class="comment">/* Copy the dimensions from the virtual output */</span>
<a name="l00231"></a>00231         memcpy(&amp;(ws-&gt;<a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>), &amp;(ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>-&gt;<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="l00232"></a>00232 
<a name="l00233"></a>00233         <a class="code" href="a00065.html#aefdaf6a17c2aa3979c49e3ff74cfee56" title="Updates the workarea for each desktop.">ewmh_update_workarea</a>();
<a name="l00234"></a>00234 
<a name="l00235"></a>00235         <span class="comment">/* Force reconfiguration for each client on that workspace */</span>
<a name="l00236"></a>00236         <a class="code" href="a00047.html#a05db87878125c27e3060dd641aa3b0f4">SLIST_FOREACH</a>(client, &amp;(ws-&gt;focus_stack), focus_clients) {
<a name="l00237"></a>00237                 client-&gt;<a class="code" href="a00007.html#a873c62703ab51afe96b38df2b30ffa66">force_reconfigure</a> = <span class="keyword">true</span>;
<a name="l00238"></a>00238                 empty = <span class="keyword">false</span>;
<a name="l00239"></a>00239         }
<a name="l00240"></a>00240 
<a name="l00241"></a>00241         <span class="keywordflow">if</span> (empty)
<a name="l00242"></a>00242                 <span class="keywordflow">return</span>;
<a name="l00243"></a>00243 
<a name="l00244"></a>00244         <span class="comment">/* Render the workspace to reconfigure the clients. However, they will be visible now, so… */</span>
<a name="l00245"></a>00245         <a class="code" href="a00069.html#ab3e248d886080e290648c0d791a40b64" title="Renders the given workspace on the given screen.">render_workspace</a>(<a class="code" href="a00071.html#ada13c42121d64521629e06e7a5e1db16">global_conn</a>, output, ws);
<a name="l00246"></a>00246 
<a name="l00247"></a>00247         <span class="comment">/* …unless we want to see them at the moment, we should hide that workspace */</span>
<a name="l00248"></a>00248         <span class="keywordflow">if</span> (visible &amp;&amp; !hide_it)
<a name="l00249"></a>00249                 <span class="keywordflow">return</span>;
<a name="l00250"></a>00250 
<a name="l00251"></a>00251         <span class="comment">/* however, if this is the current workspace, we only need to adjust</span>
<a name="l00252"></a>00252 <span class="comment">         * the output’s current_workspace pointer (and must not unmap the</span>
<a name="l00253"></a>00253 <span class="comment">         * windows) */</span>
<a name="l00254"></a>00254         <span class="keywordflow">if</span> (<a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a> == ws) {
<a name="l00255"></a>00255                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Need to adjust output-&gt;current_workspace...\n&quot;</span>);
<a name="l00256"></a>00256                 output-&gt;<a class="code" href="a00026.html#a9bcf702b65d8f47f98eafbefff529ffe" title="Current workspace selected on this virtual screen.">current_workspace</a> = <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>;
<a name="l00257"></a>00257                 <a class="code" href="a00068.html#ad525c6fad9f4978ae1f06282ad9de6c6" title="Sends the specified event to all IPC clients which are currently connected and subscribed...">ipc_send_event</a>(<span class="stringliteral">&quot;workspace&quot;</span>, I3_IPC_EVENT_WORKSPACE, <span class="stringliteral">&quot;{\&quot;change\&quot;:\&quot;focus\&quot;}&quot;</span>);
<a name="l00258"></a>00258                 <span class="keywordflow">return</span>;
<a name="l00259"></a>00259         }
<a name="l00260"></a>00260 
<a name="l00261"></a>00261         <a class="code" href="a00078.html#a5994190a13e9afaf2fddb99e8ec1f25d" title="Unmaps all clients (and stack windows) of the given workspace.">workspace_unmap_clients</a>(<a class="code" href="a00071.html#ada13c42121d64521629e06e7a5e1db16">global_conn</a>, ws);
<a name="l00262"></a>00262 }
<a name="l00263"></a>00263 
<a name="l00264"></a>00264 <span class="comment">/*</span>
<a name="l00265"></a>00265 <span class="comment"> * Initializes the given workspace if it is not already initialized. The given</span>
<a name="l00266"></a>00266 <span class="comment"> * screen is to be understood as a fallback, if the workspace itself either</span>
<a name="l00267"></a>00267 <span class="comment"> * was not assigned to a particular screen or cannot be placed there because</span>
<a name="l00268"></a>00268 <span class="comment"> * the screen is not attached at the moment.</span>
<a name="l00269"></a>00269 <span class="comment"> *</span>
<a name="l00270"></a>00270 <span class="comment"> */</span>
<a name="l00271"></a><a class="code" href="a00053.html#a9e156f4f9fbeb3d82db7a79ef23fd9e5">00271</a> <span class="keywordtype">void</span> <a class="code" href="a00078.html#a8339966acb1a826e826e9b20bfb754f6" title="Initializes the given workspace if it is not already initialized.">workspace_initialize</a>(<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="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output, <span class="keywordtype">bool</span> recheck) {
<a name="l00272"></a>00272         <a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *old_output;
<a name="l00273"></a>00273 
<a name="l00274"></a>00274         <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> != NULL &amp;&amp; !recheck) {
<a name="l00275"></a>00275                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Workspace already initialized\n&quot;</span>);
<a name="l00276"></a>00276                 <span class="keywordflow">return</span>;
<a name="l00277"></a>00277         }
<a name="l00278"></a>00278 
<a name="l00279"></a>00279         old_output = ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>;
<a name="l00280"></a>00280 
<a name="l00281"></a>00281         <span class="comment">/* If this workspace has no preferred output or if the output it wants</span>
<a name="l00282"></a>00282 <span class="comment">         * to be on is not available at the moment, we initialize it with</span>
<a name="l00283"></a>00283 <span class="comment">         * the output which was given */</span>
<a name="l00284"></a>00284         <span class="keywordflow">if</span> (ws-&gt;<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="l00285"></a>00285             (ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">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>(ws-&gt;<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="l00286"></a>00286                 ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a> = output;
<a name="l00287"></a>00287 
<a name="l00288"></a>00288         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;old_output = %p, ws-&gt;output = %p\n&quot;</span>, old_output, ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>);
<a name="l00289"></a>00289         <span class="comment">/* If the assignment did not change, we do not need to update anything */</span>
<a name="l00290"></a>00290         <span class="keywordflow">if</span> (old_output != NULL &amp;&amp; ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a> == old_output)
<a name="l00291"></a>00291                 <span class="keywordflow">return</span>;
<a name="l00292"></a>00292 
<a name="l00293"></a>00293         <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, ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>, <span class="keyword">false</span>);
<a name="l00294"></a>00294 }
<a name="l00295"></a>00295 
<a name="l00296"></a>00296 <span class="comment">/*</span>
<a name="l00297"></a>00297 <span class="comment"> * Gets the first unused workspace for the given screen, taking into account</span>
<a name="l00298"></a>00298 <span class="comment"> * the preferred_output setting of every workspace (workspace assignments).</span>
<a name="l00299"></a>00299 <span class="comment"> *</span>
<a name="l00300"></a>00300 <span class="comment"> */</span>
<a name="l00301"></a><a class="code" href="a00053.html#aefa772375bb2c4fed89fa205899ee826">00301</a> <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *<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>(<a class="code" href="a00026.html" title="An Output is a physical output on your graphics driver.">Output</a> *output) {
<a name="l00302"></a>00302         <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *result = NULL;
<a name="l00303"></a>00303 
<a name="l00304"></a>00304         <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws;
<a name="l00305"></a>00305         <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="l00306"></a>00306                 <span class="keywordflow">if</span> (ws-&gt;<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="l00307"></a>00307                     <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-&gt;<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="l00308"></a>00308                         <span class="keywordflow">continue</span>;
<a name="l00309"></a>00309 
<a name="l00310"></a>00310                 result = ws;
<a name="l00311"></a>00311                 <span class="keywordflow">break</span>;
<a name="l00312"></a>00312         }
<a name="l00313"></a>00313 
<a name="l00314"></a>00314         <span class="keywordflow">if</span> (result == NULL) {
<a name="l00315"></a>00315                 <span class="comment">/* No assignment found, returning first unused workspace */</span>
<a name="l00316"></a>00316                 <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="l00317"></a>00317                         <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> != NULL)
<a name="l00318"></a>00318                                 <span class="keywordflow">continue</span>;
<a name="l00319"></a>00319 
<a name="l00320"></a>00320                         result = ws;
<a name="l00321"></a>00321                         <span class="keywordflow">break</span>;
<a name="l00322"></a>00322                 }
<a name="l00323"></a>00323         }
<a name="l00324"></a>00324 
<a name="l00325"></a>00325         <span class="keywordflow">if</span> (result == NULL) {
<a name="l00326"></a>00326                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;No existing free workspace found to assign, creating a new one\n&quot;</span>);
<a name="l00327"></a>00327 
<a name="l00328"></a>00328                 <span class="keywordtype">int</span> last_ws = 0;
<a name="l00329"></a>00329                 <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="l00330"></a>00330                         last_ws = ws-&gt;<a class="code" href="a00025.html#a7dfb9b375b2740db75bb82eb0b2be41d" title="Number of this workspace, starting from 0.">num</a>;
<a name="l00331"></a>00331                 result = <a class="code" href="a00078.html#a73833335a85bfc97bdff285b151ab1c5" title="Returns a pointer to the workspace with the given number (starting at 0), creating...">workspace_get</a>(last_ws + 1);
<a name="l00332"></a>00332         }
<a name="l00333"></a>00333 
<a name="l00334"></a>00334         <a class="code" href="a00078.html#a8339966acb1a826e826e9b20bfb754f6" title="Initializes the given workspace if it is not already initialized.">workspace_initialize</a>(result, output, <span class="keyword">false</span>);
<a name="l00335"></a>00335         <span class="keywordflow">return</span> result;
<a name="l00336"></a>00336 }
<a name="l00337"></a>00337 
<a name="l00338"></a>00338 <span class="comment">/*</span>
<a name="l00339"></a>00339 <span class="comment"> * Maps all clients (and stack windows) of the given workspace.</span>
<a name="l00340"></a>00340 <span class="comment"> *</span>
<a name="l00341"></a>00341 <span class="comment"> */</span>
<a name="l00342"></a><a class="code" href="a00053.html#a88c6ab06ad8ce02a23811e2ee2d84285">00342</a> <span class="keywordtype">void</span> <a class="code" href="a00078.html#a88c6ab06ad8ce02a23811e2ee2d84285" title="Maps all clients (and stack windows) of the given workspace.">workspace_map_clients</a>(xcb_connection_t *conn, <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws) {
<a name="l00343"></a>00343         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client;
<a name="l00344"></a>00344 
<a name="l00345"></a>00345         <a class="code" href="a00069.html#a8a6aa6f7ea9bdaae274ff67183940dce" title="Modifies the event mask of all clients on the given workspace to either ignore or...">ignore_enter_notify_forall</a>(conn, ws, <span class="keyword">true</span>);
<a name="l00346"></a>00346 
<a name="l00347"></a>00347         <span class="comment">/* Map all clients on the new workspace */</span>
<a name="l00348"></a>00348         <a class="code" href="a00052.html#a7da994865329c8424d49403dec5fef5e">FOR_TABLE</a>(ws)
<a name="l00349"></a>00349                 <a class="code" href="a00047.html#ae97f4eb5724477c63699fafea4614b46">CIRCLEQ_FOREACH</a>(client, &amp;(ws-&gt;<a class="code" href="a00025.html#a26cf35518dcf31aa97deda261548e719" title="This is a two-dimensional dynamic array of Container-pointers.">table</a>[cols][rows]-&gt;clients), clients)
<a name="l00350"></a>00350                         <a class="code" href="a00060.html#a7f3612a4061bd46213d5e28f0c4d00ee" title="Map the client, correctly restoring any state needed.">client_map</a>(conn, client);
<a name="l00351"></a>00351 
<a name="l00352"></a>00352         <span class="comment">/* Map all floating clients */</span>
<a name="l00353"></a>00353         <span class="keywordflow">if</span> (!ws-&gt;<a class="code" href="a00025.html#a5efdecde018d10414e6f740573b2a9fb" title="Are the floating clients on this workspace currently hidden?">floating_hidden</a>)
<a name="l00354"></a>00354                 <a class="code" href="a00047.html#a16e5fc168e7f3494d4b1df54447d871e">TAILQ_FOREACH</a>(client, &amp;(ws-&gt;floating_clients), floating_clients)
<a name="l00355"></a>00355                         <a class="code" href="a00060.html#a7f3612a4061bd46213d5e28f0c4d00ee" title="Map the client, correctly restoring any state needed.">client_map</a>(conn, client);
<a name="l00356"></a>00356 
<a name="l00357"></a>00357         <span class="comment">/* Map all stack windows, if any */</span>
<a name="l00358"></a>00358         <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="l00359"></a>00359         <a class="code" href="a00047.html#a05db87878125c27e3060dd641aa3b0f4">SLIST_FOREACH</a>(stack_win, &amp;<a class="code" href="a00071.html#ac38e5cddf6395c52d3755d7b368e4a2b">stack_wins</a>, stack_windows)
<a name="l00360"></a>00360                 <span class="keywordflow">if</span> (stack_win-&gt;<a class="code" href="a00023.html#ad5f9402c2db288b0762e3a6467257dc8" title="Backpointer to the container this stack window is in.">container</a>-&gt;<a class="code" href="a00013.html#a98ed501e1088ccf2e7c75399ab7e6031">workspace</a> == ws &amp;&amp; stack_win-&gt;<a class="code" href="a00023.html#ac42bcee20d4f77f4ecbdec1dbb616a4f">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a> &gt; 0)
<a name="l00361"></a>00361                         xcb_map_window(conn, stack_win-&gt;<a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a>);
<a name="l00362"></a>00362 
<a name="l00363"></a>00363         <a class="code" href="a00069.html#a8a6aa6f7ea9bdaae274ff67183940dce" title="Modifies the event mask of all clients on the given workspace to either ignore or...">ignore_enter_notify_forall</a>(conn, ws, <span class="keyword">false</span>);
<a name="l00364"></a>00364 }
<a name="l00365"></a>00365 
<a name="l00366"></a>00366 <span class="comment">/*</span>
<a name="l00367"></a>00367 <span class="comment"> * Unmaps all clients (and stack windows) of the given workspace.</span>
<a name="l00368"></a>00368 <span class="comment"> *</span>
<a name="l00369"></a>00369 <span class="comment"> * This needs to be called separately when temporarily rendering</span>
<a name="l00370"></a>00370 <span class="comment"> * a workspace which is not the active workspace to force</span>
<a name="l00371"></a>00371 <span class="comment"> * reconfiguration of all clients, like in src/xinerama.c when</span>
<a name="l00372"></a>00372 <span class="comment"> * re-assigning a workspace to another screen.</span>
<a name="l00373"></a>00373 <span class="comment"> *</span>
<a name="l00374"></a>00374 <span class="comment"> */</span>
<a name="l00375"></a><a class="code" href="a00053.html#a5994190a13e9afaf2fddb99e8ec1f25d">00375</a> <span class="keywordtype">void</span> <a class="code" href="a00078.html#a5994190a13e9afaf2fddb99e8ec1f25d" title="Unmaps all clients (and stack windows) of the given workspace.">workspace_unmap_clients</a>(xcb_connection_t *conn, <a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *u_ws) {
<a name="l00376"></a>00376         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client;
<a name="l00377"></a>00377         <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="l00378"></a>00378 
<a name="l00379"></a>00379         <span class="comment">/* Ignore notify events because they would cause focus to be changed */</span>
<a name="l00380"></a>00380         <a class="code" href="a00069.html#a8a6aa6f7ea9bdaae274ff67183940dce" title="Modifies the event mask of all clients on the given workspace to either ignore or...">ignore_enter_notify_forall</a>(conn, u_ws, <span class="keyword">true</span>);
<a name="l00381"></a>00381 
<a name="l00382"></a>00382         <span class="comment">/* Unmap all clients of the given workspace */</span>
<a name="l00383"></a>00383         <span class="keywordtype">int</span> unmapped_clients = 0;
<a name="l00384"></a>00384         <a class="code" href="a00052.html#a7da994865329c8424d49403dec5fef5e">FOR_TABLE</a>(u_ws)
<a name="l00385"></a>00385                 <a class="code" href="a00047.html#ae97f4eb5724477c63699fafea4614b46">CIRCLEQ_FOREACH</a>(client, &amp;(u_ws-&gt;<a class="code" href="a00025.html#a26cf35518dcf31aa97deda261548e719" title="This is a two-dimensional dynamic array of Container-pointers.">table</a>[cols][rows]-&gt;clients), clients) {
<a name="l00386"></a>00386                         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;unmapping normal client %p / %p / %p\n&quot;</span>, client, client-&gt;<a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, client-&gt;<a class="code" href="a00007.html#afba312b946fa74727ce619a33f8f28aa" title="The client’s window.">child</a>);
<a name="l00387"></a>00387                         <a class="code" href="a00060.html#afe96e905cd2fcc23acf096304000f793" title="Unmap the client, correctly setting any state which is needed.">client_unmap</a>(conn, client);
<a name="l00388"></a>00388                         unmapped_clients++;
<a name="l00389"></a>00389                 }
<a name="l00390"></a>00390 
<a name="l00391"></a>00391         <span class="comment">/* To find floating clients, we traverse the focus stack */</span>
<a name="l00392"></a>00392         <a class="code" href="a00047.html#a05db87878125c27e3060dd641aa3b0f4">SLIST_FOREACH</a>(client, &amp;(u_ws-&gt;focus_stack), focus_clients) {
<a name="l00393"></a>00393                 <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="l00394"></a>00394                         <span class="keywordflow">continue</span>;
<a name="l00395"></a>00395 
<a name="l00396"></a>00396                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;unmapping floating client %p / %p / %p\n&quot;</span>, client, client-&gt;<a class="code" href="a00007.html#ae6bb442465a95e5794ed34936fa67bac" title="Our window: The frame around the client.">frame</a>, client-&gt;<a class="code" href="a00007.html#afba312b946fa74727ce619a33f8f28aa" title="The client’s window.">child</a>);
<a name="l00397"></a>00397 
<a name="l00398"></a>00398                 <a class="code" href="a00060.html#afe96e905cd2fcc23acf096304000f793" title="Unmap the client, correctly setting any state which is needed.">client_unmap</a>(conn, client);
<a name="l00399"></a>00399                 unmapped_clients++;
<a name="l00400"></a>00400         }
<a name="l00401"></a>00401 
<a name="l00402"></a>00402         <span class="comment">/* If we did not unmap any clients, the workspace is empty and we can destroy it, at least</span>
<a name="l00403"></a>00403 <span class="comment">         * if it is not the current workspace. */</span>
<a name="l00404"></a>00404         <span class="keywordflow">if</span> (unmapped_clients == 0 &amp;&amp; u_ws != <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>) {
<a name="l00405"></a>00405                 <span class="comment">/* Re-assign the workspace of all dock clients which use this workspace */</span>
<a name="l00406"></a>00406                 <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *dock;
<a name="l00407"></a>00407                 <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;workspace %p is empty\n&quot;</span>, u_ws);
<a name="l00408"></a>00408                 <a class="code" href="a00047.html#a05db87878125c27e3060dd641aa3b0f4">SLIST_FOREACH</a>(dock, &amp;(u_ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>-&gt;dock_clients), dock_clients) {
<a name="l00409"></a>00409                         <span class="keywordflow">if</span> (dock-&gt;<a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a> != u_ws)
<a name="l00410"></a>00410                                 <span class="keywordflow">continue</span>;
<a name="l00411"></a>00411 
<a name="l00412"></a>00412                         <a class="code" href="a00044.html#a287e239c800086178591f5e53f5bb82c">DLOG</a>(<span class="stringliteral">&quot;Re-assigning dock client to c_ws (%p)\n&quot;</span>, <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>);
<a name="l00413"></a>00413                         dock-&gt;<a class="code" href="a00007.html#ab9573ba898dbd1932f5200be5eb2a990" title="Because dock clients don’t have a container, we have this workspace-backpointer...">workspace</a> = <a class="code" href="a00076.html#a6dc99dff7063221c1096561951c0386b">c_ws</a>;
<a name="l00414"></a>00414                 }
<a name="l00415"></a>00415                 u_ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a> = NULL;
<a name="l00416"></a>00416         }
<a name="l00417"></a>00417 
<a name="l00418"></a>00418         <span class="comment">/* Unmap the stack windows on the given workspace, if any */</span>
<a name="l00419"></a>00419         <a class="code" href="a00047.html#a05db87878125c27e3060dd641aa3b0f4">SLIST_FOREACH</a>(stack_win, &amp;<a class="code" href="a00071.html#ac38e5cddf6395c52d3755d7b368e4a2b">stack_wins</a>, stack_windows)
<a name="l00420"></a>00420                 <span class="keywordflow">if</span> (stack_win-&gt;<a class="code" href="a00023.html#ad5f9402c2db288b0762e3a6467257dc8" title="Backpointer to the container this stack window is in.">container</a>-&gt;<a class="code" href="a00013.html#a98ed501e1088ccf2e7c75399ab7e6031">workspace</a> == u_ws)
<a name="l00421"></a>00421                         xcb_unmap_window(conn, stack_win-&gt;<a class="code" href="a00023.html#aa10861a9e5d4859d70275b462acfcd24">window</a>);
<a name="l00422"></a>00422 
<a name="l00423"></a>00423         <a class="code" href="a00069.html#a8a6aa6f7ea9bdaae274ff67183940dce" title="Modifies the event mask of all clients on the given workspace to either ignore or...">ignore_enter_notify_forall</a>(conn, u_ws, <span class="keyword">false</span>);
<a name="l00424"></a>00424 }
<a name="l00425"></a>00425 
<a name="l00426"></a>00426 <span class="comment">/*</span>
<a name="l00427"></a>00427 <span class="comment"> * Goes through all clients on the given workspace and updates the workspace’s</span>
<a name="l00428"></a>00428 <span class="comment"> * urgent flag accordingly.</span>
<a name="l00429"></a>00429 <span class="comment"> *</span>
<a name="l00430"></a>00430 <span class="comment"> */</span>
<a name="l00431"></a><a class="code" href="a00053.html#a2c43568cc3492bd24992d93f4552bbe9">00431</a> <span class="keywordtype">void</span> <a class="code" href="a00078.html#a2c43568cc3492bd24992d93f4552bbe9" title="Goes through all clients on the given workspace and updates the workspace’s urgent...">workspace_update_urgent_flag</a>(<a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws) {
<a name="l00432"></a>00432         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *current;
<a name="l00433"></a>00433         <span class="keywordtype">bool</span> old_flag = ws-&gt;<a class="code" href="a00025.html#ae43262c5fb60e7d7a93da1041835eeb2" title="True if any client on this workspace has its urgent flag set.">urgent</a>;
<a name="l00434"></a>00434         <span class="keywordtype">bool</span> urgent = <span class="keyword">false</span>;
<a name="l00435"></a>00435 
<a name="l00436"></a>00436         <a class="code" href="a00047.html#a05db87878125c27e3060dd641aa3b0f4">SLIST_FOREACH</a>(current, &amp;(ws-&gt;focus_stack), focus_clients) {
<a name="l00437"></a>00437                 <span class="keywordflow">if</span> (!current-&gt;<a class="code" href="a00007.html#ad169bd46b1c1edf6f7cddf2c0c5306c7" title="True if the client set the urgency flag in its WM_HINTS property.">urgent</a>)
<a name="l00438"></a>00438                         <span class="keywordflow">continue</span>;
<a name="l00439"></a>00439 
<a name="l00440"></a>00440                 urgent = <span class="keyword">true</span>;
<a name="l00441"></a>00441                 <span class="keywordflow">break</span>;
<a name="l00442"></a>00442         }
<a name="l00443"></a>00443 
<a name="l00444"></a>00444         ws-&gt;<a class="code" href="a00025.html#ae43262c5fb60e7d7a93da1041835eeb2" title="True if any client on this workspace has its urgent flag set.">urgent</a> = urgent;
<a name="l00445"></a>00445 
<a name="l00446"></a>00446         <span class="keywordflow">if</span> (old_flag != urgent)
<a name="l00447"></a>00447                 <a class="code" href="a00068.html#ad525c6fad9f4978ae1f06282ad9de6c6" title="Sends the specified event to all IPC clients which are currently connected and subscribed...">ipc_send_event</a>(<span class="stringliteral">&quot;workspace&quot;</span>, I3_IPC_EVENT_WORKSPACE, <span class="stringliteral">&quot;{\&quot;change\&quot;:\&quot;urgent\&quot;}&quot;</span>);
<a name="l00448"></a>00448 }
<a name="l00449"></a>00449 
<a name="l00450"></a>00450 <span class="comment">/*</span>
<a name="l00451"></a>00451 <span class="comment"> * Returns the width of the workspace.</span>
<a name="l00452"></a>00452 <span class="comment"> *</span>
<a name="l00453"></a>00453 <span class="comment"> */</span>
<a name="l00454"></a><a class="code" href="a00053.html#a56b20858f66e962aad2b914b9ab97f1b">00454</a> <span class="keywordtype">int</span> <a class="code" href="a00078.html#a56b20858f66e962aad2b914b9ab97f1b">workspace_width</a>(<a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws) {
<a name="l00455"></a>00455         <span class="keywordflow">return</span> ws-&gt;<a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#adb31dc42e48628c3e513c60296779ef8">width</a>;
<a name="l00456"></a>00456 }
<a name="l00457"></a>00457 
<a name="l00458"></a>00458 <span class="comment">/*</span>
<a name="l00459"></a>00459 <span class="comment"> * Returns the effective height of the workspace (without the internal bar and</span>
<a name="l00460"></a>00460 <span class="comment"> * without dock clients).</span>
<a name="l00461"></a>00461 <span class="comment"> *</span>
<a name="l00462"></a>00462 <span class="comment"> */</span>
<a name="l00463"></a><a class="code" href="a00053.html#af55407f9bc846ec57cf289c87a47dbce">00463</a> <span class="keywordtype">int</span> <a class="code" href="a00078.html#af55407f9bc846ec57cf289c87a47dbce">workspace_height</a>(<a class="code" href="a00025.html" title="The concept of Workspaces is known from various other window managers.">Workspace</a> *ws) {
<a name="l00464"></a>00464         <span class="keywordtype">int</span> height = ws-&gt;<a class="code" href="a00025.html#ac11bedb880b568b9c540fc9a376607ad" title="x, y, width, height">rect</a>.<a class="code" href="a00020.html#a0a074c07d144c9647e3eb60ef54f88c3">height</a>;
<a name="l00465"></a>00465         <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>(<a class="code" href="a00071.html#ada13c42121d64521629e06e7a5e1db16">global_conn</a>, <a class="code" href="a00062.html#a4a8dd3a2de125b72d4fe6251a0a271b5">config</a>.<a class="code" href="a00010.html#aff568f0d5ca7a51971f4c3006a842019">font</a>);
<a name="l00466"></a>00466 
<a name="l00467"></a>00467         <span class="comment">/* Reserve space for dock clients */</span>
<a name="l00468"></a>00468         <a class="code" href="a00007.html" title="A client is X11-speak for a window.">Client</a> *client;
<a name="l00469"></a>00469         <a class="code" href="a00047.html#a05db87878125c27e3060dd641aa3b0f4">SLIST_FOREACH</a>(client, &amp;(ws-&gt;<a class="code" href="a00025.html#aeee203e013dae84555d28f8247a7e375" title="Backpointer to the output this workspace is on.">output</a>-&gt;dock_clients), dock_clients)
<a name="l00470"></a>00470                 height -= client-&gt;<a class="code" href="a00007.html#a101bf3d37c729260e8a8e3ef808799de" title="Height which was determined by reading the _NET_WM_STRUT_PARTIAL top/bottom of the...">desired_height</a>;
<a name="l00471"></a>00471 
<a name="l00472"></a>00472         <span class="comment">/* Space for the internal bar */</span>
<a name="l00473"></a>00473         <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="l00474"></a>00474                 height -= (font-&gt;<a class="code" href="a00015.html#a89ceb86bb4ad2694315d846e69893399" title="The height of the font, built from font_ascent + font_descent.">height</a> + 6);
<a name="l00475"></a>00475 
<a name="l00476"></a>00476         <span class="keywordflow">return</span> height;
<a name="l00477"></a>00477 }
</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>