Subject: Sam`s GDK-Mir Backend

From: Leslie Zhai <[email-masked]>
Date: Thu, 22 Aug 2013 12:57:14 +0800

Hi Sam, gtk3-demo WORKED :)

But there is still some bug need to fix, such as Invalid rectangle region.

Leslie

> That looks like the fix I applied. Have you tried stepping through the 
> library to make sure it was conditionally compiled in?
>
>
> On Thu, Aug 22, 2013 at 11:34 AM, Leslie Zhai <[email-masked] 
> <mailto:[email-masked]>> wrote:
>
>     Hi Sam,
>
>     Did you fixed the gdkdisplaymanager without mir bug like this?
>
>     diff --git a/gdk/gdkdisplaymanager.c b/gdk/gdkdisplaymanager.c
>     index 075f507..84c07a4 100644
>     --- a/gdk/gdkdisplaymanager.c
>     +++ b/gdk/gdkdisplaymanager.c
>     @@ -60,6 +60,10 @@
>      #include "wayland/gdkprivate-wayland.h"
>      #endif
>
>     +#ifdef GDK_WINDOWING_MIR
>     +#include "mir/gdkprivate-mir.h"
>     +#endif
>     +
>      /**
>       * SECTION:gdkdisplaymanager
>       * @Short_description: Maintains a list of all open GdkDisplays
>     @@ -270,6 +274,9 @@ static GdkBackend gdk_backends[] = {
>      #ifdef GDK_WINDOWING_WAYLAND
>        { "wayland",  _gdk_wayland_display_open },
>      #endif
>     +#ifdef GDK_WINDOWING_MIR
>     +  { "mir",      _gdk_mir_display_open },
>     +#endif
>      #ifdef GDK_WINDOWING_X11
>        { "x11",      _gdk_x11_display_open },
>      #endif
>
>     I using GDK_BACKEND=mir GTK_CSD=1 ./gtk/examples/hello-world
>     But still (lt-hello-world:6443): Gtk-WARNING **: cannot open
>     display: :0
>
>     I built the gtk ./autogen.sh --enable-mir-backend
>     --disable-wayland-backend ...
>     Did you disable  the wayland backend? it is useless.
>
>     Leslie
>
>>     Hey Leslie,
>>
>>     I'm currently running it natively - you need to explicitly tell
>>     GDK to use the mir backend.
>>
>>     ./autogen.sh --enable-mir-backend ...
>>     GDK_BACKEND=mir GTK_CSD=1 ./gtk/examples/hello-world
>>
>>     There was a bug for a little bit where the backend stub to pick
>>     the mir backend in gdkdisplaymanager wasn't checked in to source
>>     control, but I've fixed that now.
>>
>>     I've (mostly) fixed the display lag problem. Part of that is a
>>     fix to the mir compositor so you'll need a recent (955+) revision
>>     of that. There is still a condition where frame swaps can get out
>>     of sync with input events which I'll look into soon.
>>
>>     Sam.
>>
>>
>>     On Thu, Aug 22, 2013 at 11:17 AM, Leslie Zhai
>>     <[email-masked] <mailto:[email-masked]>> wrote:
>>
>>         Hi Sam,
>>
>>         I came back to "just for fun open source project" from
>>         business development.
>>
>>         I running Mir natively described in doc/using_mir_on_pc.md
>>         <http://using_mir_on_pc.md>
>>
>>             $ sudo mir_demo_server
>>             <Ctrl+Alt+F2> - log in to VT 2
>>             $ sudo chmod 777 /tmp/mir_socket
>>             $ gtk/examples/hello-world
>>             <Ctrl+Alt+F1> - switch back to Mir
>>
>>         But (lt-hello-world:6443): Gtk-WARNING **: cannot open
>>         display: :0
>>
>>         So did you test the GDK Mir backend using Mir natively way?
>>         or whether directly using XMir?
>>
>>         Leslie
>>
>>>         Hey Leslie,
>>>
>>>         Just wanted to update you on this - I've got a very (basic)
>>>         version of gtk+ up and running. Display, mouse and key
>>>         events should work to a limited extent. There is no support
>>>         for key modifiers or more complicated keys yet. I've also
>>>         disabled support for crossing events as Mir seems to send
>>>         mir_motion_event_hover_exit as soon as a mouse button is
>>>         pressed, which tends to confuse the toolkit (as I've
>>>         experienced in the past ...). I've also noticed that the
>>>         display lags a bit behind the input - I suspect this is
>>>         because frame clock support is also unimplemented, so we are
>>>         probably doing a buffer swap at the wrong point in the paint
>>>         cycle.
>>>
>>>         https://github.com/smspillaz/gtk/commits/wip/mir
>>>
>>>         Anyways, its something to look at (or submit pull requests!)
>>>         if you want.
>>>
>>>         Thanks for doing the initial work on this.
>>>
>>>         Sam.
>>>
>>>
>>>         On Thu, Aug 8, 2013 at 7:32 PM, Leslie Zhai
>>>         <[email-masked] <mailto:[email-masked]>> wrote:
>>>
>>>             Hi Sam,
>>>
>>>             You are welcome :) OK, I will git push to
>>>             https://github.com/gnome/gtk
>>>
>>>>             Hi Leslie,
>>>>
>>>>             Excellent. What I'd suggest doing instead of creating a
>>>>             new repo is instead creating a fork of
>>>>             https://github.com/gnome/gtk so that changes will be
>>>>             tracked on head (and not on a divergent branch).
>>>>
>>>>             I haven't pushed my changes anywhere primarily because
>>>>             there's nothing particularly interesting  - just gdk
>>>>             with a copypasted wayland backend with s/wayland/mir at
>>>>             the moment. It might make sense for me to work on your
>>>>             branch directly.
>>>>
>>>>             As for cursor and device support - I don't think that
>>>>             this is particularly fatal to any kind of Mir work. It
>>>>             should be possible to just function as though there is
>>>>             only a single input device at the moment. Cursor
>>>>             support can probably also easily be a no-op. I don't
>>>>             think there is a case in gdk for retrieving the cursor
>>>>             image from the server.
>>>>
>>>>             I'll look into it a bit more later tonight. Thanks :)
>>>>
>>>>             Sam.
>>>>
>>>>
>>>>             On Thu, Aug 8, 2013 at 2:14 PM, Leslie Zhai
>>>>             <[email-masked] <mailto:[email-masked]>>
>>>>             wrote:
>>>>
>>>>                 Hi Sam, github repos
>>>>                 https://github.com/xiangzhai/gtk-mir
>>>>                 May I know your github link :)
>>>>
>>>>
>>>>                     Sam,
>>>>
>>>>                     I paused due to there is no cursor nor device
>>>>                     in Mir concept, but Wayland has it.
>>>>                     I want to team up and work on this together :)
>>>>                     I can learn a lot of things from you and other
>>>>                     Linux geeks!
>>>>
>>>>                     1. yes, there is only cairo-gl, but we could
>>>>                     follow the Mir client examples about EGL
>>>>                     2. yes, we need to remove all Wayland code :)
>>>>                     3. ok, I will create the repos under my github
>>>>                     https://github.com/xiangzhai
>>>>
>>>>                         Hey Leslie,
>>>>
>>>>                         I saw on mir-devel that you were hacking on
>>>>                         a mir gdk backend. I actually started
>>>>                         looking into this last night and then
>>>>                         noticed just now that you've started doing
>>>>                         this. (Actually, I took the same approach
>>>>                         of copypasting the wayland backend).
>>>>
>>>>                         Were you still working on this. I was
>>>>                         wondering if you wanted to team up and work
>>>>                         on this together.
>>>>
>>>>                         Some open questions:
>>>>
>>>>                         1. I've noticed that you're creating an EGL
>>>>                         context on the mir surface as soon as its
>>>>                         created. This seems strange to me as gdk
>>>>                         has no egl rendering backend (asides from
>>>>                         perhaps cairo-gl, which is not enabled by
>>>>                         default). Would it be easier to
>>>>                         software-backed buffers for this purpose
>>>>                         (similar to wayland?)
>>>>                         2. There are some references to wayland
>>>>                         structs still in the code, I imagine these
>>>>                         should be removed
>>>>                         3. The code is hosted on launchpad. Would
>>>>                         it be easier to host it on github for
>>>>                         easier mergability back into upstream gdk?
>>>>
>>>>                         Sam.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>             -- 
>>>>             Sam Spilsbury
>>>
>>>
>>>
>>>
>>>         -- 
>>>         Sam Spilsbury
>>
>>
>>
>>
>>     -- 
>>     Sam Spilsbury
>
>
>
>
> -- 
> Sam Spilsbury

---

From: Daniel van Vugt <[email-masked]>
Date: Thu, 22 Aug 2013 13:35:46 +0800

Looking good. And for those who might be wondering, I believe that GTK 
without a theme loaded is meant to look like that :)

---

From: Leslie Zhai <[email-masked]>
Date: Thu, 22 Aug 2013 13:47:57 +0800

Hi Daniel,

LOOOOOOONG time no see, I came back to "just for fun" world from BIZ DEV 
shortly :|

If there is mir-recordmydesktop or screenshot client demo, I will not 
need to take the photoshot with my mobile phone :)

Leslie

Linux Deepin Business Developer

---

From: Sam Spilsbury <[email-masked]>
Date: Thu, 22 Aug 2013 14:06:15 +0800

Oops, it seems like this went on-list a little earlier than I had expected.

Those looking to try this out can find it here[1]. You can configure and
install the backend by passing the --enable-mir-backend switch to the
configure script and enable it at runtime by running with the
GDK_BACKEND=mir environment variable set.

The backend is not yet complete - there are still some remaining issues,
notably:
 1. There is a condition where the event cycle can get out of sync with the
paint cycle, leading to a visible input lag. I'm not so sure what causes
this yet.
 2. Rendering to Mir surfaces is still quite inefficient. GDK does not
appear to have any concept of backbuffer age so we need to render to an
intermediate client-allocated cairo surface so that we can copy the entire
surface contents to the incoming Mir GraphicsRegion. Backbuffer age support
should be something that can be implemented in the backend itself, however
doing so is not a high priority right now.
 3. Client side decorations are not enabled by default. They can be enabled
by setting the environment variable GTK_CSD to a nonzero value.
 4. Support for keyboard modifiers and non-ascii keysyms is not yet
implemented.
 5. Mir does not have a concept that is parallel to X11's LeaveNotify /
EnterNotify. It has mir_surface_motion_hover_enter and
mir_surface_motion_hover_exit. However, these are tied more closely to
touch events on Android, where motion_hover_enter and motion_hover_exit
will be generated upon exiting the "hover" state and entering the
"clicking" state. Generating GDK_ENTER_NOTIFY and GDK_LEAVE_NOTIFY in these
cases will cause GDK to think that the pointer is no longer in the window,
which causes numerous interactions to fail silently. I've discussed this
with Thomas and hopefully we will come up with some solution. In the
interim, we are ignoring hover_exit events and instead generating
GDK_LEAVE_NOTIFY for "prior" surfaces on hover_enter.

Best Regards,

Sam

[1] https://github.com/smspillaz/gtk/tree/wip/mir