<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>x11 — jd:/dev/blog</title><description>Posts tagged &quot;x11&quot; on jd:/dev/blog.</description><link>https://julien.danjou.info/</link><item><title>Logitech Unifying devices support in UPower</title><link>https://julien.danjou.info/blog/logitech-unifying-upower/</link><guid isPermaLink="true">https://julien.danjou.info/blog/logitech-unifying-upower/</guid><description>A few months ago, I wrote about my reverse engineering attempt to Logitech Unifying devices . Back then, I concluded my post with big hopes on the future after receiving a document with some part of t</description><pubDate>Fri, 16 Nov 2012 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;A few months ago, &lt;a href=&quot;https://julien.danjou.info/blog/logitech-k750-linux-support&quot;&gt;I wrote about my reverse engineering attempt to Logitech Unifying devices&lt;/a&gt;. Back then, I concluded my post with big hopes on the future after receiving a document with some part of the specification of the HID++ 2.0 from Logitech.&lt;/p&gt;
&lt;p&gt;A couple of weeks ago, some of my summer work has been merged to &lt;a href=&quot;http://upower.freedesktop.org/&quot;&gt;UPower&lt;/a&gt;, adding battery support for some Logitech devices.&lt;/p&gt;
&lt;h2&gt;HID++&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://julien.danjou.info/content/images/03/m705.jpg&quot; alt=&quot;m705&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As I discovered late in my first reverse engineering attempt, Logitech developed a custom HID protocol named HID++. This protocol exists in two versions, 1.0 and 2.0. Some devices talk with version 1 of the protocol (like my M705 mouse) and some others talk with version 2 of the protocol (like my K750 keyboard).&lt;/p&gt;
&lt;p&gt;Recently, I&apos;ve been able to be in touch with a Logitech engineer who worked on the Linux support for the Unifying receiver, and he has been really helpful and exposed me some details about this protocol.&lt;/p&gt;
&lt;p&gt;Logitech made the decision to publish their HID++ specification publicly about a year ago, but still didn&apos;t do it. The internal review needed to publish such documents hasn&apos;t be done yet. The &lt;a href=&quot;http://6xq.net/git/lars/lshidpp.git/plain/doc/logitech_hidpp_2.0_specification_draft_2012-06-04.pdf&quot;&gt;only published draft&lt;/a&gt; is just an extract of the specification, with even some typo in it as I discovered.&lt;/p&gt;
&lt;p&gt;Some &lt;a href=&quot;https://drive.google.com/?tab=mo&amp;amp;pli=1&amp;amp;authuser=0#folders/0BxbRzx7vEV7eWmgwazJ3NUFfQ28&quot;&gt;other documents&lt;/a&gt; have been recently published, but I didn&apos;t have the time to review them. They contains HID++ 1.0 specifications and some details I asked for about the K750 keyboard.&lt;/p&gt;
&lt;h2&gt;UPower support&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://julien.danjou.info/content/images/03/upower-1.png&quot; alt=&quot;upower-1&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It took me sometime to get a full understanding of the protocol, its different version etc. After reverse engineering my K750 keyboard, I&apos;ve also reverse engineered the data stream used to get my M705 mouse battery status. I&apos;ve also received some information about the HID++ 1.0 protocol, so I&apos;ve been able to discover a bit more on what the packets mean. Most of my discoveries are now used to do proper &lt;code&gt;#define&lt;/code&gt; in &lt;a href=&quot;http://cgit.freedesktop.org/upower/tree/src/linux/up-device-lg-unifying.c&quot;&gt;&lt;code&gt;up-lg-unifying.c&lt;/code&gt;&lt;/a&gt; so the code makes more sense.&lt;/p&gt;
&lt;p&gt;My &lt;a href=&quot;http://cgit.freedesktop.org/upower/commit/?id=2f03ad62b520fc5c02e3ff9eb5bffc4275eb88dc&quot;&gt;first patch&lt;/a&gt; implements a new property for UPower devices, named &lt;em&gt;luminosity&lt;/em&gt;, that use with K750 keyboard to report the light level received. The &lt;a href=&quot;http://cgit.freedesktop.org/upower/commit/?id=95184593504bca5240ecd296db98954decd2c5a5&quot;&gt;second patch&lt;/a&gt; add support for Logitech Unifying devices (over USB only) and should work with at least Logitech M705 and K750 devices. This should be available with the next version of UPower, which should be 0.9.19.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://julien.danjou.info/content/images/03/gnome-power-statistics-k750.png&quot; alt=&quot;gnome-power-statistics-k750&quot; /&gt;&lt;/p&gt;
&lt;p&gt;So far, Logitech has been kind enough to help me understanding part of the protocol and even sent me a few devices so I can play and test my work with them. Unfortunately, this will probably requires some work and time, and so far Logitech was not able to help with that.&lt;/p&gt;
&lt;p&gt;There should be enough information out there to at least add support for battery to HID++ 2.0 devices, and probably a few other things too. I hope I&apos;d get the time do this at some point, but feel free to beat me in this race!&lt;/p&gt;
</content:encoded><category>x11</category><category>linux</category></item><item><title>xpyb 1.3 released</title><link>https://julien.danjou.info/blog/xpyb-1-3/</link><guid isPermaLink="true">https://julien.danjou.info/blog/xpyb-1-3/</guid><description>It took a while to get it out, but finally, 3 years after the latest release (1.2), the version of 1.3 of xpyb (the XCB Python bindngs) is out.</description><pubDate>Thu, 22 Mar 2012 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;It took a while to get it out, but finally, 3 years after the latest release (1.2), the version of 1.3 of &lt;a href=&quot;http://cgit.freedesktop.org/xcb/xpyb/&quot;&gt;xpyb&lt;/a&gt; (the &lt;a href=&quot;http://xcb.freedesktop.org&quot;&gt;XCB&lt;/a&gt; Python bindngs) is out.&lt;/p&gt;
&lt;p&gt;This version has a lot of improvement, and major bug fixes (memory corruption and memory leak were tracked down and fixed).&lt;/p&gt;
&lt;p&gt;One amazing feature that is now shipped with that release, is &lt;a href=&quot;https://julien.danjou.info/blog/python-cairo-and-xcb-support&quot;&gt;my code to export the xpyb API to other Python modules&lt;/a&gt;, allowing to draw with &lt;a href=&quot;http://www.cairographics.org/pycairo/&quot;&gt;Pycairo&lt;/a&gt; in Python using XCB.&lt;/p&gt;
&lt;p&gt;Here is an example of a Python program that draws a spiral in a window using xpyb and Pycairo. You need xpyb &amp;gt;= 1.3 and Pycairo &amp;gt;= 1.10 to make this works.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import cairo
import xcb
from xcb.xproto import *

WIDTH, HEIGHT = 600, 600

def draw_spiral(ctx, width, height):
    &quot;&quot;&quot;Draw a spiral with lines!&quot;&quot;&quot;
    wd = .02 * width
    hd = .02 * height

    width -= 2
    height -= 2

    ctx.move_to (width + 1, 1-hd)
    for i in range(9):
        ctx.rel_line_to (0, height - hd * (2 * i - 1))
        ctx.rel_line_to (- (width - wd * (2 *i)), 0)
        ctx.rel_line_to (0, - (height - hd * (2*i)))
        ctx.rel_line_to (width - wd * (2 * i + 1), 0)

    ctx.set_source_rgb (0, 0, 1)
    ctx.stroke()

