<div dir="ltr"><div>DirectFB: Add weston-dfb-adapter to integrate native</div><div> DirectFB clients into Wayland protocol</div><div><br></div><div>This component might be moved into Weston server process.</div><div><br></div>
<div>Actually, at the moment this adapter should work with non-Weston</div><div>compositors as well, as long as they are using the wayland-dfb</div><div>library which is part of DirectFB.</div><div>---</div><div> clients/Makefile.am            |   12 +</div>
<div> clients/dfb_test1.cpp          |  290 ++++++++++</div><div> clients/weston-dfb-adapter.cpp | 1220 ++++++++++++++++++++++++++++++++++++++++</div><div> 3 files changed, 1522 insertions(+)</div><div> create mode 100644 clients/dfb_test1.cpp</div>
<div> create mode 100644 clients/weston-dfb-adapter.cpp</div><div><br></div><div>diff --git a/clients/Makefile.am b/clients/Makefile.am</div><div>index 4f9dc48..edf8489 100644</div><div>--- a/clients/Makefile.am</div><div>
+++ b/clients/Makefile.am</div><div>@@ -1,5 +1,7 @@</div><div> bin_PROGRAMS =<span class="" style="white-space:pre">                                  </span>\</div><div> <span class="" style="white-space:pre"> </span>weston-info<span class="" style="white-space:pre">                               </span>\</div>
<div>+<span class="" style="white-space:pre">   </span>weston-dfb-adapter<span class="" style="white-space:pre">                        </span>\</div><div>+<span class="" style="white-space:pre"> </span>weston-dfb-test1<span class="" style="white-space:pre">                  </span>\</div>
<div> <span class="" style="white-space:pre">   </span>$(terminal)</div><div> </div><div> demo_clients = \</div><div>@@ -202,6 +204,16 @@ weston_info_SOURCES =<span class="" style="white-space:pre">                              </span>\</div><div> <span class="" style="white-space:pre"> </span>../shared/os-compatibility.h</div>
<div> weston_info_LDADD = $(WESTON_INFO_LIBS)</div><div> </div><div>+weston_dfb_test1_SOURCES =<span class="" style="white-space:pre">                          </span>\</div><div>+<span class="" style="white-space:pre"> </span>dfb_test1.cpp</div>
<div>+weston_dfb_test1_CXXFLAGS = $(DIRECTFB_COMPOSITOR_CFLAGS)</div><div>+weston_dfb_test1_LDADD = $(DIRECTFB_COMPOSITOR_LIBS) $(CLIENT_LIBS)</div><div>+</div><div>+weston_dfb_adapter_SOURCES =<span class="" style="white-space:pre">                           </span>\</div>
<div>+<span class="" style="white-space:pre">   </span>weston-dfb-adapter.cpp</div><div>+weston_dfb_adapter_CXXFLAGS = $(DIRECTFB_COMPOSITOR_CFLAGS)</div><div>+weston_dfb_adapter_LDADD = $(DIRECTFB_COMPOSITOR_LIBS) $(CLIENT_LIBS)</div>
<div>+</div><div> weston_desktop_shell_SOURCES =<span class="" style="white-space:pre">                     </span>\</div><div> <span class="" style="white-space:pre"> </span>desktop-shell.c<span class="" style="white-space:pre">                           </span>\</div>
<div> <span class="" style="white-space:pre">   </span>desktop-shell-client-protocol.h<span class="" style="white-space:pre">           </span>\</div><div>diff --git a/clients/dfb_test1.cpp b/clients/dfb_test1.cpp</div><div>new file mode 100644</div>
<div>index 0000000..cbbebb7</div><div>--- /dev/null</div><div>+++ b/clients/dfb_test1.cpp</div><div>@@ -0,0 +1,290 @@</div><div>+/*</div><div>+ * Copyright Â© 2008-2011 Kristian Høgsberg</div><div>+ * Copyright Â© 2011 Intel Corporation</div>
<div>+ * Copyright Â© 2012 Raspberry Pi Foundation</div><div>+ * Copyright Â© 2013 Philip Withnall</div><div>+ *</div><div>+ * Permission to use, copy, modify, distribute, and sell this software and</div><div>+ * its documentation for any purpose is hereby granted without fee, provided</div>
<div>+ * that the above copyright notice appear in all copies and that both that</div><div>+ * copyright notice and this permission notice appear in supporting</div><div>+ * documentation, and that the name of the copyright holders not be used in</div>
<div>+ * advertising or publicity pertaining to distribution of the software</div><div>+ * without specific, written prior permission.  The copyright holders make</div><div>+ * no representations about the suitability of this software for any</div>
<div>+ * purpose.  It is provided "as is" without express or implied warranty.</div><div>+ *</div><div>+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS</div><div>+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND</div>
<div>+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY</div><div>+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER</div><div>+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF</div>
<div>+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN</div><div>+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</div><div>+ */</div><div>+</div><div>+#include "config.h"</div>
<div>+</div><div>+#include <++dfb.h></div><div>+</div><div>+#include <++dfb_mangle.h></div><div>+#include <wayland-dfb.h></div><div>+#include <++dfb_unmangle.h></div><div>+</div><div>+#include <stdexcept></div>
<div>+</div><div>+#include <wayland-client.h></div><div>+</div><div>+#include <wayland-dfb-client-protocol.h></div><div>+</div><div>+</div><div>+extern "C" {</div><div>+#include <errno.h></div>
<div>+#include <stdlib.h></div><div>+#include <stdio.h></div><div>+#include <string.h></div><div>+#include <math.h></div><div>+#include <sys/mman.h></div><div>+#include <sys/types.h></div>
<div>+#include <fcntl.h></div><div>+#include <unistd.h></div><div>+}</div><div>+</div><div>+</div><div>+D_DEBUG_DOMAIN( Weston_DFBTest1, "Weston/DFBTest1", "Weston DFBTest1" );</div><div>+</div>
<div>+/**********************************************************************************************************************/</div><div>+</div><div>+class DFBTest1 {</div><div>+public:</div><div>+<span class="" style="white-space:pre">    </span>struct wl_display       *display;</div>
<div>+<span class="" style="white-space:pre">   </span>struct wl_registry      *registry;</div><div>+<span class="" style="white-space:pre">        </span>struct wl_compositor    *compositor;</div><div>+<span class="" style="white-space:pre">      </span>struct wl_shell         *shell;</div>
<div>+<span class="" style="white-space:pre">   </span>struct wl_dfb           *wl_dfb;</div><div>+<span class="" style="white-space:pre">  </span>struct wl_dfb_buffer    *buffer;</div><div>+<span class="" style="white-space:pre">  </span>struct wl_surface       *wl_surface;</div>
<div>+<span class="" style="white-space:pre">   </span>struct wl_shell_surface *shell_surface;</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>IDirectFB                dfb;</div><div>+<span class="" style="white-space:pre">     </span>IDirectFBDisplayLayer    layer;</div>
<div>+<span class="" style="white-space:pre">   </span>IDirectFBWindow          window;</div><div>+<span class="" style="white-space:pre">  </span>IDirectFBSurface         surface;</div><div>+<span class="" style="white-space:pre"> </span>DFBSurfaceID             surface_id;</div>
<div>+<span class="" style="white-space:pre">   </span>int                      width, height;</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>DFBTest1()</div><div>+<span class="" style="white-space:pre">                </span>:</div>
<div>+<span class="" style="white-space:pre">           </span>configured( false ),</div><div>+<span class="" style="white-space:pre">              </span>fullscreen( false )</div><div>+<span class="" style="white-space:pre">       </span>{</div><div>
+<span class="" style="white-space:pre">      </span>}</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>~DFBTest1()</div><div>+<span class="" style="white-space:pre">       </span>{</div><div>+<span class="" style="white-space:pre"> </span>}</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>void init();</div><div>+<span class="" style="white-space:pre">      </span>void redraw();</div><div>+<span class="" style="white-space:pre">    </span>void run();</div>
<div>+<span class="" style="white-space:pre">   </span>void toggle_fullscreen( bool fullscreen );</div><div>+</div><div>+<span class="" style="white-space:pre">        </span>bool configured;</div><div>+<span class="" style="white-space:pre">  </span>bool fullscreen;</div>
<div>+};</div><div>+</div><div>+/**********************************************************************************************************************/</div><div>+</div><div>+static void</div><div>+registry_handle_global(void *data, struct wl_registry *registry,</div>
<div>+<span class="" style="white-space:pre">           </span>       uint32_t name, const char *interface, uint32_t version)</div><div>+{</div><div>+<span class="" style="white-space:pre">   </span>DFBTest1 *test = (DFBTest1*) data;</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>D_DEBUG_AT( Weston_DFBTest1, "WindowAdapter::%s( %p, %s )\n", __FUNCTION__, test, interface );</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>if (strcmp(interface, "wl_compositor") == 0) {</div>
<div>+<span class="" style="white-space:pre">           </span>test->compositor = (wl_compositor*)wl_registry_bind( registry, name, &wl_compositor_interface, 1 );</div><div>+<span class="" style="white-space:pre">                </span>D_ASSERT( test->compositor != NULL );</div>
<div>+<span class="" style="white-space:pre">   </span>} else if (strcmp(interface, "wl_shell") == 0) {</div><div>+<span class="" style="white-space:pre">                </span>test->shell = (wl_shell*)wl_registry_bind( registry, name, &wl_shell_interface, 1 );</div>
<div>+<span class="" style="white-space:pre">           </span>D_ASSERT( test->shell != NULL );</div><div>+<span class="" style="white-space:pre">       </span>} else if (strcmp(interface, "wl_dfb") == 0) {</div><div>+<span class="" style="white-space:pre">          </span>test->wl_dfb = (wl_dfb*)wl_registry_bind( registry, name, &wl_dfb_interface, 1 );</div>
<div>+<span class="" style="white-space:pre">           </span>D_ASSERT( test->wl_dfb != NULL );</div><div>+<span class="" style="white-space:pre">      </span>}</div><div>+}</div><div>+</div><div>+static void</div><div>+registry_handle_global_remove(void *data, struct wl_registry *registry,</div>
<div>+<span class="" style="white-space:pre">                   </span>      uint32_t name)</div><div>+{</div><div>+}</div><div>+</div><div>+static const struct wl_registry_listener registry_listener = {</div><div>+<span class="" style="white-space:pre">      </span>registry_handle_global,</div>
<div>+<span class="" style="white-space:pre">   </span>registry_handle_global_remove</div><div>+};</div><div>+</div><div>+/**********************************************************************************************************************/</div>
<div>+</div><div>+static void</div><div>+handle_ping(void *data, struct wl_shell_surface *shell_surface,</div><div>+<span class="" style="white-space:pre"> </span>    uint32_t serial)</div><div>+{</div><div>+<span class="" style="white-space:pre">     </span>D_DEBUG_AT( Weston_DFBTest1, "%s( %p, shell_surface %p, serial %u )\n", __FUNCTION__, data, shell_surface, serial );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>wl_shell_surface_pong(shell_surface, serial);</div><div>+}</div><div>+</div><div>+static void</div><div>+handle_configure(void *data, struct wl_shell_surface *shell_surface,</div>
<div>+<span class="" style="white-space:pre">           </span> uint32_t edges, int32_t width, int32_t height)</div><div>+{</div><div>+<span class="" style="white-space:pre">  </span>D_DEBUG_AT( Weston_DFBTest1, "%s( %p, shell_surface %p, edges 0x%04x, width %d, height %d )\n",</div>
<div>+<span class="" style="white-space:pre">           </span>    __FUNCTION__, data, shell_surface, edges, width, height );</div><div>+}</div><div>+</div><div>+static void</div><div>+handle_popup_done(void *data, struct wl_shell_surface *shell_surface)</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>D_DEBUG_AT( Weston_DFBTest1, "%s( %p, shell_surface %p )\n", __FUNCTION__, data, shell_surface );</div><div>+}</div><div>+</div><div>+static const struct wl_shell_surface_listener shell_surface_listener = {</div>
<div>+<span class="" style="white-space:pre">   </span>handle_ping,</div><div>+<span class="" style="white-space:pre">      </span>handle_configure,</div><div>+<span class="" style="white-space:pre"> </span>handle_popup_done</div>
<div>+};</div><div>+</div><div>+/**********************************************************************************************************************/</div><div>+</div><div>+static void</div><div>+configure_callback(void *data, struct wl_callback *callback, uint32_t  time)</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>DFBTest1 *test = (DFBTest1*) data;</div><div>+</div><div>+<span class="" style="white-space:pre">        </span>D_DEBUG_AT( Weston_DFBTest1, "%s( %p, callback %p )\n", __FUNCTION__, data, callback );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>wl_callback_destroy( callback );</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>test->configured = 1;</div><div>+</div><div>+//<span class="" style="white-space:pre">        </span>if (test->callback == NULL)</div>
<div>+<span class="" style="white-space:pre">   </span>test->redraw();</div><div>+}</div><div>+</div><div>+static struct wl_callback_listener configure_callback_listener = {</div><div>+<span class="" style="white-space:pre">     </span>configure_callback,</div>
<div>+};</div><div>+</div><div>+/**********************************************************************************************************************/</div><div>+</div><div>+void</div><div>+DFBTest1::init()</div><div>+{</div>
<div>+<span class="" style="white-space:pre">   </span>D_DEBUG_AT( Weston_DFBTest1, "DFBTest1::%s( %p )\n", __FUNCTION__, this );</div><div>+</div><div>+<span class="" style="white-space:pre">      </span>display = wl_display_connect( NULL );</div>
<div>+<span class="" style="white-space:pre">   </span>if (!display)</div><div>+<span class="" style="white-space:pre">             </span>throw std::runtime_error( "wl_display_connect_to_fd failed" );</div><div>+</div><div>
+<span class="" style="white-space:pre">      </span>registry = wl_display_get_registry( display );</div><div>+</div><div>+<span class="" style="white-space:pre">    </span>wl_registry_add_listener( registry, &registry_listener, this );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>wl_display_dispatch( display );</div><div>+</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>wl_surface    = wl_compositor_create_surface( compositor );</div>
<div>+<span class="" style="white-space:pre">   </span>shell_surface = wl_shell_get_shell_surface( shell, wl_surface );</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>wl_shell_surface_add_listener( shell_surface, &shell_surface_listener, this );</div>
<div>+</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>wl_shell_surface_set_title( shell_surface, "DFB Test" );</div><div>+</div><div>+<span class="" style="white-space:pre">        </span>toggle_fullscreen( false );</div>
<div>+</div><div>+</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>dfb     = DirectFB::Create();</div><div>+<span class="" style="white-space:pre">     </span>layer   = dfb.GetDisplayLayer( DLID_PRIMARY );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>DFBWindowDescription desc;</div><div>+</div><div>+<span class="" style="white-space:pre">        </span>desc.flags  = (DFBWindowDescriptionFlags)(DWDESC_WIDTH | DWDESC_HEIGHT);</div>
<div>+<span class="" style="white-space:pre">   </span>desc.width  = 300;</div><div>+<span class="" style="white-space:pre">        </span>desc.height = 300;</div><div>+</div><div>+<span class="" style="white-space:pre">        </span>window  = layer.CreateWindow( desc );</div>
<div>+<span class="" style="white-space:pre">   </span>surface = window.GetSurface();</div><div>+</div><div>+<span class="" style="white-space:pre">    </span>surface.AllowAccess( "*" );</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>surface_id = surface.GetID();</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>surface.GetSize( &width, &height );</div><div>+}</div><div>+</div><div>+void</div><div>+DFBTest1::redraw()</div><div>+{</div><div>+<span class="" style="white-space:pre">       </span>D_DEBUG_AT( Weston_DFBTest1, "DFBTest1::%s( %p )\n", __FUNCTION__, this );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>buffer = wl_dfb_create_buffer( wl_dfb, surface_id, 0, 0 );</div><div>+</div><div>+<span class="" style="white-space:pre">        </span>wl_surface_attach( wl_surface, (struct wl_buffer*) buffer, 0, 0 );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>wl_surface_damage( wl_surface, 0, 0, width, height );</div><div>+<span class="" style="white-space:pre">     </span>wl_surface_commit( wl_surface );</div><div>+}</div>
<div>+</div><div>+void</div><div>+DFBTest1::run()</div><div>+{</div><div>+<span class="" style="white-space:pre">       </span>D_DEBUG_AT( Weston_DFBTest1, "DFBTest1::%s( %p )\n", __FUNCTION__, this );</div><div>+</div>
<div>+<span class="" style="white-space:pre">   </span>while (true) {</div><div>+<span class="" style="white-space:pre">            </span>wl_display_dispatch( display );</div><div>+<span class="" style="white-space:pre">   </span>}</div>
<div>+}</div><div>+</div><div>+void</div><div>+DFBTest1::toggle_fullscreen( bool fullscreen )</div><div>+{</div><div>+<span class="" style="white-space:pre">       </span>struct wl_callback *callback;</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>this->fullscreen = fullscreen;</div>
<div>+<span class="" style="white-space:pre">   </span>this->configured = false;</div><div>+</div><div>+<span class="" style="white-space:pre">      </span>if (fullscreen) {</div><div>+<span class="" style="white-space:pre">         </span>wl_shell_surface_set_fullscreen( shell_surface,</div>
<div>+<span class="" style="white-space:pre">                                           </span> WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,</div><div>+<span class="" style="white-space:pre">                                              </span> 0, NULL );</div><div>+<span class="" style="white-space:pre">       </span>} else {</div>
<div>+<span class="" style="white-space:pre">           </span>wl_shell_surface_set_toplevel( shell_surface );</div><div>+</div><div>+<span class="" style="white-space:pre">           </span>handle_configure( this, shell_surface, 0, width, height );</div>
<div>+<span class="" style="white-space:pre">   </span>}</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>callback = wl_display_sync( display );</div><div>+</div><div>+<span class="" style="white-space:pre">    </span>wl_callback_add_listener( callback, &configure_callback_listener, this );</div>
<div>+}</div><div>+</div><div>+/**********************************************************************************************************************/</div><div>+</div><div>+int</div><div>+main( int argc, char *argv[] )</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>DFBTest1 test1;</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>DirectFB::Init( &argc, &argv );</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>test1.init();</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>test1.run();</div><div>+</div><div>+<span class="" style="white-space:pre">      </span>return 0;</div><div>+}</div><div>diff --git a/clients/weston-dfb-adapter.cpp b/clients/weston-dfb-adapter.cpp</div>
<div>new file mode 100644</div><div>index 0000000..a21fa38</div><div>--- /dev/null</div><div>+++ b/clients/weston-dfb-adapter.cpp</div><div>@@ -0,0 +1,1220 @@</div><div>+/*</div><div>+ * Copyright Â© 2008-2011 Kristian Høgsberg</div>
<div>+ * Copyright Â© 2011 Intel Corporation</div><div>+ * Copyright Â© 2012 Raspberry Pi Foundation</div><div>+ * Copyright Â© 2013 Philip Withnall</div><div>+ *</div><div>+ * Permission to use, copy, modify, distribute, and sell this software and</div>
<div>+ * its documentation for any purpose is hereby granted without fee, provided</div><div>+ * that the above copyright notice appear in all copies and that both that</div><div>+ * copyright notice and this permission notice appear in supporting</div>
<div>+ * documentation, and that the name of the copyright holders not be used in</div><div>+ * advertising or publicity pertaining to distribution of the software</div><div>+ * without specific, written prior permission.  The copyright holders make</div>
<div>+ * no representations about the suitability of this software for any</div><div>+ * purpose.  It is provided "as is" without express or implied warranty.</div><div>+ *</div><div>+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS</div>
<div>+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND</div><div>+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY</div><div>+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER</div>
<div>+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF</div><div>+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN</div><div>+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</div>
<div>+ */</div><div>+</div><div>+#include "config.h"</div><div>+</div><div>+#include <++dfb.h></div><div>+</div><div>+#include <++dfb_mangle.h></div><div>+#include <wayland-dfb.h></div><div>+#include <++dfb_unmangle.h></div>
<div>+</div><div>+#include <stdexcept></div><div>+</div><div>+#include <wayland-client.h></div><div>+</div><div>+#include <wayland-dfb-client-protocol.h></div><div>+</div><div>+</div><div>+#include <directfb_windows.h></div>
<div>+</div><div>+extern "C" {</div><div>+#include <errno.h></div><div>+#include <stdlib.h></div><div>+#include <stdio.h></div><div>+#include <string.h></div><div>+#include <math.h></div>
<div>+#include <sys/poll.h></div><div>+#include <sys/mman.h></div><div>+#include <sys/types.h></div><div>+#include <fcntl.h></div><div>+#include <unistd.h></div><div>+#include <linux/input.h></div>
<div>+}</div><div>+</div><div>+</div><div>+</div><div>+D_DEBUG_DOMAIN( DFBWayland_Adapter, "DFBWayland/Adapter", "DirectFB Wayland Adapter" );</div><div>+</div><div>+/**********************************************************************************************************************/</div>
<div>+</div><div>+class Adapter;</div><div>+</div><div>+/**********************************************************************************************************************/</div><div>+</div><div>+class Client {</div><div>
+public:</div><div>+<span class="" style="white-space:pre">       </span>Adapter                 &adapter;</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>struct wl_display       *display;</div><div>+<span class="" style="white-space:pre"> </span>struct wl_registry      *registry;</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>struct wl_compositor    *compositor;</div><div>+<span class="" style="white-space:pre">      </span>struct wl_shell         *shell;</div><div>+<span class="" style="white-space:pre">   </span>struct wl_seat          *seat;</div>
<div>+<span class="" style="white-space:pre">   </span>struct wl_pointer       *pointer;</div><div>+<span class="" style="white-space:pre"> </span>struct wl_keyboard      *keyboard;</div><div>+<span class="" style="white-space:pre">        </span>struct wl_touch         *touch;</div>
<div>+<span class="" style="white-space:pre">   </span>struct wl_dfb           *wl_dfb;</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>Client( Adapter &adapter )</div><div>+<span class="" style="white-space:pre">    </span>:</div>
<div>+<span class="" style="white-space:pre">   </span>adapter( adapter ),</div><div>+<span class="" style="white-space:pre">       </span>display( NULL ),</div><div>+<span class="" style="white-space:pre">  </span>registry( NULL ),</div>
<div>+<span class="" style="white-space:pre">   </span>compositor( NULL ),</div><div>+<span class="" style="white-space:pre">       </span>shell( NULL ),</div><div>+<span class="" style="white-space:pre">    </span>seat( NULL ),</div>
<div>+<span class="" style="white-space:pre">   </span>pointer( NULL ),</div><div>+<span class="" style="white-space:pre">  </span>keyboard( NULL ),</div><div>+<span class="" style="white-space:pre"> </span>touch( NULL ),</div>
<div>+<span class="" style="white-space:pre">   </span>wl_dfb( NULL )</div><div>+<span class="" style="white-space:pre">    </span>{</div><div>+<span class="" style="white-space:pre"> </span>}</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>~Client()</div>
<div>+<span class="" style="white-space:pre">   </span>{</div><div>+<span class="" style="white-space:pre"> </span>}</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>void init();</div><div>+<span class="" style="white-space:pre">      </span>void run();</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>void check();</div><div>+};</div><div>+</div><div>+/**********************************************************************************************************************/</div>
<div>+</div><div>+class DFBWindow {</div><div>+public:</div><div>+<span class="" style="white-space:pre">   </span>Adapter                 &adapter;</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>IDirectFBWindow          window;</div>
<div>+<span class="" style="white-space:pre">   </span>IDirectFBSurface         surface;</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>DFBWindowID              window_id;</div><div>+<span class="" style="white-space:pre">       </span>DFBSurfaceID             surface_id;</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>struct wl_dfb_buffer    *buffer;</div><div>+<span class="" style="white-space:pre">  </span>struct wl_surface       *wl_surface;</div><div>+<span class="" style="white-space:pre">      </span>struct wl_shell_surface *shell_surface;</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>int                      width;</div><div>+<span class="" style="white-space:pre">   </span>int                      height;</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>u32                      wl_surface_id;</div>
<div>+</div><div>+</div><div>+public:</div><div>+<span class="" style="white-space:pre">    </span>DFBWindow( Adapter     &adapter,</div><div>+<span class="" style="white-space:pre">              </span>   DFBWindowID  window_id );</div>
<div>+<span class="" style="white-space:pre">   </span>~DFBWindow();</div><div>+</div><div>+private:</div><div>+public:</div><div>+<span class="" style="white-space:pre">      </span>void integrate();</div><div>+</div><div>+</div>
<div>+<span class="" style="white-space:pre">   </span>void HandleSurfaceEvent( const DFBSurfaceEvent &event );</div><div>+</div><div>+<span class="" style="white-space:pre">      </span>void toggle_fullscreen( bool fullscreen );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>bool configured;</div><div>+<span class="" style="white-space:pre">  </span>bool fullscreen;</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>void push_buffer( u32 flip_count );</div>
<div>+</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>void dispatchEnter( int x, int y );</div><div>+<span class="" style="white-space:pre">       </span>void dispatchLeave();</div><div>+<span class="" style="white-space:pre">     </span>void dispatchMotion( int x, int y );</div>
<div>+<span class="" style="white-space:pre">   </span>void dispatchButton( DFBInputDeviceButtonIdentifier button,</div><div>+<span class="" style="white-space:pre">                       </span>     bool                           pressed );</div>
<div>+<span class="" style="white-space:pre">   </span>void dispatchWheel( int v );</div><div>+</div><div>+<span class="" style="white-space:pre">      </span>void dispatchKey( int                   key_code,</div><div>+<span class="" style="white-space:pre">                 </span>  bool                  pressed );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>int                      pointer_x;</div><div>+<span class="" style="white-space:pre">       </span>int                      pointer_y;</div><div>+};</div><div>+</div>
<div>+/**********************************************************************************************************************/</div><div>+</div><div>+class Adapter {</div><div>+public:</div><div>+<span class="" style="white-space:pre">     </span>IDirectFB                dfb;</div>
<div>+<span class="" style="white-space:pre">   </span>IDirectFBEventBuffer     events;</div><div>+<span class="" style="white-space:pre">  </span>IDirectFBDisplayLayer    layer;</div><div>+<span class="" style="white-space:pre">   </span>IDirectFBWindows        *dfb_windows;</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>Client                   client;</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>std::map<DFBWindowID,std::shared_ptr<DFBWindow> >  windows;</div>
<div>+<span class="" style="white-space:pre">   </span>std::map<DFBSurfaceID,std::shared_ptr<DFBWindow> > surfaces;</div><div>+<span class="" style="white-space:pre">  </span>std::map<u32,std::shared_ptr<DFBWindow> >          wl_surfaces;</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>std::shared_ptr<DFBWindow>                         pointer_focus;</div><div>+<span class="" style="white-space:pre">   </span>std::shared_ptr<DFBWindow>                         keyboard_focus;</div>
<div>+</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>Adapter();</div><div>+<span class="" style="white-space:pre">        </span>~Adapter();</div><div>+</div><div>+<span class="" style="white-space:pre">       </span>void init();</div>
<div>+<span class="" style="white-space:pre">   </span>void run();</div><div>+<span class="" style="white-space:pre">       </span>void shutdown();</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>void AddWindow( DFBWindowID window_id );</div>
<div>+<span class="" style="white-space:pre">   </span>void RemoveWindow( DFBWindowID window_id );</div><div>+</div><div>+<span class="" style="white-space:pre">       </span>void HandleWindowEvent( const DFBWindowEvent &event );</div>
<div>+<span class="" style="white-space:pre">   </span>void HandleSurfaceEvent( const DFBSurfaceEvent &event );</div><div>+</div><div>+</div><div>+<span class="" style="white-space:pre">      </span>/*</div><div>+<span class="" style="white-space:pre">        </span> * Pointer</div>
<div>+<span class="" style="white-space:pre">   </span> */</div><div>+<span class="" style="white-space:pre">       </span>void handleEnter( struct wl_pointer *pointer,</div><div>+<span class="" style="white-space:pre">                     </span>  struct wl_surface *surface,</div>
<div>+<span class="" style="white-space:pre">                   </span>  wl_fixed_t         sx_w,</div><div>+<span class="" style="white-space:pre">                        </span>  wl_fixed_t         sy_w );</div><div>+</div><div>+<span class="" style="white-space:pre">      </span>void handleLeave( struct wl_pointer *pointer,</div>
<div>+<span class="" style="white-space:pre">                   </span>  struct wl_surface *surface );</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>void handleMotion( struct wl_pointer *pointer,</div><div>+<span class="" style="white-space:pre">                    </span>   wl_fixed_t         sx_w,</div>
<div>+<span class="" style="white-space:pre">                   </span>   wl_fixed_t         sy_w );</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>void handleButton( struct wl_pointer *pointer,</div><div>+<span class="" style="white-space:pre">                    </span>   uint32_t           button,</div>
<div>+<span class="" style="white-space:pre">                   </span>   uint32_t           state_w );</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>void handleAxis( struct wl_pointer *pointer,</div><div>+<span class="" style="white-space:pre">                      </span> uint32_t           axis,</div>
<div>+<span class="" style="white-space:pre">                   </span> wl_fixed_t         value );</div><div>+</div><div>+</div><div>+<span class="" style="white-space:pre">      </span>/*</div><div>+<span class="" style="white-space:pre">        </span> * Keyboard</div>
<div>+<span class="" style="white-space:pre">   </span> */</div><div>+<span class="" style="white-space:pre">       </span>void handleEnter( struct wl_keyboard *keyboard,</div><div>+<span class="" style="white-space:pre">                   </span>  struct wl_surface  *surface );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>void handleLeave( struct wl_keyboard *keyboard,</div><div>+<span class="" style="white-space:pre">                   </span>  struct wl_surface  *surface );</div><div>+</div>
<div>+<span class="" style="white-space:pre">   </span>void handleKey  ( struct wl_keyboard *keyboard,</div><div>+<span class="" style="white-space:pre">                   </span>  uint32_t            key,</div><div>+<span class="" style="white-space:pre">                        </span>  uint32_t            state_w );</div>
<div>+</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>DFBWindowsWatcher watcher;</div><div>+</div><div>+<span class="" style="white-space:pre">        </span>void Watcher_WindowAdd( const DFBWindowInfo *info );</div>
<div>+<span class="" style="white-space:pre">   </span>void Watcher_WindowRemove( DFBWindowID  window_id );</div><div>+<span class="" style="white-space:pre">      </span>void Watcher_WindowConfig( DFBWindowID            window_id,</div>
<div>+<span class="" style="white-space:pre">                           </span>   const DFBWindowConfig *config,</div><div>+<span class="" style="white-space:pre">                         </span>   DFBWindowConfigFlags   flags );</div><div>+<span class="" style="white-space:pre">        </span>void Watcher_WindowState( DFBWindowID           window_id,</div>
<div>+<span class="" style="white-space:pre">                           </span>  const DFBWindowState *state );</div><div>+<span class="" style="white-space:pre">  </span>void Watcher_WindowRestack( DFBWindowID   window_id,</div><div>+<span class="" style="white-space:pre">                              </span>    unsigned int  index );</div>
<div>+<span class="" style="white-space:pre">   </span>void Watcher_WindowFocus( DFBWindowID  window_id );</div><div>+};</div><div>+</div><div>+/**********************************************************************************************************************/</div>
<div>+/**********************************************************************************************************************/</div><div>+</div><div>+static void</div><div>+registry_handle_global(void *data, struct wl_registry *registry,</div>
<div>+<span class="" style="white-space:pre">           </span>       uint32_t name, const char *interface, uint32_t version)</div><div>+{</div><div>+<span class="" style="white-space:pre">   </span>Client *client = (Client*) data;</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, %s )\n", __FUNCTION__, client, interface );</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>if (strcmp(interface, "wl_compositor") == 0) {</div>
<div>+<span class="" style="white-space:pre">           </span>client->compositor = (wl_compositor*)wl_registry_bind( registry, name, &wl_compositor_interface, 1 );</div><div>+<span class="" style="white-space:pre">              </span>D_ASSERT( client->compositor != NULL );</div>
<div>+<span class="" style="white-space:pre">   </span>} else if (strcmp(interface, "wl_seat") == 0) {</div><div>+<span class="" style="white-space:pre">         </span>client->seat = (wl_seat*)wl_registry_bind( registry, name, &wl_seat_interface, 1 );</div>
<div>+<span class="" style="white-space:pre">           </span>D_ASSERT( client->shell != NULL );</div><div>+<span class="" style="white-space:pre">     </span>} else if (strcmp(interface, "wl_shell") == 0) {</div><div>+<span class="" style="white-space:pre">                </span>client->shell = (wl_shell*)wl_registry_bind( registry, name, &wl_shell_interface, 1 );</div>
<div>+<span class="" style="white-space:pre">           </span>D_ASSERT( client->shell != NULL );</div><div>+<span class="" style="white-space:pre">     </span>} else if (strcmp(interface, "wl_dfb") == 0) {</div><div>+<span class="" style="white-space:pre">          </span>client->wl_dfb = (wl_dfb*)wl_registry_bind( registry, name, &wl_dfb_interface, 1 );</div>
<div>+<span class="" style="white-space:pre">           </span>D_ASSERT( client->wl_dfb != NULL );</div><div>+<span class="" style="white-space:pre">    </span>}</div><div>+}</div><div>+</div><div>+static void</div><div>+registry_handle_global_remove(void *data, struct wl_registry *registry,</div>
<div>+<span class="" style="white-space:pre">                   </span>      uint32_t name)</div><div>+{</div><div>+}</div><div>+</div><div>+static const struct wl_registry_listener registry_listener = {</div><div>+<span class="" style="white-space:pre">      </span>registry_handle_global,</div>
<div>+<span class="" style="white-space:pre">   </span>registry_handle_global_remove</div><div>+};</div><div>+</div><div>+/**********************************************************************************************************************/</div>
<div>+/**********************************************************************************************************************/</div><div>+</div><div>+static void</div><div>+pointer_handle_enter(void *data, struct wl_pointer *pointer,</div>
<div>+<span class="" style="white-space:pre">           </span>     uint32_t serial, struct wl_surface *surface,</div><div>+<span class="" style="white-space:pre">         </span>     wl_fixed_t sx_w, wl_fixed_t sy_w)</div><div>+{</div><div>
+<span class="" style="white-space:pre">      </span>Client *client = (Client*) data;</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, pointer %p, surface %p )\n", __FUNCTION__, client, pointer, surface );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>if (!surface) {</div><div>+<span class="" style="white-space:pre">           </span>/* enter event for a window we've just destroyed */</div><div>+<span class="" style="white-space:pre">           </span>return;</div>
<div>+<span class="" style="white-space:pre">   </span>}</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>client->adapter.handleEnter( pointer, surface, sx_w, sy_w );</div><div>+}</div><div>+</div><div>
+static void</div><div>+pointer_handle_leave(void *data, struct wl_pointer *pointer,</div><div>+<span class="" style="white-space:pre">               </span>     uint32_t serial, struct wl_surface *surface)</div><div>+{</div><div>+<span class="" style="white-space:pre">        </span>Client *client = (Client*) data;</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, pointer %p )\n", __FUNCTION__, client, pointer );</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>client->adapter.handleLeave( pointer, surface );</div>
<div>+}</div><div>+</div><div>+static void</div><div>+pointer_handle_motion(void *data, struct wl_pointer *pointer,</div><div>+<span class="" style="white-space:pre">          </span>      uint32_t time, wl_fixed_t sx_w, wl_fixed_t sy_w)</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>Client *client = (Client*) data;</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, pointer %p )\n", __FUNCTION__, client, pointer );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>client->adapter.handleMotion( pointer, sx_w, sy_w );</div><div>+}</div><div>+</div><div>+static void</div><div>+pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial,</div>
<div>+<span class="" style="white-space:pre">           </span>      uint32_t time, uint32_t button, uint32_t state_w)</div><div>+{</div><div>+<span class="" style="white-space:pre">  </span>Client *client = (Client*) data;</div><div>
+</div><div>+<span class="" style="white-space:pre">      </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, pointer %p )\n", __FUNCTION__, client, pointer );</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>client->adapter.handleButton( pointer, button, state_w );</div>
<div>+}</div><div>+</div><div>+static void</div><div>+pointer_handle_axis(void *data, struct wl_pointer *pointer,</div><div>+<span class="" style="white-space:pre">            </span>    uint32_t time, uint32_t axis, wl_fixed_t value)</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>Client *client = (Client*) data;</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, pointer %p )\n", __FUNCTION__, client, pointer );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>client->adapter.handleAxis( pointer, axis, value );</div><div>+}</div><div>+</div><div>+static const struct wl_pointer_listener pointer_listener = {</div>
<div>+<span class="" style="white-space:pre">   </span>pointer_handle_enter,</div><div>+<span class="" style="white-space:pre">     </span>pointer_handle_leave,</div><div>+<span class="" style="white-space:pre">     </span>pointer_handle_motion,</div>
<div>+<span class="" style="white-space:pre">   </span>pointer_handle_button,</div><div>+<span class="" style="white-space:pre">    </span>pointer_handle_axis,</div><div>+};</div><div>+</div><div>+/**********************************************************************************************************************/</div>
<div>+/**********************************************************************************************************************/</div><div>+</div><div>+static void</div><div>+keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,</div>
<div>+<span class="" style="white-space:pre">           </span>       uint32_t format, int fd, uint32_t size)</div><div>+{</div><div>+<span class="" style="white-space:pre">   </span>Client *client = (Client*) data;</div><div>+</div>
<div>+<span class="" style="white-space:pre">   </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, keyboard %p )\n", __FUNCTION__, client, keyboard );</div><div>+</div><div>+#if 0</div><div>+<span class="" style="white-space:pre">      </span>char *map_str;</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>if (!data) {</div><div>+<span class="" style="white-space:pre">              </span>close(fd);</div><div>+<span class="" style="white-space:pre">                </span>return;</div><div>
+<span class="" style="white-space:pre">      </span>}</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) {</div><div>+<span class="" style="white-space:pre">         </span>close(fd);</div>
<div>+<span class="" style="white-space:pre">           </span>return;</div><div>+<span class="" style="white-space:pre">   </span>}</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>map_str = (char*) mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);</div>
<div>+<span class="" style="white-space:pre">   </span>if (map_str == MAP_FAILED) {</div><div>+<span class="" style="white-space:pre">              </span>close(fd);</div><div>+<span class="" style="white-space:pre">                </span>return;</div>
<div>+<span class="" style="white-space:pre">   </span>}</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>D_INFO("Keymap: '%s'\n", map_str);</div><div>+</div><div>+<span class="" style="white-space:pre">      </span>client->xkb.keymap = xkb_map_new_from_string(client->display->xkb_context,</div>
<div>+<span class="" style="white-space:pre">                                           </span>     map_str,</div><div>+<span class="" style="white-space:pre">                                             </span>     XKB_KEYMAP_FORMAT_TEXT_V1,</div><div>+<span class="" style="white-space:pre">                                           </span>     0);</div>
<div>+<span class="" style="white-space:pre">   </span>munmap(map_str, size);</div><div>+<span class="" style="white-space:pre">    </span>close(fd);</div><div>+</div><div>+</div><div>+<span class="" style="white-space:pre">        </span>if (!client->xkb.keymap) {</div>
<div>+<span class="" style="white-space:pre">           </span>fprintf(stderr, "failed to compile keymap\n");</div><div>+<span class="" style="white-space:pre">          </span>return;</div><div>+<span class="" style="white-space:pre">   </span>}</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>client->xkb.state = xkb_state_new(client->xkb.keymap);</div><div>+<span class="" style="white-space:pre">      </span>if (!client->xkb.state) {</div><div>
+<span class="" style="white-space:pre">              </span>fprintf(stderr, "failed to create XKB state\n");</div><div>+<span class="" style="white-space:pre">                </span>xkb_map_unref(client->xkb.keymap);</div><div>+<span class="" style="white-space:pre">             </span>client->xkb.keymap = NULL;</div>
<div>+<span class="" style="white-space:pre">           </span>return;</div><div>+<span class="" style="white-space:pre">   </span>}</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>client->xkb.control_mask =</div>
<div>+<span class="" style="white-space:pre">   </span>1 << xkb_map_mod_get_index(client->xkb.keymap, "Control");</div><div>+<span class="" style="white-space:pre">     </span>client->xkb.alt_mask =</div><div>
+<span class="" style="white-space:pre">      </span>1 << xkb_map_mod_get_index(client->xkb.keymap, "Mod1");</div><div>+<span class="" style="white-space:pre">        </span>client->xkb.shift_mask =</div><div>+<span class="" style="white-space:pre">       </span>1 << xkb_map_mod_get_index(client->xkb.keymap, "Shift");</div>
<div>+#endif</div><div>+}</div><div>+</div><div>+static void</div><div>+keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,</div><div>+<span class="" style="white-space:pre">          </span>      uint32_t serial, struct wl_surface *surface,</div>
<div>+<span class="" style="white-space:pre">           </span>      struct wl_array *keys)</div><div>+{</div><div>+<span class="" style="white-space:pre">     </span>Client *client = (Client*) data;</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, keyboard %p )\n", __FUNCTION__, client, keyboard );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>client->adapter.handleEnter( keyboard, surface );</div><div>+}</div><div>+</div><div>+static void</div><div>+keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,</div>
<div>+<span class="" style="white-space:pre">           </span>      uint32_t serial, struct wl_surface *surface)</div><div>+{</div><div>+<span class="" style="white-space:pre">       </span>Client *client = (Client*) data;</div><div>+</div>
<div>+<span class="" style="white-space:pre">   </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, keyboard %p )\n", __FUNCTION__, client, keyboard );</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>client->adapter.handleLeave( keyboard, surface );</div>
<div>+}</div><div>+</div><div>+static void</div><div>+keyboard_handle_key(void *data, struct wl_keyboard *keyboard,</div><div>+<span class="" style="white-space:pre">          </span>    uint32_t serial, uint32_t time, uint32_t key,</div>
<div>+<span class="" style="white-space:pre">           </span>    uint32_t state_w)</div><div>+{</div><div>+<span class="" style="white-space:pre">    </span>Client *client = (Client*) data;</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, keyboard %p )\n", __FUNCTION__, client, keyboard );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>client->adapter.handleKey( keyboard, key, state_w );</div><div>+}</div><div>+</div><div>+static void</div><div>+keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard,</div>
<div>+<span class="" style="white-space:pre">                   </span>  uint32_t serial, uint32_t mods_depressed,</div><div>+<span class="" style="white-space:pre">                       </span>  uint32_t mods_latched, uint32_t mods_locked,</div><div>+<span class="" style="white-space:pre">                    </span>  uint32_t group)</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>Client *client = (Client*) data;</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, keyboard %p )\n", __FUNCTION__, client, keyboard );</div>
<div>+</div><div>+}</div><div>+</div><div>+static const struct wl_keyboard_listener keyboard_listener = {</div><div>+<span class="" style="white-space:pre">    </span>keyboard_handle_keymap,</div><div>+<span class="" style="white-space:pre">   </span>keyboard_handle_enter,</div>
<div>+<span class="" style="white-space:pre">   </span>keyboard_handle_leave,</div><div>+<span class="" style="white-space:pre">    </span>keyboard_handle_key,</div><div>+<span class="" style="white-space:pre">      </span>keyboard_handle_modifiers,</div>
<div>+};</div><div>+</div><div>+/**********************************************************************************************************************/</div><div>+/**********************************************************************************************************************/</div>
<div>+</div><div>+static void</div><div>+seat_handle_capabilities(void *data,</div><div>+<span class="" style="white-space:pre">                    </span> struct wl_seat *wl_seat,</div><div>+<span class="" style="white-space:pre">                 </span> uint32_t capabilities)</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>Client *client = (Client*) data;</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, seat %p, caps 0x%08x )\n", __FUNCTION__, client, wl_seat, capabilities );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>if ((capabilities & WL_SEAT_CAPABILITY_POINTER) && !client->pointer) {</div><div>+<span class="" style="white-space:pre">             </span>client->pointer = wl_seat_get_pointer( wl_seat );</div>
<div>+<span class="" style="white-space:pre">           </span>wl_pointer_add_listener( client->pointer, &pointer_listener, client );</div><div>+<span class="" style="white-space:pre">     </span>} else if (!(capabilities & WL_SEAT_CAPABILITY_POINTER) && client->pointer) {</div>
<div>+<span class="" style="white-space:pre">           </span>wl_pointer_destroy( client->pointer );</div><div>+<span class="" style="white-space:pre">         </span>client->pointer = NULL;</div><div>+<span class="" style="white-space:pre">        </span>}</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>if ((capabilities & WL_SEAT_CAPABILITY_KEYBOARD) && !client->keyboard) {</div><div>+<span class="" style="white-space:pre">           </span>client->keyboard = wl_seat_get_keyboard( wl_seat );</div>
<div>+<span class="" style="white-space:pre">           </span>wl_keyboard_add_listener(client->keyboard, &keyboard_listener,</div><div>+<span class="" style="white-space:pre">                                     </span> client);</div><div>+<span class="" style="white-space:pre"> </span>} else if (!(capabilities & WL_SEAT_CAPABILITY_KEYBOARD) && client->keyboard) {</div>
<div>+<span class="" style="white-space:pre">           </span>wl_keyboard_destroy(client->keyboard);</div><div>+<span class="" style="white-space:pre">         </span>client->keyboard = NULL;</div><div>+<span class="" style="white-space:pre">       </span>}</div>
<div>+</div><div>+//     if ((capabilities & WL_SEAT_CAPABILITY_TOUCH) && !client->touch) {</div><div>+//          client->touch = wl_seat_get_touch( wl_seat );</div><div>+//          wl_touch_add_listener(client->touch, &touch_listener, client);</div>
<div>+//     }</div><div>+//     else if (!(capabilities & WL_SEAT_CAPABILITY_TOUCH) && client->touch) {</div><div>+//          wl_touch_destroy(client->touch);</div><div>+//          client->touch = NULL;</div>
<div>+//     }</div><div>+}</div><div>+</div><div>+static const struct wl_seat_listener seat_listener = {</div><div>+<span class="" style="white-space:pre">    </span>seat_handle_capabilities,</div><div>+};</div><div>+</div>
<div>+/**********************************************************************************************************************/</div><div>+/**********************************************************************************************************************/</div>
<div>+</div><div>+void</div><div>+Client::init()</div><div>+{</div><div>+<span class="" style="white-space:pre">        </span>D_DEBUG_AT( DFBWayland_Adapter, "Client::%s( %p )\n", __FUNCTION__, this );</div><div>+</div>
<div>+<span class="" style="white-space:pre">   </span>display = wl_display_connect( NULL );</div><div>+<span class="" style="white-space:pre">     </span>if (!display)</div><div>+<span class="" style="white-space:pre">             </span>throw std::runtime_error( "wl_display_connect_to_fd failed" );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>registry = wl_display_get_registry( display );</div><div>+</div><div>+<span class="" style="white-space:pre">    </span>wl_registry_add_listener( registry, &registry_listener, this );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>wl_display_dispatch( display );</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>wl_seat_add_listener( seat, &seat_listener, this );</div>
<div>+}</div><div>+</div><div>+void</div><div>+Client::run()</div><div>+{</div><div>+<span class="" style="white-space:pre">        </span>D_DEBUG_AT( DFBWayland_Adapter, "Client::%s( %p )\n", __FUNCTION__, this );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>while (true)</div><div>+<span class="" style="white-space:pre">              </span>wl_display_dispatch( display );</div><div>+}</div><div>+</div><div>+void</div><div>+Client::check()</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>//D_DEBUG_AT( DFBWayland_Adapter, "Client::%s( %p )\n", __FUNCTION__, this );</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>wl_display_flush( display );</div>
<div>+</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>struct pollfd pfd[1];</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>pfd[0].fd = wl_display_get_fd( display );</div><div>
+<span class="" style="white-space:pre">      </span>pfd[0].events = POLLIN;</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>int ret = poll(pfd, 1, 10);</div><div>+<span class="" style="white-space:pre">       </span>switch (ret) {</div>
<div>+<span class="" style="white-space:pre">   </span>case -1:</div><div>+<span class="" style="white-space:pre">          </span>D_PERROR( "DFBWayland/Adapter: poll\n" );</div><div>+<span class="" style="white-space:pre">               </span>return;</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>case 0:</div><div>+<span class="" style="white-space:pre">           </span>return;</div><div>+<span class="" style="white-space:pre">   </span>}</div><div>+</div><div>
+<span class="" style="white-space:pre">      </span>wl_display_dispatch( display );</div><div>+}</div><div>+</div><div>+/**********************************************************************************************************************/</div>
<div>+/**********************************************************************************************************************/</div><div>+</div><div>+/**********************************************************************************************************************/</div>
<div>+/**********************************************************************************************************************/</div><div>+</div><div>+static void</div><div>+handle_ping(void *data, struct wl_shell_surface *shell_surface,</div>
<div>+<span class="" style="white-space:pre">   </span>    uint32_t serial)</div><div>+{</div><div>+<span class="" style="white-space:pre">     </span>D_DEBUG_AT( DFBWayland_Adapter, "%s( %p, shell_surface %p, serial %u )\n", __FUNCTION__, data, shell_surface, serial );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>wl_shell_surface_pong(shell_surface, serial);</div><div>+}</div><div>+</div><div>+static void</div><div>+handle_configure(void *data, struct wl_shell_surface *shell_surface,</div>
<div>+<span class="" style="white-space:pre">           </span> uint32_t edges, int32_t width, int32_t height)</div><div>+{</div><div>+<span class="" style="white-space:pre">  </span>D_DEBUG_AT( DFBWayland_Adapter, "%s( %p, shell_surface %p, edges 0x%04x, width %d, height %d )\n",</div>
<div>+<span class="" style="white-space:pre">           </span>    __FUNCTION__, data, shell_surface, edges, width, height );</div><div>+}</div><div>+</div><div>+static void</div><div>+handle_popup_done(void *data, struct wl_shell_surface *shell_surface)</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>D_DEBUG_AT( DFBWayland_Adapter, "%s( %p, shell_surface %p )\n", __FUNCTION__, data, shell_surface );</div><div>+}</div><div>+</div><div>+static const struct wl_shell_surface_listener shell_surface_listener = {</div>
<div>+<span class="" style="white-space:pre">   </span>handle_ping,</div><div>+<span class="" style="white-space:pre">      </span>handle_configure,</div><div>+<span class="" style="white-space:pre"> </span>handle_popup_done</div>
<div>+};</div><div>+</div><div>+/**********************************************************************************************************************/</div><div>+</div><div>+static void</div><div>+configure_callback(void *data, struct wl_callback *callback, uint32_t  time)</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>DFBWindow *window = (DFBWindow*) data;</div><div>+</div><div>+<span class="" style="white-space:pre">    </span>D_DEBUG_AT( DFBWayland_Adapter, "%s( %p, callback %p )\n", __FUNCTION__, data, callback );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>wl_callback_destroy( callback );</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>window->configured = true;</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>window->push_buffer( 0 );</div>
<div>+}</div><div>+</div><div>+static struct wl_callback_listener configure_callback_listener = {</div><div>+<span class="" style="white-space:pre">        </span>configure_callback,</div><div>+};</div><div>+</div><div>+/**********************************************************************************************************************/</div>
<div>+/**********************************************************************************************************************/</div><div>+</div><div>+DFBWindow::DFBWindow( Adapter &adapter,</div><div>+<span class="" style="white-space:pre">                </span>      DFBWindowID    window_id )</div>
<div>+<span class="" style="white-space:pre">   </span>:</div><div>+<span class="" style="white-space:pre"> </span>adapter( adapter ),</div><div>+<span class="" style="white-space:pre">       </span>window_id( window_id ),</div><div>
+<span class="" style="white-space:pre">      </span>buffer( NULL ),</div><div>+<span class="" style="white-space:pre">   </span>wl_surface( NULL ),</div><div>+<span class="" style="white-space:pre">       </span>shell_surface( NULL ),</div>
<div>+<span class="" style="white-space:pre">   </span>wl_surface_id( 0 ),</div><div>+<span class="" style="white-space:pre">       </span>configured( false ),</div><div>+<span class="" style="white-space:pre">      </span>fullscreen( false ),</div>
<div>+<span class="" style="white-space:pre">   </span>pointer_x( 0 ),</div><div>+<span class="" style="white-space:pre">   </span>pointer_y( 0 )</div><div>+{</div><div>+<span class="" style="white-space:pre">   </span>D_DEBUG_AT( DFBWayland_Adapter, "DFBWindow::%s( %p, id %u )\n", __FUNCTION__, this, window_id );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>window     = adapter.layer.GetWindow( window_id );</div><div>+<span class="" style="white-space:pre">        </span>surface    = window.GetSurface();</div><div>+<span class="" style="white-space:pre"> </span>surface_id = surface.GetID();</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>surface.GetSize( &width, &height );</div><div>+</div><div>+<span class="" style="white-space:pre">       </span>surface.iface->AttachEventBuffer( surface.iface, adapter.events.iface );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>surface.iface->MakeClient( surface.iface );</div><div>+}</div><div>+</div><div>+DFBWindow::~DFBWindow()</div><div>+{</div><div>+<span class="" style="white-space:pre">   </span>D_DEBUG_AT( DFBWayland_Adapter, "DFBWindow::%s( %p ) <- id %u\n", __FUNCTION__, this, window_id );</div>
<div>+}</div><div>+</div><div>+void</div><div>+DFBWindow::integrate()</div><div>+{</div><div>+<span class="" style="white-space:pre">       </span>D_DEBUG_AT( DFBWayland_Adapter, "DFBWindow::%s( %p ) <- id %u\n", __FUNCTION__, this, window_id );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>wl_surface    = wl_compositor_create_surface( adapter.client.compositor );</div><div>+<span class="" style="white-space:pre">        </span>wl_surface_id = wl_proxy_get_id((wl_proxy*)wl_surface);</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>shell_surface = wl_shell_get_shell_surface( adapter.client.shell, wl_surface );</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>wl_shell_surface_add_listener( shell_surface, &shell_surface_listener, this );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>wl_shell_surface_set_title( shell_surface, "DFB Test" );</div><div>+</div><div>+<span class="" style="white-space:pre">        </span>toggle_fullscreen( false );</div>
<div>+}</div><div>+</div><div>+void</div><div>+DFBWindow::HandleSurfaceEvent( const DFBSurfaceEvent &event )</div><div>+{</div><div>+<span class="" style="white-space:pre">    </span>D_DEBUG_AT( DFBWayland_Adapter, "DFBWindow::%s( %p, event %p ) <- type 0x%04x\n", __FUNCTION__, this, &event, event.type );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>switch (event.type) {</div><div>+<span class="" style="white-space:pre">     </span>case DSEVT_UPDATE: {</div><div>+<span class="" style="white-space:pre">                      </span>D_DEBUG_AT( DFBWayland_Adapter, "  -> UPDATE %u %d,%d-%dx%d %d\n",</div>
<div>+<span class="" style="white-space:pre">                           </span>    event.surface_id, DFB_RECTANGLE_VALS_FROM_REGION( &event.update ), event.flip_count );</div><div>+</div><div>+<span class="" style="white-space:pre">                    </span>surface.iface->FrameAck( surface.iface, event.flip_count );</div>
<div>+</div><div>+<span class="" style="white-space:pre">                   </span>if (configured)</div><div>+<span class="" style="white-space:pre">                           </span>push_buffer( event.flip_count );</div><div>+</div><div>+<span class="" style="white-space:pre">                  </span>break;</div>
<div>+<span class="" style="white-space:pre">           </span>}</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>default:</div><div>+<span class="" style="white-space:pre">          </span>break;</div><div>+<span class="" style="white-space:pre">    </span>}</div>
<div>+}</div><div>+</div><div>+void</div><div>+DFBWindow::toggle_fullscreen( bool fullscreen )</div><div>+{</div><div>+<span class="" style="white-space:pre">      </span>D_DEBUG_AT( DFBWayland_Adapter, "DFBWindow::%s( %p )\n", __FUNCTION__, this );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>struct wl_callback *callback;</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>this->fullscreen = fullscreen;</div><div>+<span class="" style="white-space:pre"> </span>this->configured = false;</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>if (fullscreen) {</div><div>+<span class="" style="white-space:pre">         </span>wl_shell_surface_set_fullscreen( shell_surface,</div><div>+<span class="" style="white-space:pre">                                           </span> WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,</div>
<div>+<span class="" style="white-space:pre">                                           </span> 0, NULL );</div><div>+<span class="" style="white-space:pre">       </span>} else {</div><div>+<span class="" style="white-space:pre">          </span>wl_shell_surface_set_toplevel( shell_surface );</div>
<div>+</div><div>+<span class="" style="white-space:pre">           </span>handle_configure( this, shell_surface, 0, width, height );</div><div>+<span class="" style="white-space:pre">        </span>}</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>callback = wl_display_sync( adapter.client.display );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>wl_callback_add_listener( callback, &configure_callback_listener, this );</div><div>+}</div><div>+</div><div>+void</div><div>+DFBWindow::push_buffer( u32 flip_count )</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>D_DEBUG_AT( DFBWayland_Adapter, "DFBWindow::%s( %p, flip_count %u )\n", __FUNCTION__, this, flip_count );</div><div>+</div><div>+//     if (buffer)</div>
<div>+//          wl_dfb_buffer_destroy( buffer );</div><div>+//</div><div>+//     buffer = wl_dfb_create_buffer( adapter.client.wl_dfb, surface_id, 0, 0 );</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>if (!buffer)</div>
<div>+<span class="" style="white-space:pre">           </span>buffer = wl_dfb_create_buffer( adapter.client.wl_dfb, surface_id, 0, 0 );</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>wl_surface_attach( wl_surface, (struct wl_buffer*) buffer, 0, 0 );</div>
<div>+<span class="" style="white-space:pre">   </span>wl_surface_damage( wl_surface, 0, 0, width, height );</div><div>+<span class="" style="white-space:pre">     </span>wl_surface_commit( wl_surface );</div><div>+}</div><div>
+</div><div>+void</div><div>+DFBWindow::dispatchEnter( int x, int y )</div><div>+{</div><div>+<span class="" style="white-space:pre"> </span>D_DEBUG_AT( DFBWayland_Adapter, "DFBWindow::%s( %p, %d,%d )\n", __FUNCTION__, this, x, y );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>DFBWindowEvent event;</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>event.type  = DWET_ENTER;</div><div>+<span class="" style="white-space:pre"> </span>event.flags = DWEF_NONE;</div>
<div>+<span class="" style="white-space:pre">   </span>event.x     = x;</div><div>+<span class="" style="white-space:pre">  </span>event.y     = y;</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>pointer_x = x;</div>
<div>+<span class="" style="white-space:pre">   </span>pointer_y = y;</div><div>+</div><div>+<span class="" style="white-space:pre">    </span>window.iface->SendEvent( window.iface, &event );</div><div>+}</div><div>+</div>
<div>+void</div><div>+DFBWindow::dispatchLeave()</div><div>+{</div><div>+<span class="" style="white-space:pre">    </span>D_DEBUG_AT( DFBWayland_Adapter, "DFBWindow::%s( %p )\n", __FUNCTION__, this );</div><div>+</div>
<div>+<span class="" style="white-space:pre">   </span>DFBWindowEvent event;</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>event.type  = DWET_LEAVE;</div><div>+<span class="" style="white-space:pre"> </span>event.flags = DWEF_NONE;</div>
<div>+<span class="" style="white-space:pre">   </span>event.x     = pointer_x;</div><div>+<span class="" style="white-space:pre">  </span>event.y     = pointer_y;</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>window.iface->SendEvent( window.iface, &event );</div>
<div>+}</div><div>+</div><div>+void</div><div>+DFBWindow::dispatchMotion( int x, int y )</div><div>+{</div><div>+<span class="" style="white-space:pre">    </span>D_DEBUG_AT( DFBWayland_Adapter, "DFBWindow::%s( %p, %d,%d )\n", __FUNCTION__, this, x, y );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>DFBWindowEvent event;</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>event.type  = DWET_MOTION;</div><div>+<span class="" style="white-space:pre">        </span>event.flags = DWEF_NONE;</div>
<div>+<span class="" style="white-space:pre">   </span>event.x     = x;</div><div>+<span class="" style="white-space:pre">  </span>event.y     = y;</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>pointer_x = x;</div>
<div>+<span class="" style="white-space:pre">   </span>pointer_y = y;</div><div>+</div><div>+<span class="" style="white-space:pre">    </span>window.iface->SendEvent( window.iface, &event );</div><div>+}</div><div>+</div>
<div>+void</div><div>+DFBWindow::dispatchButton( DFBInputDeviceButtonIdentifier button,</div><div>+<span class="" style="white-space:pre">                      </span>   bool                           pressed )</div><div>+{</div><div>+<span class="" style="white-space:pre">      </span>D_DEBUG_AT( DFBWayland_Adapter, "DFBWindow::%s( %p, button %d, pressed %d )\n", __FUNCTION__, this, button, pressed );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>DFBWindowEvent event;</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>event.type   = pressed ? DWET_BUTTONDOWN : DWET_BUTTONUP;</div><div>
+<span class="" style="white-space:pre">      </span>event.flags  = DWEF_NONE;</div><div>+<span class="" style="white-space:pre"> </span>event.button = button;</div><div>+<span class="" style="white-space:pre">    </span>event.x      = pointer_x;</div>
<div>+<span class="" style="white-space:pre">   </span>event.y      = pointer_y;</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>window.iface->SendEvent( window.iface, &event );</div><div>+}</div>
<div>+</div><div>+void</div><div>+DFBWindow::dispatchWheel( int v )</div><div>+{</div><div>+<span class="" style="white-space:pre">     </span>D_DEBUG_AT( DFBWayland_Adapter, "DFBWindow::%s( %p, %d )\n", __FUNCTION__, this, v );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>DFBWindowEvent event;</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>event.type  = DWET_WHEEL;</div><div>+<span class="" style="white-space:pre"> </span>event.flags = DWEF_NONE;</div>
<div>+<span class="" style="white-space:pre">   </span>event.step  = v;</div><div>+<span class="" style="white-space:pre">  </span>event.x     = pointer_x;</div><div>+<span class="" style="white-space:pre">  </span>event.y     = pointer_y;</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>window.iface->SendEvent( window.iface, &event );</div><div>+}</div><div>+</div><div>+void</div><div>+DFBWindow::dispatchKey( int  key_code,</div><div>
+<span class="" style="white-space:pre">                      </span>bool pressed )</div><div>+{</div><div>+<span class="" style="white-space:pre">   </span>D_DEBUG_AT( DFBWayland_Adapter, "DFBWindow::%s( %p, key_code %d, pressed %d )\n", __FUNCTION__, this, key_code, pressed );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>DFBWindowEvent event;</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>event.type       = pressed ? DWET_KEYDOWN : DWET_KEYUP;</div><div>
+<span class="" style="white-space:pre">      </span>event.flags      = DWEF_NONE;</div><div>+<span class="" style="white-space:pre">     </span>event.key_code   = key_code;</div><div>+<span class="" style="white-space:pre">      </span>//event.key_id     = key_code;</div>
<div>+<span class="" style="white-space:pre">   </span>//event.key_symbol = key_code;</div><div>+</div><div>+<span class="" style="white-space:pre">    </span>window.iface->SendEvent( window.iface, &event );</div><div>+}</div>
<div>+</div><div>+/**********************************************************************************************************************/</div><div>+/**********************************************************************************************************************/</div>
<div>+</div><div>+static void</div><div>+dump_config( const DFBWindowConfig *config )</div><div>+{</div><div>+<span class="" style="white-space:pre">   </span>D_INFO( "  -> bounds       %d,%d-%dx%d\n", DFB_RECTANGLE_VALS( &config->bounds ) );</div>
<div>+<span class="" style="white-space:pre">   </span>D_INFO( "  -> opacity      %d\n", config->opacity );</div><div>+<span class="" style="white-space:pre">      </span>D_INFO( "  -> cursor flags 0x%08x\n", config->cursor_flags );</div>
<div>+}</div><div>+</div><div>+/**********************************************************************************************************************/</div><div>+</div><div>+void</div><div>+Adapter::Watcher_WindowAdd( const DFBWindowInfo *info )</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>D_INFO( "%s( ID %u )\n", __FUNCTION__, info->window_id );</div><div>+<span class="" style="white-space:pre">    </span>D_INFO( "  -> caps         0x%08x\n", info->caps );</div>
<div>+<span class="" style="white-space:pre">   </span>D_INFO( "  -> resource id  0x%016llx\n", (unsigned long long) info->resource_id );</div><div>+<span class="" style="white-space:pre">        </span>D_INFO( "  -> process id   %d\n", info->process_id );</div>
<div>+<span class="" style="white-space:pre">   </span>D_INFO( "  -> instance id  %d\n", info->instance_id );</div><div>+<span class="" style="white-space:pre">    </span>D_INFO( "  -> state        0x%08x\n", info->state.flags );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>dump_config( &info->config );</div><div>+</div><div>+<span class="" style="white-space:pre">      </span>if (info->resource_id == 0) {</div><div>+<span class="" style="white-space:pre">          </span>AddWindow( info->window_id );</div>
<div>+<span class="" style="white-space:pre">   </span>}</div><div>+}</div><div>+</div><div>+void</div><div>+Adapter::Watcher_WindowRemove( DFBWindowID  window_id )</div><div>+{</div><div>+<span class="" style="white-space:pre">    </span>D_INFO( "%s( ID %u )\n", __FUNCTION__, window_id );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>RemoveWindow( window_id );</div><div>+}</div><div>+</div><div>+void</div><div>+Adapter::Watcher_WindowConfig( DFBWindowID            window_id,</div><div>+<span class="" style="white-space:pre">                   </span>       const DFBWindowConfig *config,</div>
<div>+<span class="" style="white-space:pre">                   </span>       DFBWindowConfigFlags   flags )</div><div>+{</div><div>+<span class="" style="white-space:pre">    </span>D_INFO( "%s( ID %u )\n", __FUNCTION__, window_id );</div>
<div>+<span class="" style="white-space:pre">   </span>D_INFO( "  -> flags        0x%08x\n", flags );</div><div>+<span class="" style="white-space:pre">       </span>D_INFO( "  -> cursor flags 0x%08x\n", config->cursor_flags );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>dump_config( config );</div><div>+}</div><div>+</div><div>+void</div><div>+Adapter::Watcher_WindowState( DFBWindowID           window_id,</div><div>+<span class="" style="white-space:pre">                 </span>      const DFBWindowState *state )</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>D_INFO( "%s( ID %u )\n", __FUNCTION__, window_id );</div><div>+<span class="" style="white-space:pre">     </span>D_INFO( "  -> flags        0x%08x\n", state->flags );</div>
<div>+}</div><div>+</div><div>+void</div><div>+Adapter::Watcher_WindowRestack( DFBWindowID   window_id,</div><div>+<span class="" style="white-space:pre">                              </span>unsigned int  index )</div><div>+{</div><div>+<span class="" style="white-space:pre">    </span>D_INFO( "%s( ID %u )\n", __FUNCTION__, window_id );</div>
<div>+<span class="" style="white-space:pre">   </span>D_INFO( "  -> index        %u\n", index );</div><div>+}</div><div>+</div><div>+void</div><div>+Adapter::Watcher_WindowFocus( DFBWindowID  window_id )</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>D_INFO( "%s( ID %u )\n", __FUNCTION__, window_id );</div><div>+}</div><div>+</div><div>+/**********************************************************************************************************************/</div>
<div>+</div><div>+Adapter::Adapter()</div><div>+<span class="" style="white-space:pre"> </span>:</div><div>+<span class="" style="white-space:pre"> </span>dfb_windows( NULL ),</div><div>+<span class="" style="white-space:pre">      </span>client( *this )</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s()\n", __FUNCTION__ );</div><div>+</div><div>+<span class="" style="white-space:pre">      </span>watcher.WindowAdd     = (__typeof__(watcher.WindowAdd    ))( &Adapter::Watcher_WindowAdd );</div>
<div>+<span class="" style="white-space:pre">   </span>watcher.WindowRemove  = (__typeof__(watcher.WindowRemove ))( &Adapter::Watcher_WindowRemove );</div><div>+<span class="" style="white-space:pre">        </span>watcher.WindowConfig  = (__typeof__(watcher.WindowConfig ))( &Adapter::Watcher_WindowConfig );</div>
<div>+<span class="" style="white-space:pre">   </span>watcher.WindowState   = (__typeof__(watcher.WindowState  ))( &Adapter::Watcher_WindowState );</div><div>+<span class="" style="white-space:pre"> </span>watcher.WindowRestack = (__typeof__(watcher.WindowRestack))( &Adapter::Watcher_WindowRestack );</div>
<div>+<span class="" style="white-space:pre">   </span>watcher.WindowFocus   = (__typeof__(watcher.WindowFocus  ))( &Adapter::Watcher_WindowFocus );</div><div>+}</div><div>+</div><div>+Adapter::~Adapter()</div><div>+{</div>
<div>+<span class="" style="white-space:pre">   </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s()\n", __FUNCTION__ );</div><div>+}</div><div>+</div><div>+void</div><div>+Adapter::init()</div><div>+{</div><div>
+<span class="" style="white-space:pre">      </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s()\n", __FUNCTION__ );</div><div>+</div><div>+<span class="" style="white-space:pre">      </span>client.init();</div><div>+</div>
<div>+<span class="" style="white-space:pre">   </span>dfb    = DirectFB::Create();</div><div>+<span class="" style="white-space:pre">      </span>events = dfb.CreateEventBuffer();</div><div>+<span class="" style="white-space:pre"> </span>layer  = dfb.GetDisplayLayer( DLID_PRIMARY );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>dfb_windows = (IDirectFBWindows*) dfb.GetInterface( "IDirectFBWindows", NULL, NULL );</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>dfb_windows->RegisterWatcher( dfb_windows, &watcher, this );</div>
<div>+}</div><div>+</div><div>+void</div><div>+Adapter::run()</div><div>+{</div><div>+<span class="" style="white-space:pre">       </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s()\n", __FUNCTION__ );</div><div>+</div>
<div>+<span class="" style="white-space:pre">   </span>while (true) {</div><div>+<span class="" style="white-space:pre">            </span>client.check();</div><div>+</div><div>+<span class="" style="white-space:pre">           </span>for (auto it=windows.begin(); it!=windows.end(); it++) {</div>
<div>+<span class="" style="white-space:pre">                   </span>std::shared_ptr<DFBWindow> window = (*it).second;</div><div>+</div><div>+<span class="" style="white-space:pre">                   </span>if (window && !window->wl_surface) {</div>
<div>+<span class="" style="white-space:pre">                           </span>window->integrate();</div><div>+</div><div>+<span class="" style="white-space:pre">                           </span>wl_surfaces[ window->wl_surface_id ] = window;</div><div>+<span class="" style="white-space:pre">                 </span>}</div>
<div>+<span class="" style="white-space:pre">           </span>}</div><div>+</div><div>+</div><div>+<span class="" style="white-space:pre">         </span>DFBEvent event;</div><div>+</div><div>+<span class="" style="white-space:pre">           </span>while (events.GetEvent( &event )) {</div>
<div>+<span class="" style="white-space:pre">                   </span>switch (event.clazz) {</div><div>+<span class="" style="white-space:pre">                    </span>case DFEC_SURFACE:</div><div>+<span class="" style="white-space:pre">                                </span>HandleSurfaceEvent( event.surface );</div>
<div>+<span class="" style="white-space:pre">                           </span>break;</div><div>+<span class="" style="white-space:pre">                    </span>}</div><div>+<span class="" style="white-space:pre">         </span>}</div><div>+<span class="" style="white-space:pre"> </span>}</div>
<div>+}</div><div>+</div><div>+void</div><div>+Adapter::shutdown()</div><div>+{</div><div>+<span class="" style="white-space:pre">  </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s()\n", __FUNCTION__ );</div><div>
+</div><div>+<span class="" style="white-space:pre">      </span>dfb_windows->UnregisterWatcher( dfb_windows, this );</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>dfb_windows->Release( dfb_windows );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>windows.clear();</div><div>+}</div><div>+</div><div>+void</div><div>+Adapter::AddWindow( DFBWindowID window_id )</div><div>+{</div><div>+<span class="" style="white-space:pre"> </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %u )\n", __FUNCTION__, window_id );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>auto window = windows[window_id];</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>if (window) {</div><div>+<span class="" style="white-space:pre">             </span>D_WARN( "window %u already added", window_id );</div>
<div>+<span class="" style="white-space:pre">           </span>return;</div><div>+<span class="" style="white-space:pre">   </span>}</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>window.reset( new DFBWindow( *this, window_id ) );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>windows[window_id] = window;</div><div>+<span class="" style="white-space:pre">      </span>surfaces[window->surface_id] = window;</div><div>+}</div><div>+</div>
<div>+void</div><div>+Adapter::RemoveWindow( DFBWindowID window_id )</div><div>+{</div><div>+<span class="" style="white-space:pre">        </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %u )\n", __FUNCTION__, window_id );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>std::shared_ptr<DFBWindow> window = windows[window_id];</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>if (!window) {</div><div>
+<span class="" style="white-space:pre">              </span>D_WARN( "window %u not added", window_id );</div><div>+<span class="" style="white-space:pre">             </span>return;</div><div>+<span class="" style="white-space:pre">   </span>}</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>surfaces.erase( window->surface_id );</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>windows.erase( window_id );</div><div>+</div>
<div>+<span class="" style="white-space:pre">   </span>if (window->wl_surface_id)</div><div>+<span class="" style="white-space:pre">             </span>wl_surfaces.erase( window->wl_surface_id );</div><div>+</div><div>+<span class="" style="white-space:pre">    </span>if (pointer_focus == window)</div>
<div>+<span class="" style="white-space:pre">           </span>pointer_focus.reset();</div><div>+</div><div>+<span class="" style="white-space:pre">    </span>if (keyboard_focus == window)</div><div>+<span class="" style="white-space:pre">             </span>keyboard_focus.reset();</div>
<div>+}</div><div>+</div><div>+void</div><div>+Adapter::HandleWindowEvent( const DFBWindowEvent &event )</div><div>+{</div><div>+<span class="" style="white-space:pre">        </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, event %p ) <- type 0x%04x\n", __FUNCTION__, this, &event, event.type );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>switch (event.type) {</div><div>+<span class="" style="white-space:pre">     </span>case DWET_POSITION_SIZE:</div><div>+<span class="" style="white-space:pre">          </span>D_DEBUG_AT( DFBWayland_Adapter, "  -> POSITION_SIZE %d,%d-%dx%d\n",</div>
<div>+<span class="" style="white-space:pre">                   </span>    event.x, event.y, event.w, event.h );</div><div>+<span class="" style="white-space:pre">         </span>break;</div><div>+</div><div>+<span class="" style="white-space:pre">    </span>default:</div>
<div>+<span class="" style="white-space:pre">           </span>break;</div><div>+<span class="" style="white-space:pre">    </span>}</div><div>+}</div><div>+</div><div>+void</div><div>+Adapter::HandleSurfaceEvent( const DFBSurfaceEvent &event )</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, event %p ) <- type 0x%04x\n", __FUNCTION__, this, &event, event.type );</div><div>+</div>
<div>+<span class="" style="white-space:pre">   </span>switch (event.type) {</div><div>+<span class="" style="white-space:pre">     </span>case DSEVT_UPDATE: {</div><div>+<span class="" style="white-space:pre">                      </span>D_DEBUG_AT( DFBWayland_Adapter, "  -> UPDATE %u %d,%d-%dx%d %d\n",</div>
<div>+<span class="" style="white-space:pre">                           </span>    event.surface_id, DFB_RECTANGLE_VALS_FROM_REGION( &event.update ), event.flip_count );</div><div>+</div><div>+<span class="" style="white-space:pre">                    </span>auto window = surfaces[event.surface_id];</div>
<div>+</div><div>+<span class="" style="white-space:pre">                   </span>if (window)</div><div>+<span class="" style="white-space:pre">                               </span>window->HandleSurfaceEvent( event );</div><div>+<span class="" style="white-space:pre">                   </span>else</div>
<div>+<span class="" style="white-space:pre">                           </span>D_LOG( DFBWayland_Adapter, VERBOSE, "  -> SURFACE WITH ID %u NOT FOUND\n", event.surface_id );</div><div>+</div><div>+<span class="" style="white-space:pre">                       </span>break;</div>
<div>+<span class="" style="white-space:pre">           </span>}</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>default:</div><div>+<span class="" style="white-space:pre">          </span>break;</div><div>+<span class="" style="white-space:pre">    </span>}</div>
<div>+}</div><div>+</div><div>+/**********************************************************************************************************************/</div><div>+</div><div>+void</div><div>+Adapter::handleEnter( struct wl_pointer *pointer,</div>
<div>+<span class="" style="white-space:pre">           </span>      struct wl_surface *surface,</div><div>+<span class="" style="white-space:pre">         </span>      wl_fixed_t         sx_w,</div><div>+<span class="" style="white-space:pre">            </span>      wl_fixed_t         sy_w )</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>int sx = wl_fixed_to_int( sx_w );</div><div>+<span class="" style="white-space:pre"> </span>int sy = wl_fixed_to_int( sy_w );</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, surface %p, sx %d, sy %d )\n", __FUNCTION__, this, surface, sx, sy );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>pointer_focus = wl_surfaces[ wl_proxy_get_id((wl_proxy*)surface) ];</div><div>+</div><div>+<span class="" style="white-space:pre">       </span>if (pointer_focus) {</div>
<div>+<span class="" style="white-space:pre">           </span>pointer_focus->dispatchEnter( sx, sy );</div><div>+<span class="" style="white-space:pre">        </span>}</div><div>+}</div><div>+</div><div>+void</div><div>+Adapter::handleLeave( struct wl_pointer *pointer,</div>
<div>+<span class="" style="white-space:pre">           </span>      struct wl_surface *surface )</div><div>+{</div><div>+<span class="" style="white-space:pre">       </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, surface %p )\n", __FUNCTION__, this, surface );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>auto window = wl_surfaces[ wl_proxy_get_id((wl_proxy*)surface) ];</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>D_ASSUME( pointer_focus == window );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>if (pointer_focus == window) {</div><div>+<span class="" style="white-space:pre">            </span>pointer_focus->dispatchLeave();</div><div>+<span class="" style="white-space:pre">                </span>pointer_focus.reset();</div>
<div>+<span class="" style="white-space:pre">   </span>}</div><div>+}</div><div>+</div><div>+void</div><div>+Adapter::handleMotion( struct wl_pointer *pointer,</div><div>+<span class="" style="white-space:pre">          </span>       wl_fixed_t         sx_w,</div>
<div>+<span class="" style="white-space:pre">           </span>       wl_fixed_t         sy_w )</div><div>+{</div><div>+<span class="" style="white-space:pre"> </span>int sx = wl_fixed_to_int( sx_w );</div><div>+<span class="" style="white-space:pre"> </span>int sy = wl_fixed_to_int( sy_w );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, sx %d, sy %d )\n", __FUNCTION__, this, sx, sy );</div><div>+</div><div>+<span class="" style="white-space:pre">      </span>if (pointer_focus) {</div>
<div>+<span class="" style="white-space:pre">           </span>pointer_focus->dispatchMotion( sx, sy );</div><div>+<span class="" style="white-space:pre">       </span>}</div><div>+}</div><div>+</div><div>+void</div><div>+Adapter::handleButton( struct wl_pointer *pointer,</div>
<div>+<span class="" style="white-space:pre">           </span>       uint32_t           button,</div><div>+<span class="" style="white-space:pre">         </span>       uint32_t           state_w )</div><div>+{</div><div>+<span class="" style="white-space:pre">      </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, button %d, state %d )\n", __FUNCTION__, this, button, state_w );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>if (pointer_focus) {</div><div>+<span class="" style="white-space:pre">              </span>pointer_focus->dispatchButton( (DFBInputDeviceButtonIdentifier)( DIBI_FIRST + button - BTN_LEFT ),</div>
<div>+<span class="" style="white-space:pre">                                   </span>       state_w == WL_POINTER_BUTTON_STATE_PRESSED );</div><div>+<span class="" style="white-space:pre">      </span>}</div><div>+}</div><div>+</div><div>+void</div><div>
+Adapter::handleAxis( struct wl_pointer *pointer,</div><div>+<span class="" style="white-space:pre">              </span>     uint32_t           axis,</div><div>+<span class="" style="white-space:pre">             </span>     wl_fixed_t         value )</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>int v = wl_fixed_to_int( value );</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, axis %d, value %d )\n", __FUNCTION__, this, axis, v );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>if (pointer_focus) {</div><div>+<span class="" style="white-space:pre">              </span>pointer_focus->dispatchWheel( v );</div><div>+<span class="" style="white-space:pre">     </span>}</div>
<div>+}</div><div>+</div><div>+/**********************************************************************************************************************/</div><div>+</div><div>+void</div><div>+Adapter::handleEnter( struct wl_keyboard *keyboard,</div>
<div>+<span class="" style="white-space:pre">           </span>      struct wl_surface *surface )</div><div>+{</div><div>+<span class="" style="white-space:pre">       </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, surface %p )\n", __FUNCTION__, this, surface );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>keyboard_focus = wl_surfaces[ wl_proxy_get_id((wl_proxy*)surface) ];</div><div>+}</div><div>+</div><div>+void</div><div>+Adapter::handleLeave( struct wl_keyboard *keyboard,</div>
<div>+<span class="" style="white-space:pre">           </span>      struct wl_surface *surface )</div><div>+{</div><div>+<span class="" style="white-space:pre">       </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, surface %p )\n", __FUNCTION__, this, surface );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>auto window = wl_surfaces[ wl_proxy_get_id((wl_proxy*)surface) ];</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>D_ASSUME( keyboard_focus == window );</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>if (keyboard_focus == window) {</div><div>+<span class="" style="white-space:pre">           </span>keyboard_focus.reset();</div><div>+<span class="" style="white-space:pre">   </span>}</div>
<div>+}</div><div>+</div><div>+void</div><div>+Adapter::handleKey( struct wl_keyboard *keyboard,</div><div>+<span class="" style="white-space:pre">             </span>    uint32_t            key,</div><div>+<span class="" style="white-space:pre">              </span>    uint32_t            state_w )</div>
<div>+{</div><div>+<span class="" style="white-space:pre">  </span>D_DEBUG_AT( DFBWayland_Adapter, "Adapter::%s( %p, key %d, state %d )\n", __FUNCTION__, this, key, state_w );</div><div>+</div><div>+<span class="" style="white-space:pre">    </span>if (keyboard_focus) {</div>
<div>+<span class="" style="white-space:pre">           </span>keyboard_focus->dispatchKey( key,</div><div>+<span class="" style="white-space:pre">                                      </span>     state_w == WL_KEYBOARD_KEY_STATE_PRESSED );</div><div>+<span class="" style="white-space:pre">  </span>}</div>
<div>+}</div><div>+</div><div>+/**********************************************************************************************************************/</div><div>+/**********************************************************************************************************************/</div>
<div>+</div><div>+/**********************************************************************************************************************/</div><div>+</div><div>+int</div><div>+main( int argc, char *argv[] )</div><div>+{</div>
<div>+<span class="" style="white-space:pre">   </span>Adapter adapter;</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>DirectFB::Init( &argc, &argv );</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>adapter.init();</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>adapter.run();</div><div>+</div><div>+<span class="" style="white-space:pre">    </span>return 0;</div><div>+}</div><div>+</div></div>