Giter Club home page Giter Club logo

Comments (5)

Osspial avatar Osspial commented on June 28, 2024

So, there's been a bit of back-and-forth recently about whether or not to expose HINSTANCE in RawWindowHandle::Windows. An HINSTANCE is basically a handle to the application the window was created with. I was initially opposed to doing that, since similarly to ns_view it can be derived from the hwnd, but I've recently changed my mind about it. Exposing it isn't too much of a stretch, and it seems to give downstream users peace of mind when they don't have to reach into the platform-specific documentation to get a field they need to initialize a vulkan surface or whatever it is they need to do. After all, understanding the platform-specific APIs is largely the job of the people abstracting around the windowing APIs. I feel like ns_view is in a similar sort of territory.

If somebody submits a PR adding ns_view_controller and ns_window_controller, I'll probably accept them. If not, stuff will remain as-is. I don't think there's any harm in exposing a little bit more than necessary, and I don't really feel like engaging in an argument about it, since it's mostly a matter of "what design principles do you think matter most".

from raw-window-handle.

thomcc avatar thomcc commented on June 28, 2024

I don't know if I really agree, as this leaves more room for bugs caused by implementers of the RawWindowHandle trait, but it's not really my call to make.

If you're keeping it, I strongly feel that the documentation should note which view it is precisely. as it is, it's just some view associated with the window. The contentView is probably the most obvious choice, but isn't the only one. (Additionally, if a user happens to hear they need to pass the window's contentView into something, they probably will have to look up and verify that the view they have is the contentView -- I would do this, at least).

It's also possibly worth noting that NSWindow are safe to use from whichever thread you want, but the NSView is a main-thread-only type (e.g. NSWindow is send, NSView isn't and also has a special relationship with the main thread). I don't know if this matters here, though -- probably not as MacOSHandle isn't send (admittedly, it not being send is not enough for it to be sound to use the NSView, but only unsafe code can do anything meaningful with it anyway, so that's possibly fine).

from raw-window-handle.

Osspial avatar Osspial commented on June 28, 2024

If you're keeping it, I strongly feel that the documentation should note which view it is precisely. as it is, it's just some view associated with the window. The contentView is probably the most obvious choice, but isn't the only one.

What sorts of bugs could happen as a result of not doing that? If users can associate multiple NSViews with a particular window, it seems useful to allow implementors to specify the exact view they're referring to. I'm not inclined to take that flexibility away without good reason.

from raw-window-handle.

wrl avatar wrl commented on June 28, 2024

Audio plugins on macOS receive (or are expected to return) an NSView * which is independent of any particular window and which will not necessarily (in fact, rarely) end up as the contentView.

Removing the NSView * would break our use case irreparably.

from raw-window-handle.

thomcc avatar thomcc commented on June 28, 2024

Removing the NSView * would break our use case irreparably.

Sold.

from raw-window-handle.

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.