## Connect to the X server
conn = xcb.connect()
## Get the X server setup
setup = conn.get_setup()
## Generate X ID for our X &quot;objects&quot;
window = conn.generate_id()
pixmap = conn.generate_id()
gc = conn.generate_id()
## Create a new window
conn.core.CreateWindow(setup.roots[0].root_depth, window,
                       # Parent is the root window
                       setup.roots[0].root,
                       0, 0, WIDTH, HEIGHT, 0, WindowClass.InputOutput,
                       setup.roots[0].root_visual,
                       CW.BackPixel | CW.EventMask,
                       [ setup.roots[0].white_pixel, EventMask.ButtonPress | EventMask.EnterWindow | EventMask.LeaveWindow | EventMask.Exposure ])

## Create a pixmap: it will be used to draw with cairo
conn.core.CreatePixmap(setup.roots[0].root_depth, pixmap, setup.roots[0].root,
                       WIDTH, HEIGHT)

## We just need a GC to copy later the pixmap on the window, so create one
## very simple
conn.core.CreateGC(gc, setup.roots[0].root, GC.Foreground | GC.Background,
                   [ setup.roots[0].black_pixel, setup.roots[0].white_pixel ])

## Create a cairo surface
surface = cairo.XCBSurface (conn, pixmap,
                            setup.roots[0].allowed_depths[0].visuals[0], WIDTH, HEIGHT)
## Create a cairo context with that surface
ctx = cairo.Context(surface)

## Paint everything in white
ctx.set_source_rgb (1, 1, 1)
ctx.set_operator (cairo.OPERATOR_SOURCE)
ctx.paint()

## Draw our spiral
draw_spiral (ctx, WIDTH, HEIGHT)

## Map the window on the screen so it gets visible
conn.core.MapWindow(window)

## Flush all X requests to the X server
conn.flush()

while True:
    try:
        event = conn.wait_for_event()
    except xcb.ProtocolException, error:
        print &quot;Protocol error %s received!&quot; % error.__class__.__name__
        break
    except:
        break

    # ExposeEvent are received when we need to refresh the content of the
    # window, so we copy the content of the pixmap (where cairo drew) in the
    # window
    if isinstance(event, ExposeEvent):
        conn.core.CopyArea(pixmap, window, gc, 0, 0, 0, 0, WIDTH, HEIGHT)
    # You click, I quit.
    elif isinstance(event, ButtonPressEvent):
        break
    conn.flush()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Seeing the complexity it is to draw something simple with this technology, I somehow understand why nobody bothered to release or use the code during the last 3 years.&lt;/p&gt;
&lt;p&gt;But hey, now that it&apos;s out, you can build the next Python based desktop environment with bleeding edge technologies. :-)&lt;/p&gt;
</content:encoded><category>x11</category><category>python</category></item><item><title>Google Calendar notifications using pynotify</title><link>https://julien.danjou.info/blog/google-calendar-pynotify/</link><guid isPermaLink="true">https://julien.danjou.info/blog/google-calendar-pynotify/</guid><description>I use Google Calendar to manage my calendars, and I really missed something to warn me whenever I have an appointment with an alert set.</description><pubDate>Tue, 03 Jan 2012 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I use &lt;a href=&quot;http://google.com/calendar&quot;&gt;Google Calendar&lt;/a&gt; to manage my calendars, and I really missed something to warn me whenever I have an appointment with an alert set.&lt;/p&gt;
&lt;p&gt;So here is an example of a Python program to do such a thing. It is written using the &lt;a href=&quot;http://code.google.com/p/gdata-python-client/&quot;&gt;Google Data APIs Python client library&lt;/a&gt; and pynotify.&lt;/p&gt;
&lt;p&gt;I&apos;ll detail the code here, so you can build your own and adapt it to your needs.&lt;/p&gt;
&lt;p&gt;First, we need to import GTK+ and pynotify, and initialize it.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import gtk
import pynotify
pynotify.init(sys.argv[0])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then, we need to import gdata Calendar API and connect to the calendar. I&apos;ll use the simple email/password way to login, which is clearly not the best, but it&apos;s also the simplest. Feel free to use OAuth 2.0. :-)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;calendar_service = gdata.calendar.service.CalendarService()
calendar_service.email = &apos;mygooglelogin&apos;
calendar_service.password = &apos;mygooglepassword&apos;
calendar_service.ProgrammaticLogin()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we&apos;re ready to request stuff and notify! First, request the events from the default calendar.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;feed = calendar_service.GetCalendarEventFeed()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we can iterate over &lt;em&gt;feed&lt;/em&gt; and do various checks.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for event in feed.entry:
    # If the event status is not confirmed, go to the next event.
    if event.event_status.value != &quot;CONFIRMED&quot;:
        continue
    # Now iterate over all the event dates (usually it has one)
    for when in event.when:
        # Parse start and end time
        try:
            start_time = datetime.datetime.strptime(when.start_time.split(&quot;.&quot;)[0], &quot;%Y-%m-%dT%H:%M:%S&quot;)
            end_time = datetime.datetime.strptime(when.end_time.split(&quot;.&quot;)[0], &quot;%Y-%m-%dT%H:%M:%S&quot;)
        except ValueError:
            # ValueError happens on parsing error. Parsing errors
            # usually happen for &quot;all day&quot; events since they have
            # not time, but we do not care about this events.
            continue
        now = datetime.datetime.now()
        # Check that the event hasn&apos;t already ended
        if end_time &amp;gt; now:
            # Check each alert
            for reminder in when.reminder:
                # We handle only reminders with method &quot;alert&quot;
                # and whose start time minus the reminder delay has passed
                if reminder.method == &quot;alert&quot; \
                        and start_time - datetime.timedelta(0, 60 * int(reminder.minutes)) &amp;lt; now:
                    # Build the notification
                    notification = pynotify.Notification(summary=event.title.text,
                                                         message=event.content.text)
                    # Set an icon from the GTK+ stock icons
                    notification.set_icon_from_pixbuf(gtk.Label().render_icon(gtk.STOCK_DIALOG_INFO,
                                                                              gtk.ICON_SIZE_LARGE_TOOLBAR))
                    notification.set_timeout(0)
                    # Show the notification
                    notification.show()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Running this program, you should see a notification if an appointment has an alert to be raised at that time.&lt;/p&gt;
&lt;p&gt;This should be enough to start to build something.&lt;/p&gt;
&lt;p&gt;If you don&apos;t want to program this into Python, you might want to take a look at &lt;a href=&quot;http://code.google.com/p/gcalcli/wiki/HowTo&quot;&gt;gcalcli&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>python</category><category>x11</category><category>google</category></item><item><title>Using GTK+ stock icons with pynotify</title><link>https://julien.danjou.info/blog/python-notify-with-gtk-stock-icon/</link><guid isPermaLink="true">https://julien.danjou.info/blog/python-notify-with-gtk-stock-icon/</guid><description>It took me a while to find this, so I&apos;m just blogging it so other people will be able to find it.</description><pubDate>Tue, 27 Dec 2011 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;It took me a while to find this, so I&apos;m just blogging it so other people will be able to find it.&lt;/p&gt;
&lt;p&gt;I wanted to send a &lt;a href=&quot;http://www.galago-project.org/specs/notification/&quot;&gt;desktop notification&lt;/a&gt; using pynotify, but using a &lt;a href=&quot;http://developer.gnome.org/gtk/2.24/gtk-Stock-Items.html&quot;&gt;GTK+ stock icons&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;With the following snippet, I managed to do it.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import pynotify
pynotify.init(&quot;myapp&quot;)
import gtk
n = pynotify.Notification(summary=&quot;Summary&quot;, message=&quot;Message!&quot;)
n.set_icon_from_pixbuf(gtk.Label().render_icon(gtk.STOCK_HARDDISK, gtk.ICON_SIZE_LARGE_TOOLBAR))
n.show()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the use of a &lt;em&gt;Label&lt;/em&gt; is just to have a widget instanciated to use the &lt;em&gt;render_icon()&lt;/em&gt; method. It could be any widget type as far as I understand.&lt;/p&gt;
</content:encoded><category>python</category><category>x11</category></item><item><title>Porting D-Bus to XCB: story of a failure</title><link>https://julien.danjou.info/blog/porting-dbus-on-xcb/</link><guid isPermaLink="true">https://julien.danjou.info/blog/porting-dbus-on-xcb/</guid><description>Even if I recently stated I lost some of my faith in XCB, I still sometimes hack things to add support for it.</description><pubDate>Thu, 29 Jul 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Even if &lt;a href=&quot;https://julien.danjou.info/blog/thoughts-and-rambling-on-the-x-protocol&quot;&gt;I recently stated I lost some of my faith&lt;/a&gt; in &lt;a href=&quot;http://xcb.freedesktop.org&quot;&gt;XCB&lt;/a&gt;, I still sometimes hack things to add support for it.&lt;/p&gt;
&lt;p&gt;These last days, I&apos;ve worked on a &lt;a href=&quot;http://dbus.freedesktop.org&quot;&gt;D-Bus&lt;/a&gt; port from Xlib to XCB. The port was quite straight forward, since there&apos;s only a little piece of D-Bus using X, which is &lt;code&gt;dbus-launch&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I though D-Bus was a good candidate, since it&apos;s part of the &lt;a href=&quot;http://www.freedesktop.org&quot;&gt;Freedesktop&lt;/a&gt; initiative. Therefore, I was expecting a warm welcome and some enthusiasm from a fellow project.&lt;/p&gt;
&lt;p&gt;My contribution got one useful review, and a &lt;a href=&quot;http://lists.freedesktop.org/archives/dbus/2010-July/013185.html&quot;&gt;cold reply from Thiago Macieira&lt;/a&gt; (a &lt;a href=&quot;http://www.kde.org&quot;&gt;KDE&lt;/a&gt;/&lt;a href=&quot;http://qt.nokia.com&quot;&gt;Qt&lt;/a&gt;/&lt;a href=&quot;http://www.nokia.com&quot;&gt;Nokia&lt;/a&gt; developer):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;No, sorry, I don&apos;t agree..&lt;br /&gt;
I&apos;ve just checked and my Solaris machine doesn&apos;t have XCB.&lt;br /&gt;
Please do not remove the X11 code. You may &lt;em&gt;add&lt;/em&gt; the XCB code, but you cannot remove the X11 code.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is not really the kind of answer I expected, actually. I then reworked the code to &lt;a href=&quot;http://lists.freedesktop.org/archives/dbus/2010-July/013192.html&quot;&gt;please Thiago&lt;/a&gt;, and added some &lt;em&gt;#ifdef&lt;/em&gt; to add XCB support to D-Bus, with a fallback to libx11 where XCB would not be available.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://lists.freedesktop.org/archives/dbus/2010-July/013196.html&quot;&gt;Havoc Pennington replied&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Given that libX11 now uses xcb as backend, I don&apos;t understand the&lt;br /&gt;
value of porting to use libxcb directly when there isn&apos;t an issue of&lt;br /&gt;
round trips or other stuff. It will just make #ifdef hell, while the&lt;br /&gt;
X11 API is an API that works on both xcb and non-xcb platforms.&lt;br /&gt;
Maybe people should be thinking about porting xcb to non-Linux&lt;br /&gt;
platforms? The X protocol should be the same on other UNiX, so xcb in&lt;br /&gt;
theory ought to work fine if you just compiled it on Solaris/BSD, same&lt;br /&gt;
as GTK or dbus or Qt would work fine.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The last part &quot;Maybe people should be thinking about porting xcb to non-Linux platforms?&quot; is still unclear to me, even though &lt;a href=&quot;http://lists.freedesktop.org/archives/dbus/2010-July/013197.html&quot;&gt;I asked Havoc to explain what he meant&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Finally, &lt;a href=&quot;http://lists.freedesktop.org/archives/dbus/2010-July/013198.html&quot;&gt;Thiago refused to merge the patch&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;[…] thanks for the patch, but like Havoc I am unsure of the value. We can&apos;t&lt;br /&gt;
drop the X11 codepaths now because too many systems exist without&lt;br /&gt;
XCB. Adding the XCB codepaths only made it more complex, even though you did a good job.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I can&apos;t disagree with that conclusion: using both XCB and X11 make the code unreadable for little gain. That&apos;s why I did replace libx11 by XCB directly in the first version of the patch. On the other hand, D-Bus people does not seems to really care about making their software evolve in the right direction, even if that requires users to upgrade their systems.&lt;/p&gt;
&lt;p&gt;I think D-Bus using and depending on XCB would have been a good point to push adoption of XCB. Unfortunately, it seems you can&apos;t even rely of projects of the same initiative (i.e. Freedesktop) to work together to make things a little bit better.&lt;/p&gt;
&lt;p&gt;After 5 years of existence, XCB is still not so obvious to people, and making it adopt is going to be a challenge for the next years. The upside is that &lt;a href=&quot;http://www.x.org/wiki/Releases/7.6&quot;&gt;new X.org 7.6 will bring XCB with it&lt;/a&gt;, as part of the katamari.&lt;/p&gt;
</content:encoded><category>linux</category><category>x11</category></item><item><title>Desktop notification support for Emacs</title><link>https://julien.danjou.info/blog/desktop-notification-support-for-emacs/</link><guid isPermaLink="true">https://julien.danjou.info/blog/desktop-notification-support-for-emacs/</guid><description>This last weeks, I&apos;ve worked on implementing the Desktop Notification Specification into Emacs.</description><pubDate>Wed, 09 Jun 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This last weeks, I&apos;ve worked on implementing the &lt;a href=&quot;http://www.galago-project.org/specs/notification/&quot;&gt;Desktop Notification Specification&lt;/a&gt; into &lt;a href=&quot;http://www.gnu.org/software/emacs/&quot;&gt;Emacs&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It allows sending desktop notification in a very simple way.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(notifications-notify
    :title &quot;You&apos;ve got mail!&quot;
    :body &quot;There&apos;s 34 mails unread&quot;
    :app-icon &quot;~/.emacs.d/icons/mail.png&quot;
    :urgency &apos;low)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It supports the protocol signals (&lt;code&gt;NotificationClosed&lt;/code&gt; and &lt;code&gt;ActionInvoked&lt;/code&gt;) and the two main methods (&lt;code&gt;Notify&lt;/code&gt; and &lt;code&gt;CloseNotification&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;The methods specification are implemented entirely (hints, replaces, actions, icon, etc).&lt;/p&gt;
&lt;p&gt;The signals are supported via callbacks function provided on the notification creation.&lt;/p&gt;
&lt;p&gt;It have been merged into Emacs trunk today.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;2010-06-09  Julien Danjou  &amp;lt;julien@danjou.info&amp;gt;

	* net/notifications.el: New file.

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This also allowed me to discover, raise and fix a &lt;a href=&quot;http://lists.gnu.org/archive/html/emacs-devel/2010-06/msg00228.html&quot;&gt;bug&lt;/a&gt; in the D-Bus binding of Emacs, which will be probably fixed in trunk soon.&lt;/p&gt;
</content:encoded><category>emacs</category><category>x11</category></item><item><title>Thoughts and rambling on the X protocol</title><link>https://julien.danjou.info/blog/thoughts-and-rambling-on-the-x-protocol/</link><guid isPermaLink="true">https://julien.danjou.info/blog/thoughts-and-rambling-on-the-x-protocol/</guid><description>Two years ago, while working on awesome, I joined the Freedesktop initiative to work on XCB. I had to learn the arcane of the X11 protocol and all the mysterious and old world that goes with it.</description><pubDate>Tue, 01 Jun 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Two years ago, while working on &lt;a href=&quot;http://awesome.naquadah.org&quot;&gt;awesome&lt;/a&gt;, I joined the &lt;a href=&quot;http://www.freedesktop.org&quot;&gt;Freedesktop&lt;/a&gt; initiative to work on &lt;a href=&quot;http://xcb.freedesktop.org&quot;&gt;XCB&lt;/a&gt;. I had to learn the arcane of the X11 protocol and all the mysterious and old world that goes with it.&lt;/p&gt;
&lt;p&gt;Now that I&apos;ve swum all this months in this mud, I just feel like I need to share my thoughts about what become a mess over the decades.&lt;/p&gt;
&lt;h2&gt;When I was unborn…&lt;/h2&gt;
&lt;p&gt;…the &lt;a href=&quot;http://en.wikipedia.org/wiki/Toto_(band)&quot;&gt;Toto&lt;/a&gt; band were releasing their &lt;a href=&quot;http://en.wikipedia.org/wiki/Africa_(Toto_song)&quot;&gt;song &quot;Africa&quot;&lt;/a&gt; and some smart guys were working on a windowing system: the X Window System (this is its full name) which therefore has a (too) long history. The latest version of its protocol, the 11th one, has been designed in the 80&apos;s. You can learn more about the history in the &lt;a href=&quot;http://en.wikipedia.org/wiki/X_Window_System&quot;&gt;Wikipedia article about X&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In 2010, we still listen disco music and we still use various protocols designed in the 80&apos;s and even before X. Music have evolved, protocols have evolved, and so did X11.&lt;/p&gt;
&lt;p&gt;The problem is that X11 did not evolve that well. The guys at MIT-and-some other-places-with-very-smart-people-in-it created X version 1 in 1984, and updated it until X version 11 (the one we&apos;re still using) in 1987. Eleven version in 3 years, that was following the &quot;release early, release often&quot; model. But I don&apos;t know why, it just stopped to happen for the last 23 years (that&apos;s not totally true: they added (and then deprecated) many extensions.)&lt;/p&gt;
&lt;p&gt;I don&apos;t know what changes have been made in the first 11 major versions of the X protocol, but I&apos;m rather sure we should have deserve a couple of major version updates this last 2 decades.&lt;/p&gt;
&lt;p&gt;In my humble opinion, X11 was not designed to live 23 years. But hey, I&apos;m not blaming anyone here: I was 4 years old and playing Lego® when they released this latest version of the X protocol, so there is little chance I&apos;d have done something better.&lt;/p&gt;
&lt;h2&gt;We won&apos;t fix. We&apos;ll work-around.&lt;/h2&gt;
&lt;p&gt;That is probably one of the guideline of the X protocol for the last years. And don&apos;t misread me: I&apos;m not bashing anyone thereafter.&lt;/p&gt;
&lt;p&gt;Since the X11 protocol was aging, the X guys started to add &lt;a href=&quot;http://en.wikipedia.org/wiki/X_Window_System_protocols_and_architecture#Extensions&quot;&gt;extensions&lt;/a&gt;. They added tons of them over the years. This, in application of one of &lt;a href=&quot;http://en.wikipedia.org/wiki/X_Window_System_protocols_and_architecture#Design_principles&quot;&gt;the early principles of X&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;It is as important to decide what a system is not as to decide what it&lt;br /&gt;
is. Do not serve all the world&apos;s needs; rather, make the system extensible&lt;br /&gt;
so that additional needs can be met in an upwardly compatible fashion.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;All of them with no exception were added because, bad luck, the X11 protocol did not anticipated the things that happened in the last 23 years, like video, OpenGL, multiple monitors, or the pleasure to draw oval windows. Some of this extensions are still in use, while some of them have been dropped.&lt;/p&gt;
&lt;p&gt;While this is not a bad thing to extends the protocol, it seems like a bad thing to try to fix the protocol with for example the &lt;a href=&quot;http://en.wikipedia.org/wiki/XFixes&quot;&gt;XFixes extension&lt;/a&gt;, even with all the good intentions Keith Packard might have in his greatness.&lt;/p&gt;
&lt;h2&gt;Actually it&apos;s even worst than you think&lt;/h2&gt;
&lt;p&gt;The X11 protocol (without extensions) defines about 120 types of requests: create a window, move a window, etc.&lt;/p&gt;
&lt;p&gt;Nowadays, there&apos;s at least 25 % of them which are useless: usage of server-side font, or the drawing of squares and polygon, are unused by any modern application or toolkit. All of this is superseded by requests from extensions, like the &lt;a href=&quot;http://en.wikipedia.org/wiki/XRender&quot;&gt;XRender&lt;/a&gt; one.&lt;/p&gt;
&lt;p&gt;The handling of multiple monitors displays has totally been screwed up. X11 has been designed to work in &lt;a href=&quot;http://en.wikipedia.org/wiki/Zaphod_Beeblebrox#Cultural_references&quot;&gt;Zaphod&lt;/a&gt; mode (independent monitors). But &lt;a href=&quot;http://en.wikipedia.org/wiki/Xinerama&quot;&gt;Xinerama&lt;/a&gt;, and nowadays &lt;a href=&quot;http://en.wikipedia.org/wiki/XRandR&quot;&gt;XRandR&lt;/a&gt; have replaced it up: recent X servers (released after ~2007) does not support Zaphod mode anymore, even if it&apos;s a core piece of the X11 protocol.&lt;/p&gt;
&lt;p&gt;Worst: on many requests, there&apos;s limitation or design flaws, like described in this document: &lt;a href=&quot;http://www.std.org/~msm/common/protocol.pdf&quot;&gt;Why X Is Not Our Ideal Window System&lt;/a&gt; by DEC researchers.&lt;/p&gt;
&lt;h2&gt;We&apos;ll add more broken standard on top of that&lt;/h2&gt;
&lt;p&gt;Following &lt;a href=&quot;http://en.wikipedia.org/wiki/X_Window_System_protocols_and_architecture#Design_principles&quot;&gt;its early principle&lt;/a&gt;, X does not define policies but only mechanisms, which seems like a good thing,&lt;/p&gt;
&lt;p&gt;Consequently, people started writing specifications to determine a number of stuff and dogmas: &lt;a href=&quot;http://en.wikipedia.org/wiki/ICCCM&quot;&gt;ICCCM&lt;/a&gt;. That was 22 years ago in 1988. It&apos;s useless to add that many things in this specification are now obsolete, useless, or that it misses many modern stuff.&lt;/p&gt;
&lt;p&gt;I was not the only one to think that. The people from what will be the major desktop environments, &lt;a href=&quot;http://www.kde.org&quot;&gt;KDE&lt;/a&gt; and &lt;a href=&quot;http://www.gnome.org&quot;&gt;GNOME&lt;/a&gt;, saw that too in the 90&apos;s while I was learning to count. So they wrote &lt;a href=&quot;http://en.wikipedia.org/wiki/Extended_Window_Manager_Hints&quot;&gt;EWMH&lt;/a&gt;, another standard that comes on top of ICCCM and extends it with nifty features like maximization, full screen mode, etc.&lt;/p&gt;
&lt;p&gt;The problem is that this standard has also been written by narrow-minded people who at that time, were working on GNOME or KDE (and maybe others). This desktop environments were having and still have some strong concepts of how should work a desktop: &quot;it should have work-spaces&quot;, &quot;a window is only on one workspace&quot;, &quot;we only see a workspace at a time&quot;, &quot;you do not have multiple screens&quot;, etc.&lt;/p&gt;
&lt;h2&gt;Dude, we don&apos;t care: we have toolkits!&lt;/h2&gt;
&lt;p&gt;This vision of how the desktop should work have now been written in marble in all applications and libraries implementing EWMH, like &lt;a href=&quot;http://www.gtk.org&quot;&gt;GTK+&lt;/a&gt; or &lt;a href=&quot;http://qt.nokia.com&quot;&gt;Qt&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Nowadays, everybody forgot about all of this standards. Toolkits have implemented this, circumvented the X11 protocol limitation and flaws, and nobody wants to look back.&lt;/p&gt;
&lt;p&gt;Like all standards, obviously some people implemented them badly. This had some side effects, like &lt;a href=&quot;https://julien.danjou.info/blog/openoffice-better-as-a-pager&quot;&gt;OpenOffice acting like a pager&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;We don&apos;t look back? Worst, we forgot where we came from!&lt;/h2&gt;
&lt;p&gt;With all these layers of bad designed standards, the desktop continued to evolve for more than a decade. They continued to add more standard, the more recent ones being based on D-Bus like the &lt;a href=&quot;http://www.galago-project.org/specs/notification/&quot;&gt;Desktop Notification Specification&lt;/a&gt; or the latest &lt;a href=&quot;http://www.notmart.org/misc/statusnotifieritem/index.html&quot;&gt;Status Notifier Specification&lt;/a&gt; developed by KDE.&lt;/p&gt;
&lt;p&gt;The Status Notifier is a new implementation of the good old system tray based on &lt;a href=&quot;http://en.wikipedia.org/wiki/D-Bus&quot;&gt;D-Bus&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/XEmbed&quot;&gt;XEmbed&lt;/a&gt; instead of the X11 mechanisms, and adding the possibility to show the system tray with something else than icons.&lt;/p&gt;
&lt;p&gt;This specification draft saw an important issue and design flaw raised by Wolfgang Draxinger in &lt;a href=&quot;http://lists.freedesktop.org/archives/xdg/2010-May/011516.html&quot;&gt;this thread on the XDG mailing-list&lt;/a&gt;. What Wolfgang points out, is that X is network-oriented, and D-Bus is not. Therefore, making the Status Notifier specification to use D-Bus to pass system tray messages around is a bad idea, since running a X application from host A on host B will draw the system tray on the wrong host!&lt;/p&gt;
&lt;p&gt;Apparently, reading the thread, this &lt;a href=&quot;http://lists.freedesktop.org/archives/xdg/2010-May/011531.html&quot;&gt;does not fear some of the KDE people&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;of course this is a bizarre corner case not worth much thought. at least&lt;br /&gt;
that&apos;s what you&apos;ll think until you actually run into it yourself (be it&lt;br /&gt;
because you are testing something or because you are setting up some&lt;br /&gt;
weird kiosk environment).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;What Oswald describes as a corner case is an actual common use case for many of us. Of course, YMMV.&lt;/p&gt;
&lt;p&gt;From my point of view, this is a step back in the wrong direction. But we can conclude that the network part of X is now worthless, to at least KDE.&lt;/p&gt;
&lt;h2&gt;I used to believe in XCB&lt;/h2&gt;
&lt;p&gt;When I joined Freedesktop, it was to work on XCB, the X C Binding. XCB is a nice, clean, 21st century technology based API to play with the X11 protocol. Its code is auto generated based on XML file describing the protocol.&lt;/p&gt;
&lt;p&gt;In comparison, Xlib is 80&apos;s obfuscated code with almost no comments and hard-coded things. Only a few people can understand some of its corner like its i18n or XKB implementations. And all its code is &lt;em&gt;synchronous&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;For people not knowing it yet, X is a network protocol where you send request (like a GET in HTTP) and then get a response. Xlib forces the application to wait for the reply to its request, so the application is blocked until the X server sends the reply to the request. XCB on the other hand does not block and allows the application to send a batch of requests, do some other stuff in the mean time, and then gets the replies.&lt;/p&gt;
&lt;p&gt;It&apos;s like your Web browser would send one request at a time to a Web server, and would wait until you downloaded all the images one by one to display the page.&lt;/p&gt;
&lt;p&gt;In cases where X and all its clients are on the same host, the latency is small and not really visible, therefore the gain for XCB to be asynchronous is small. On slow network however, the gain can be huge, as proved in the &lt;a href=&quot;http://bugs.freedesktop.org/show_bug.cgi?id=4232&quot;&gt;rewrite of xlsclients with XCB by Peter Harris&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One of the long standing goal of the XCB folks is to kick-out Xlib, to increase speed and hides latency in X11 applications. That requires to port many libraries, because almost none of them (&lt;a href=&quot;http://www.cairographics.org&quot;&gt;Cairo&lt;/a&gt; being an exception) supports XCB.&lt;/p&gt;
&lt;p&gt;From where I stand, I don&apos;t really see if the work is worth it now. The desktop world is trusted by GNOME and KDE, meaning GTK+ and Qt. It seems none of this toolkits are interested to work on XCB, neither on the X protocol. They probably put hard effort in bypassing X limitation and flaws, and they now sit on top of crap of workarounds and broken-by-design-standard implementation. It seems to me they don&apos;t want to go back in the layers and improves things.&lt;/p&gt;
&lt;p&gt;They&apos;re too high to go back down and they don&apos;t see what the gain would be.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.enlightenment.org&quot;&gt;Enlightenment&lt;/a&gt; with its EFL was the first toolkit to have an XCB back-end with the work of Vincent Torri. Unfortunately, the back-end is not maintained and nobody cares about it. Last time I tried it, it did not compile at all.&lt;/p&gt;
&lt;h2&gt;X12?&lt;/h2&gt;
&lt;p&gt;There&apos;s a page called &lt;a href=&quot;http://www.x.org/wiki/Development/X12&quot;&gt;X12&lt;/a&gt; on the Freedesktop wiki, listing all the things that should be fixed some days. Unfortunately, the list continues to grow up an no one talks about working on X12.&lt;/p&gt;
&lt;p&gt;On the other hand, there&apos;s a handset of people trying to work when they will have time on &lt;a href=&quot;http://www.freedesktop.org/wiki/Software/XKeyboardConfig/XKB2Dreams&quot;&gt;XKB2&lt;/a&gt;, the second version of the &quot;let&apos;s-try-to-fix-up-the-keyboard-part-of-the-protocol-we-wrote-23-years-ago-a-second-time&quot; extension.&lt;/p&gt;
&lt;p&gt;To me, it does not seem X12 will happen in the next decade neither.&lt;/p&gt;
&lt;h2&gt;Alternative?&lt;/h2&gt;
&lt;p&gt;Do we got alternative to X? There&apos;s &lt;a href=&quot;http://en.wikipedia.org/wiki/Wayland_(display_server)&quot;&gt;Wayland&lt;/a&gt;, but it&apos;s far from being usable. There&apos;s &lt;a href=&quot;http://www.directfb.org/&quot;&gt;DirectFB&lt;/a&gt;, but that&apos;s not very portable. None seems candidate to replace X some days to me.&lt;/p&gt;
&lt;p&gt;Anyhow, none of the main toolkits around support this alternative. GTK+ once supported DirectFB, but as far as I know, it is not supported nor works nowadays, as stated by &lt;a href=&quot;http://np237.livejournal.com/27459.html&quot;&gt;Josselin Mouette&lt;/a&gt;. This is why recent versions of the Debian installer have migrated to X for the graphic part, thanks to Cyril Brulebois work.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;XCB has been around for more than half-a-decade, and very few people showed interested in it. As far as I can see, nobody is interested to use the X protocol and everybody tries to encapsulate it in some higher-level API as soon as possible to stop seeing it. This leads to poorly written application and toolkits, with a lot of ugly hack.&lt;/p&gt;
&lt;p&gt;All of that also means that starting to write applications and graphical toolkits based on XCB would be a very interesting project, but that would lead to spend too much time learning to circumvent the X protocol flaws, things that have been done in years by predecessors like Qt and GTK+.&lt;/p&gt;
&lt;p&gt;Major toolkits implementations have almost nothing to win in going back in the dark water of X. I guess most of their folks prefer to work on shiny 3D effects based on your GPS location, rather than redefining better basis for everyone.&lt;/p&gt;
&lt;p&gt;The manpower available in the X world is very small. Debian lacking of X maintainers is just the summit of that. There is very smart and very competent and skilled guys in the X world, as you can see by simply reading blog posts on &lt;a href=&quot;http://planet.freedesktop.org&quot;&gt;Planet Freedesktop&lt;/a&gt; for example (me excluded). Unfortunately, there&apos;s not enough of them to cover all the things involved in X: input devices, graphics devices, new protocol extension specification and so on. The X server is really late, and it seems most of the developers prefers to work on the server itself than on the protocol behalf. Which is understandable.&lt;/p&gt;
&lt;p&gt;I&apos;m curious to see where all of that will lead in the upcoming years. I&apos;ve been walking in the X world hallways for about 3 years now, and I feel desktop alternatives to KDE and GNOME will all die sooner or later. The time were you could choose between a dozen &quot;modern&quot; window managers has passed away.&lt;/p&gt;
&lt;p&gt;After all, maybe that is simply Darwinism applied to computer software.&lt;/p&gt;
</content:encoded><category>x11</category></item><item><title>Making startup-notification XCB native</title><link>https://julien.danjou.info/blog/making-startup-notification-xcb-native/</link><guid isPermaLink="true">https://julien.danjou.info/blog/making-startup-notification-xcb-native/</guid><description>I&apos;m trying to work on XCB this week. And today I&apos;ve started to accomplish the second step of a long term goal: making an X11 only library using XCB as its primary interface instead of Xlib.</description><pubDate>Mon, 24 May 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I&apos;m trying to work on XCB this week. And today I&apos;ve started to accomplish the second step of a long term goal: making an X11 only library using &lt;a href=&quot;http://xcb.freedesktop.org&quot;&gt;XCB&lt;/a&gt; as its primary interface instead of Xlib.&lt;/p&gt;
&lt;p&gt;Last year, I had extended the API of &lt;a href=&quot;http://www.freedesktop.org/wiki/Software/startup-notification&quot;&gt;startup-notification&lt;/a&gt; to support XCB as a back-end. This had been made possible by factorizing some code, duplicating the X11 code and translating it into equivalent XCB.&lt;/p&gt;
&lt;p&gt;Today, I&apos;ve accomplished the second step, being dropping the Xlib code inside startup-notification to keep only the XCB one.&lt;/p&gt;
&lt;p&gt;For this, I used the x11-xcb library, which is available when Xlib is compiled with XCB as its transport, which is nowadays the standard.&lt;/p&gt;
&lt;p&gt;This library provides the function &lt;code&gt;XGetXCBConnection&lt;/code&gt;, which can convert a &lt;code&gt;Display&lt;/code&gt; pointer to a &lt;code&gt;xcb_connection_t&lt;/code&gt; pointer. Consequently, it&apos;s now possible to write and execute XCB based code and being compatible with Xlib.&lt;/p&gt;
&lt;p&gt;I&apos;ve made some benchmark of my work for the occasion, in order to measure what the gain is.&lt;/p&gt;
&lt;p&gt;The first table described 1000 launches of a fake application (a modified version of the startup-notification test suite actually). The X server is local (the latency is very minimal then). The gain is computed between the same back-end type for the total time. &lt;strong&gt;Full XCB&lt;/strong&gt; is the &quot;version&quot; I&apos;m working on.&lt;/p&gt;
&lt;p&gt;Version - Back-end&lt;/p&gt;
&lt;p&gt;User time (seconds)&lt;/p&gt;
&lt;p&gt;Kernel time (seconds)&lt;/p&gt;
&lt;p&gt;Total time (seconds)&lt;/p&gt;
&lt;p&gt;Gain&lt;/p&gt;
&lt;p&gt;0.10 - libx11&lt;/p&gt;
&lt;p&gt;3.20&lt;/p&gt;
&lt;p&gt;7.42&lt;/p&gt;
&lt;p&gt;12.989&lt;/p&gt;
&lt;p&gt;-&lt;/p&gt;
&lt;p&gt;0.10 - libxcb&lt;/p&gt;
&lt;p&gt;2.76&lt;/p&gt;
&lt;p&gt;7.36&lt;/p&gt;
&lt;p&gt;12.414&lt;/p&gt;
&lt;p&gt;-&lt;/p&gt;
&lt;p&gt;Full XCB - libx11&lt;/p&gt;
&lt;p&gt;2.74&lt;/p&gt;
&lt;p&gt;7.50&lt;/p&gt;
&lt;p&gt;12.380&lt;/p&gt;
&lt;p&gt;4.6 %&lt;/p&gt;
&lt;p&gt;Full XCB - libxcb&lt;/p&gt;
&lt;p&gt;2.72&lt;/p&gt;
&lt;p&gt;7.16&lt;/p&gt;
&lt;p&gt;12.037&lt;/p&gt;
&lt;p&gt;3.0 %&lt;/p&gt;
&lt;p&gt;The user time and kernel time are provided but are not really interesting. XCB does not offers a big gain in CPU execution time, but is more about latency. Anyhow, there&apos;s always a gain with XCB.&lt;/p&gt;
&lt;p&gt;This second table describe the same test but running only 100 times over a slow network.&lt;/p&gt;
&lt;p&gt;Version - Back-end&lt;/p&gt;
&lt;p&gt;Total time (seconds)&lt;/p&gt;
&lt;p&gt;Gain&lt;/p&gt;
&lt;p&gt;0.10 - libx11&lt;/p&gt;
&lt;p&gt;76&lt;/p&gt;
&lt;p&gt;-&lt;/p&gt;
&lt;p&gt;0.10 - libxcb&lt;/p&gt;
&lt;p&gt;35&lt;/p&gt;
&lt;p&gt;-&lt;/p&gt;
&lt;p&gt;Full XCB - libx11&lt;/p&gt;
&lt;p&gt;72&lt;/p&gt;
&lt;p&gt;5.2 %&lt;/p&gt;
&lt;p&gt;Full XCB - libxcb&lt;/p&gt;
&lt;p&gt;33&lt;/p&gt;
&lt;p&gt;5.7%&lt;/p&gt;
&lt;p&gt;The gain is relatively small, about 5 %. But anyhow, there&apos;s still a gain. Note that the difference between the execution time of the same test written in XCB and Xlib is just huge. I&apos;ve tried to optimize the Xlib test, but I did not manage to win more seconds.&lt;/p&gt;
&lt;p&gt;In conclusion, considering that startup-notification is only used when an application launches another application, the perceivable gain might be even smaller. But anyhow, I think it&apos;s worth it.&lt;/p&gt;
</content:encoded><category>x11</category></item><item><title>Python cairo and XCB support</title><link>https://julien.danjou.info/blog/python-cairo-and-xcb-support/</link><guid isPermaLink="true">https://julien.danjou.info/blog/python-cairo-and-xcb-support/</guid><description>cairo has a Python binding (pycairo) since a long time, and some months ago a Python binding for XCB (xpyb) has been released.</description><pubDate>Tue, 22 Dec 2009 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;http://www.cairographics.org&quot;&gt;cairo&lt;/a&gt; has a &lt;a href=&quot;http://www.cairographics.org/pycairo/&quot;&gt;Python binding (pycairo)&lt;/a&gt; since a long time, and some months ago a &lt;a href=&quot;http://cgit.freedesktop.org/xcb/xpyb/&quot;&gt;Python binding for XCB (xpyb)&lt;/a&gt; has been released.&lt;/p&gt;
&lt;p&gt;Pycairo has no support for creating Xlib surfaces. You can get a Xlib surface from PyGTK and then use Pycairo to draw on it, but there&apos;s no way to create one directly.&lt;/p&gt;
&lt;p&gt;What I&apos;ve done is make Pycairo aware of xpyb so it can creates directly an XCB surface from a XCB connection and a drawable.&lt;/p&gt;
&lt;p&gt;As said in &lt;a href=&quot;http://lists.freedesktop.org/archives/xcb/2009-December/005438.html&quot;&gt;my mail to the XCB list&lt;/a&gt;, I&apos;m now waiting for a review before pushing this upstream. :-)&lt;/p&gt;
&lt;p&gt;For the first time, I guess, XCB has beaten Xlib support! ;-)&lt;/p&gt;
</content:encoded><category>python</category><category>x11</category></item><item><title>Various news: what happend during summer</title><link>https://julien.danjou.info/blog/various-news/</link><guid isPermaLink="true">https://julien.danjou.info/blog/various-news/</guid><description>It&apos;s been a while since I blogged about something. So here&apos;s a bunch of things I&apos;ve done the last month.  Holidays Well, I&apos;ve been in holidays one week. :-P  awesome There have been a huge number of c</description><pubDate>Tue, 22 Sep 2009 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;It&apos;s been a while since I blogged about something. So here&apos;s a bunch of things I&apos;ve done the last month.&lt;/p&gt;
&lt;h2&gt;Holidays&lt;/h2&gt;
&lt;p&gt;Well, I&apos;ve been in holidays one week. :-P&lt;/p&gt;
&lt;h2&gt;awesome&lt;/h2&gt;
&lt;p&gt;There have been a huge number of changes between 3.3 (released in June) and 3.4 (almost relesed). I wrote a small but very useful object layer on top of Lua, which adds a class/object system a bit like &lt;a href=&quot;http://www.gtk.org&quot;&gt;gobject&lt;/a&gt;. I&apos;ve also replaced all the hooks by per-class/object signals. Finally, the awesome Lua basement are cleaner than they were before, and the extendability is improved. How nice.&lt;/p&gt;
&lt;p&gt;We&apos;re trying to release 3.4 (rc2 should be out soon), but the development pace is a bit slower than a year before. We&apos;re basically almost 2 months late on what was our previous release rate. Not a big deal however.&lt;/p&gt;
&lt;p&gt;I&apos;ve started working on 3.5 slowly. It gonna get amazing new features too. :-)&lt;/p&gt;
&lt;h2&gt;Google Summer Of Code 2009&lt;/h2&gt;
&lt;p&gt;I&apos;ve mentored Mariusz Ceier on &lt;a href=&quot;http://xcb.freedesktop.org&quot;&gt;XCB&lt;/a&gt; GSoC. He worked on adding Xinput2 and XKB extensions. And he managed to do this. His work should be imported ASAP, the discussion has started on XCB maling list last week.&lt;/p&gt;
&lt;p&gt;In exchange, Google offered me (and to every mentor) an awful blue t-shirt! Thanks Google! :-P&lt;/p&gt;
</content:encoded><category>awesome</category><category>lua</category><category>x11</category></item><item><title>OpenOffice is better as a pager than as a text processor</title><link>https://julien.danjou.info/blog/openoffice-better-as-a-pager/</link><guid isPermaLink="true">https://julien.danjou.info/blog/openoffice-better-as-a-pager/</guid><description>Since several month, awesome users have reported a bug with OpenOffice.org. When using OOo and clicking on a menu, or using the mouse wheel to read a document, the currently selected tag (desktop).</description><pubDate>Wed, 11 Feb 2009 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Since several month, &lt;a href=&quot;http://awesome.naquadah.org&quot;&gt;awesome&lt;/a&gt; users have reported a bug with &lt;a href=&quot;http://www.openoffice.org&quot;&gt;OpenOffice.org&lt;/a&gt;. When using OOo and clicking on a menu, or using the mouse wheel to read a document, the currently selected tag (desktop) will change automagically to another one.&lt;/p&gt;
&lt;p&gt;I&apos;ve digged into awesome and found that awesome received a _NET_CURRENT_DESKTOP request. As defined by &lt;a href=&quot;http://standards.freedesktop.org/wm-spec/wm-spec-latest.html#id2550663&quot;&gt;EWMH&lt;/a&gt;,&lt;br /&gt;
this kind of request are sent by a pager to change the active desktop.&lt;/p&gt;
&lt;p&gt;That was weird. Nobody is using a pager here. So, I just kicked my gdb out, attached it to OOo, breaking on &lt;em&gt;XSendEvent&lt;/em&gt; call. And I got it:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Breakpoint 1, XSendEvent (dpy=0x1a00080, w=483, propagate=0, event_mask=1572864, event=0x7fff1fd70d70)
   at ../../src/SendEvent.c:46
