Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for XCB surfaces via xcffib #37

Closed
wants to merge 1 commit into from
Closed

Conversation

tych0
Copy link
Contributor

@tych0 tych0 commented Jun 19, 2014

Hi, I'm in the process of rewriting xpyb, so xcffib is unreleased but nearing a 0.1 release. I'd be happy to tag something if it means that you'd be more comfortable merging this :-)

@SimonSapin
Copy link
Member

Thanks for contributing! I’d like to see a few things before merging this, though:

@SimonSapin
Copy link
Member

mkconstants.py is generally not run on the user’s system, it’s only used during development of cairocffi itself to generate constants.py. (I just moved it into utils/ to reflect this. You’ll have to adapt your PR, sorry.) Therefore, it should not have conditional code: whether xcffib is available when mkconstants.py runs is unrelated to whether it’s available when cairocffi is used.

It’s only at run-time that we should detect availability and fall back. I think cairocffi/pixbuf.py has a good way to do this.

Also, rather than having an entire class in a tryexcept block, I’d rather have a cairocffi.xcb module that requires xcffib (again, like cairocffi/pixbuf.py).

@flacjacket
Copy link
Contributor

I have problems trying to run with this with the addition of CAIRO_STATUS_JBIG2_GLOBAL_MISSING, since I have cairo 1.12.16, while that isn't added [1] until 1.13. The error I get is:

bin/libqtile/__pycache__/_cffi__x25ffa352x2cba2200.c: In function ‘_cffi_e_enum__cairo_status’:
bin/libqtile/__pycache__/_cffi__x25ffa352x2cba2200.c:1879:8: error: ‘CAIRO_STATUS_JBIG2_GLOBAL_MISSING’ undeclared (first use in this function)
   if ((CAIRO_STATUS_JBIG2_GLOBAL_MISSING) < 0 || (unsigned long)(CAIRO_STATUS_JBIG2_GLOBAL_MISSING) != 38UL) {

[1] http://cgit.freedesktop.org/cairo/commit/?id=5c0caa6f82374ec38a33d5f25a725f60bc121887

@SimonSapin
Copy link
Member

@flacjacket could you provide steps to reproduce this issue?

@flacjacket
Copy link
Contributor

Well, I get that trying to run a WIP version of qtile using cairocffi and xcbffi. The file in question causing the problem is here https://github.com/tych0/qtile/blob/cffi/libqtile/pangocffi.py

@flacjacket
Copy link
Contributor

Actually, I've worked out a more simple test case (tho it is not related to this PR, as doing this with travis, which has cairo 1.10.2, throws the same error but with many more undeclared values):

from cffi import FFI
import cairocffi

ffi = FFI()

ffi.include(cairocffi.ffi)

C = ffi.verify("""
    #include <xcb/xcbext.h>
    #include <cairo/cairo.h>
    #include <cairo/cairo-pdf.h>
    #include <cairo/cairo-ps.h>
    #include <cairo/cairo-svg.h>
""")

I don't know if this is a bug here, or a problem with using cffi, as the cairocffi docs has an example of doing simple pangocairo [1] and uses ffi.dlopen(...). While that works for that simple case, it doesn't allow additional cdef's to be verified.

[1] https://pythonhosted.org/cairocffi/cffi_api.html#example-using-pango-through-cffi-with-cairocffi

@SimonSapin
Copy link
Member

@flacjacket, this is unrelated to this PR, please open a separate issue.

But, shortly: It is a very deliberate choice to use dlopen rather than verify in cairocffi so that users do not need to have a C compiler correctly configured to find cairo headers, which can be tricky especially on Windows. I don’t know if CFFI supports mixing dlopen and verify in the same FFI instance.

@tych0
Copy link
Contributor Author

tych0 commented Aug 3, 2014

Going to close this in favor of #39.

@tych0 tych0 closed this Aug 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants