Skip to content

Commit

Permalink
add gtk3 display source so we can use the X11 bindings with gtk3 code
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@6201 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 27, 2014
1 parent c637087 commit b7303f0
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 12 deletions.
30 changes: 19 additions & 11 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def get_status_output(*args, **kwargs):
client_ENABLED = True

x11_ENABLED = not WIN32 and not OSX
gtk_x11_ENABLED = not WIN32 and not OSX and not PYTHON3
gtk_x11_ENABLED = not WIN32 and not OSX
argb_ENABLED = True
gtk2_ENABLED = client_ENABLED and not PYTHON3
gtk3_ENABLED = PYTHON3
Expand Down Expand Up @@ -629,6 +629,7 @@ def pkgconfig(*pkgs_options, **ekw):
"xpra/x11/gtk_x11/constants.pxi",
"xpra/x11/gtk_x11/gdk_bindings.c",
"xpra/x11/gtk_x11/gdk_display_source.c",
"xpra/x11/gtk3_x11/gdk_display_source.c",
"xpra/x11/bindings/constants.pxi",
"xpra/x11/bindings/wait_for_x_server.c",
"xpra/x11/bindings/keyboard_bindings.c",
Expand Down Expand Up @@ -1179,16 +1180,23 @@ def cython_add(*args, **kwargs):

toggle_packages(gtk_x11_ENABLED, "xpra.x11.gtk_x11")
if gtk_x11_ENABLED:
#below uses gtk/gdk:
cython_add(Extension("xpra.x11.gtk_x11.gdk_display_source",
["xpra/x11/gtk_x11/gdk_display_source.pyx"],
**pkgconfig(*PYGTK_PACKAGES)
))
GDK_BINDINGS_PACKAGES = PYGTK_PACKAGES + ["xfixes", "xdamage"]
cython_add(Extension("xpra.x11.gtk_x11.gdk_bindings",
["xpra/x11/gtk_x11/gdk_bindings.pyx"],
**pkgconfig(*GDK_BINDINGS_PACKAGES)
))
if PYTHON3:
#GTK3 display source:
cython_add(Extension("xpra.x11.gtk3_x11.gdk_display_source",
["xpra/x11/gtk3_x11/gdk_display_source.pyx"],
**pkgconfig("gtk+-3.0")
))
else:
#below uses gtk/gdk:
cython_add(Extension("xpra.x11.gtk_x11.gdk_display_source",
["xpra/x11/gtk_x11/gdk_display_source.pyx"],
**pkgconfig(*PYGTK_PACKAGES)
))
GDK_BINDINGS_PACKAGES = PYGTK_PACKAGES + ["xfixes", "xdamage"]
cython_add(Extension("xpra.x11.gtk_x11.gdk_bindings",
["xpra/x11/gtk_x11/gdk_bindings.pyx"],
**pkgconfig(*GDK_BINDINGS_PACKAGES)
))


toggle_packages(argb_ENABLED, "xpra.codecs.argb")
Expand Down
10 changes: 9 additions & 1 deletion src/xpra/client/gtk3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# This file is part of Xpra.
# Copyright (C) 2013 Antoine Martin <[email protected]>
# Copyright (C) 2013, 2014 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

from xpra.log import Logger
log = Logger("gtk", "client")

try:
from xpra.x11.gtk3_x11 import gdk_display_source
except Exception, e:
log.warn("cannot import gtk3_x11 display source", exc_info=True)
4 changes: 4 additions & 0 deletions src/xpra/x11/gtk3_x11/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is part of Xpra.
# Copyright (C) 2014 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.
49 changes: 49 additions & 0 deletions src/xpra/x11/gtk3_x11/gdk_display_source.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This file is part of Xpra.
# Copyright (C) 2014 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.


# This class simply hooks the current GDK display into
# the core X11 bindings.

from xpra.x11.bindings.display_source cimport set_display
from xpra.x11.bindings.display_source import set_display_name


###################################
# Headers, python magic
###################################
cdef extern from "X11/Xlib.h":
ctypedef struct Display:
pass

cdef extern from "gtk-3.0/gdk/gdk.h":
pass

cdef extern from "gtk-3.0/gdk/gdktypes.h":
ctypedef struct GdkDisplay:
pass

cdef extern from "gtk-3.0/gdk/gdkdisplay.h":
GdkDisplay *gdk_display_get_default()

cdef extern from "gtk-3.0/gdk/gdkx.h":
Display *gdk_x11_display_get_xdisplay(GdkDisplay *display)
const char *gdk_display_get_name(GdkDisplay *display)


def init_gdk_display_source():
cdef GdkDisplay* gdk_display
cdef Display * x11_display
from gi.repository import Gdk
#this next line actually ensures Gdk is initialized, somehow
root = Gdk.get_default_root_window()
assert root is not None, "could not get the default root window"
#now we can get a display:
gdk_display = gdk_display_get_default()
x11_display = gdk_x11_display_get_xdisplay(gdk_display)
set_display(x11_display)
set_display_name(gdk_display_get_name(gdk_display))

init_gdk_display_source()

0 comments on commit b7303f0

Please sign in to comment.