(gdb) bt
#0  XSendEvent (dpy=0x1a00080, w=483, propagate=0, event_mask=1572864, event=0x7fff1fd70d70)
   at ../../src/SendEvent.c:46
#1  0x00007f8c0ab4193f in vcl_sal::WMAdaptor::switchToWorkArea ()
  from /usr/lib/openoffice/basis3.0/program/libvclplug_genlx.so
#2  0x00007f8c0aafdbd8 in X11SalFrame::Show ()
  from /usr/lib/openoffice/basis3.0/program/libvclplug_genlx.so
#3  0x00007f8c1378623c in Window::Show ()
  from /usr/lib/openoffice/program/../basis-link/program/libvcllx.so
#4  0x00007f8c13785f40 in Window::Show ()
  from /usr/lib/openoffice/program/../basis-link/program/libvcllx.so
#5  0x00007f8c1372cb54 in FloatingWindow::StartPopupMode ()
  from /usr/lib/openoffice/program/../basis-link/program/libvcllx.so
#6  0x00007f8c1373c877 in ?? () from /usr/lib/openoffice/program/../basis-link/program/libvcllx.so
#7  0x00007f8c1373ccf2 in ?? () from /usr/lib/openoffice/program/../basis-link/program/libvcllx.so
#8  0x00007f8c1373ce84 in ?? () from /usr/lib/openoffice/program/../basis-link/program/libvcllx.so
#9  0x00007f8c13795e7f in ?? () from /usr/lib/openoffice/program/../basis-link/program/libvcllx.so
#10 0x00007f8c13797e74 in ?? () from /usr/lib/openoffice/program/../basis-link/program/libvcllx.so
#11 0x00007f8c13796748 in ?? () from /usr/lib/openoffice/program/../basis-link/program/libvcllx.so
#12 0x00007f8c0aafe6f8 in X11SalFrame::HandleMouseEvent ()
  from /usr/lib/openoffice/basis3.0/program/libvclplug_genlx.so
