Git Product home page Git Product logo

Comments (10)

 avatar commented on August 29, 2024

I think the best solution is either a cargo feature for version 1.5 (which is enabled by default to prevent from breaking semver) or a separate struct which omits the new functions. I've been wanting to update x11-dl to version 3 by generating code from the C headers, but I still have some planning to do. I'm a little worried about the compile time and generated code size of x11-dl, and I'm trying to find a solution to this as well as some other problems in the meantime.

from x11-rs.

jwilm avatar jwilm commented on August 29, 2024

Version 2.4 was never published to crates.io; seems like there shouldn't be any semver issue. I'm inclined to not have default features as much as possible having watched hyper/iron struggle with openssl as a default feature. Any intermediate dependencies which don't opt-out of default features force the defaults to be enabled downstream.

The separate struct is an interesting idea. It seems that gl-rs has used that idea extensively to the point that individual functions can be loaded without triggering any other dlopens.

from x11-rs.

 avatar commented on August 29, 2024

It would be nice and ergonomic to lazily load functions as they're called from static function wrappers like you can do with gl-rs. I'm definitely considering this for version 3. I would like a way to query whether a function is available to handle cases where some are missing without having a thread panic in order to find out. This would probably make it unnecessary to even have the static bindings anymore.

from x11-rs.

jwilm avatar jwilm commented on August 29, 2024

There's some discussion about version based feature flags on the rust user forum with regards to ffi bindings. ilogiq suggested using a built script to set feature flags based on the available binary. Sounds like a reasonable idea here.

from x11-rs.

 avatar commented on August 29, 2024

Since this hasn't been done in x11-rs before, would you prefer the recently added functions to be behind a feature gate or in a separate struct?

It appears that these are the functions that have been added between the version in Ubuntu 14.04 and the current version in Arch:

  • XRRAllocateMonitor
  • XRRDeleteMonitor
  • XRRFreeMonitors
  • XRRGetMonitors
  • XRRSetMonitor

from x11-rs.

jwilm avatar jwilm commented on August 29, 2024

I think the separate struct makes the most sense. The program can then be compiled with support for all of them, and then we can fail at runtime on systems that don't have the newer symbols.

from x11-rs.

 avatar commented on August 29, 2024

I've opened a pull request #39, but I'd like your thoughts on it before I merge it. It's a little hacky, but it will only be a temporary solution until x11-rs v3.

Edit: The new struct is x11_dl::xrandr::Xrandr_2_2_0. The version number is taken from the binary version rather than the library version.

from x11-rs.

 avatar commented on August 29, 2024

ba6ae5c

from x11-rs.

 avatar commented on August 29, 2024

@jwilm

Before I go through with v3, I'd like to wait until untagged unions are available in stable Rust. But I thought of another solution to this problem that may be cleaner for v2 and wouldn't require a separate struct for Xrandr 1.4.2. A cargo feature, probably called lazy, could be added to x11-dl. Enabling this feature would enable lazy initialization of library functions, so they're not loaded until they're called. Unused functions would never be loaded, and this would help backwards compatibility for all X11 libraries without much added complexity. In order to keep the crate compatible with versions that have xrandr::Xrandr_2_2_0, this can be changed to an alias of xrandr::Xrandr. What are your thoughts on this? Do you know of any potential problems this would cause?

In addition, the library structs can have a method along the lines of xrandr.check_function("XRRAllocateMonitor") to see if a function is available without panicking.

Edit: One potential edge case that may cause a problem is if anyone is taking the library functions by reference. Changing them to lazy functions would change them from extern function pointers to struct methods, which would only cause problems in some weird hypothetical case.

from x11-rs.

rightfold avatar rightfold commented on August 29, 2024

Has this issue been resolved? I am still getting the error "undefined symbol: XRRAllocateMonitor" when creating an X11 event loop using libxrandr 1.4.2.

from x11-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.