#13 0x00007f8c0ab040c2 in X11SalFrame::Dispatch ()
  from /usr/lib/openoffice/basis3.0/program/libvclplug_genlx.so
#14 0x00007f8c0ab31625 in SalX11Display::Yield ()
  from /usr/lib/openoffice/basis3.0/program/libvclplug_genlx.so
#15 0x00007f8c0ab356f3 in ?? () from /usr/lib/openoffice/basis3.0/program/libvclplug_genlx.so
#16 0x00007f8c0ab2df1f in SalXLib::Yield () from /usr/lib/openoffice/basis3.0/program/libvclplug_genlx.so
#17 0x00007f8c135b050e in Application::Yield ()
  from /usr/lib/openoffice/program/../basis-link/program/libvcllx.so
#18 0x00007f8c135b0587 in Application::Execute ()
  from /usr/lib/openoffice/program/../basis-link/program/libvcllx.so
#19 0x00007f8c17517e80 in ?? () from /usr/lib/openoffice/program/../basis-link/program/libsofficeapp.so
#20 0x00007f8c135b4b24 in ?? () from /usr/lib/openoffice/program/../basis-link/program/libvcllx.so
#21 0x00007f8c135b4bc5 in SVMain () from /usr/lib/openoffice/program/../basis-link/program/libvcllx.so
#22 0x00007f8c1754ca6c in soffice_main ()
  from /usr/lib/openoffice/program/../basis-link/program/libsofficeapp.so
#23 0x000000000040105b in main ()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I started digging more into the code, and this is what I finally found in &lt;em&gt;salframe.cxx&lt;/em&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;        // #i45160# switch to desktop where a dialog with parent will appear
        if( mpParent &amp;amp;&amp;amp; mpParent-&amp;gt;m_nWorkArea != m_nWorkArea )
            GetDisplay()-&amp;gt;getWMAdaptor()-&amp;gt;switchToWorkArea(mpParent-&amp;gt;m_nWorkArea );
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Beautiful! It even has a comment with a IssueZilla bug number. Let&apos;s go and see where it comes from.&lt;/p&gt;
&lt;p&gt;After 10 minutes of research to find that fucking IZ, I finally found the link to the &lt;a href=&quot;http://www.openoffice.org/issues/show_bug.cgi?id=45160&quot;&gt;issue #45160&lt;/a&gt;. The bug is IMHO not related to OOo but to a window manager doing poor job.&lt;/p&gt;
&lt;p&gt;I&apos;ve found that an awesome user already reported an bug… err, wait, I mean an issue as &lt;a href=&quot;http://www.openoffice.org/issues/show_bug.cgi?id=96684&quot;&gt;issue #96684&lt;/a&gt; (remember there&apos;s no bug in OOo, only issues) and I commented about it.&lt;/p&gt;
&lt;p&gt;It seems OOo developers have agreed to fix that bug eventually.&lt;/p&gt;
</content:encoded><category>x11</category><category>awesome</category></item><item><title>startup-notification ported to XCB</title><link>https://julien.danjou.info/blog/startup-notification-ported-to-xcb/</link><guid isPermaLink="true">https://julien.danjou.info/blog/startup-notification-ported-to-xcb/</guid><description>Since Tuesday, I&apos;ve begun to work on XCB portage of the startup-notification library.</description><pubDate>Thu, 29 Jan 2009 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Since Tuesday, I&apos;ve begun to work on &lt;a href=&quot;http://xcb.freedesktop.org&quot;&gt;XCB&lt;/a&gt; portage of the &lt;a href=&quot;http://www.freedesktop.org/software/startup-notification/&quot;&gt;startup-notification&lt;/a&gt; library.&lt;/p&gt;
&lt;p&gt;I&apos;ve just completed the job, and &lt;a href=&quot;http://lists.freedesktop.org/archives/xdg/2009-January/010176.html&quot;&gt;send a bunch of patches to the XDG mailing list&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If the patches are merged, which I don&apos;t doubt, I&apos;ll be able to use this lib into &lt;a href=&quot;http://awesome.naquadah.org&quot;&gt;awesome&lt;/a&gt;, which would be nice step to the Freedesktop standard compliance I like to make.&lt;/p&gt;
</content:encoded><category>x11</category></item><item><title>Security bug found in Imlib2</title><link>https://julien.danjou.info/blog/security-bug-found-in-imlib2/</link><guid isPermaLink="true">https://julien.danjou.info/blog/security-bug-found-in-imlib2/</guid><description>Yeah, I&apos;m the proud discover of CVE-2008-5187.</description><pubDate>Sat, 22 Nov 2008 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Yeah, I&apos;m the proud discover of &lt;a href=&quot;http://www.securityfocus.com/bid/32371&quot;&gt;CVE-2008-5187&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It&apos;s my first time, it does mean something to me. ;-)&lt;/p&gt;
</content:encoded><category>security</category><category>x11</category></item><item><title>The eggtray problem</title><link>https://julien.danjou.info/blog/the-eggtray-problem/</link><guid isPermaLink="true">https://julien.danjou.info/blog/the-eggtray-problem/</guid><description>I still don&apos;t know why but many GTK+ applications use something called eggtrayicon. As far as I know, eggtrayicon.c is a file written in 2002 by Anders Carlsson which implements the Freedesktop.org sy</description><pubDate>Fri, 03 Oct 2008 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I still don&apos;t know why but many GTK+ applications use something called eggtrayicon. As far as I know, &lt;em&gt;eggtrayicon.c&lt;/em&gt; is a file written in 2002 by Anders Carlsson which implements the &lt;a href=&quot;http://standards.freedesktop.org/systemtray-spec/latest/&quot;&gt;Freedesktop.org system tray&lt;/a&gt; procotol for GTK+ applications.&lt;/p&gt;
&lt;p&gt;Problem is that this C file is used in dozens of programs and maybe more, and is a bit bugged. I&apos;ve already send patches for &lt;a href=&quot;http://www.nongnu.org/mailnotify/&quot;&gt;mail-notification&lt;/a&gt; and &lt;a href=&quot;http://audacious-media-player.org&quot;&gt;Audacious&lt;/a&gt;. &lt;a href=&quot;http://www.pidgin.im/&quot;&gt;pidgin&lt;/a&gt; is the first fixed implementation I found and works quite well. Many other applications are probably affected.&lt;/p&gt;
&lt;p&gt;That seems to me like a real problem. Multiple copy of bad code instead of using &lt;a href=&quot;http://library.gnome.org/devel/gtk/2.14/GtkStatusIcon.html&quot;&gt;native GTK+ system tray implementation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;So please stop using this bad implementation…&lt;/p&gt;
</content:encoded><category>x11</category></item><item><title>EWMH and XRandR</title><link>https://julien.danjou.info/blog/ewmh-and-xrandr/</link><guid isPermaLink="true">https://julien.danjou.info/blog/ewmh-and-xrandr/</guid><description>Today I decided to add some EWMH support to awesome. It now supports a bunch of this extensions quite nicely.</description><pubDate>Thu, 27 Dec 2007 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Today I decided to add some &lt;a href=&quot;http://en.wikipedia.org/wiki/EWMH&quot;&gt;EWMH&lt;/a&gt; support to &lt;a href=&quot;http://awesome.naquadah.org&quot;&gt;awesome&lt;/a&gt;. It now supports a bunch of this extensions quite nicely.&lt;/p&gt;
&lt;p&gt;However, while reading the &lt;a href=&quot;http://standards.freedesktop.org/wm-spec/wm-spec-1.4.html&quot;&gt;spec&lt;/a&gt; and writing the code, it appears that this forces a window manager to behave in only one way: have a poor desktop support, and no multi-head/XRandR/Xinerama support at all.&lt;/p&gt;
&lt;p&gt;The main caveats are that in Xinerama/XRandR mode, you&apos;ll have only one root window. And the root window is where you must store the NET_WM X properties… So you cannot handle screens in a independant way like &lt;em&gt;awesome&lt;/em&gt; does. That&apos;s really a shame.&lt;/p&gt;
&lt;p&gt;There&apos;s also a big problem for window managers like &lt;em&gt;awesome&lt;/em&gt; which are happy to draw several desktops at the same time. There&apos;s no support for stuff like that.&lt;/p&gt;
&lt;p&gt;So far, I think EWMH is nice but is really too narrow-minded for software and people who want to think window management in a different way.&lt;/p&gt;
</content:encoded><category>x11</category></item></channel></rss>