Skip to content

Get OS window handle ID #3219

Closed
Closed

Description

@omrilitov

There doesn't seem to be a way to get the id provided by the OS for the window. For example, on Windows there is a window hwnd and it can be used on some win api to manipulate the window.
Is there any known way of doing that?

Activity

  1. zcbenz commented on Oct 27, 2015

    @zcbenz
    Contributor

    There is no data type in JavaScript can represent a native handle, we can probably add an API to return a v8::External or node::Buffer which contains an external pointer to the handle of native window, and then users can receive the handle by writing a native module.

  2. omrilitov commented on Oct 27, 2015

    @omrilitov
    ContributorAuthor

    It looks fair to say GetAcceleratedWidget() in native_window_views.cc returns the window handle on the windows part.
    Is there a known equivalent in osx/linux?

  3. zcbenz commented on Oct 27, 2015

    @zcbenz
    Contributor

    GetAcceleratedWidget() also works on Linux. On OS X it should be the window_ member of NativeWindowMac.

  4. omrilitov commented on Oct 27, 2015

    @omrilitov
    ContributorAuthor

    Will start working on a pull request 👍
    v8 is not my strongest part, from your experience, is there a preference between v8::External and node:buffer?

  5. zcbenz commented on Oct 27, 2015

    @zcbenz
    Contributor

    node-ffi uses node::Buffer to store external pointers, it also used v8::External and v8::Object in the past, so I guess node::Buffer works the best.

  6. skreborn commented on Jan 4, 2016

    @skreborn

    @zcbenz @omrilitov Any updates on this? I am actually in the need of this feature. Thanks!

    [ Edit ] It seems to me that using an (unsigned) integer big enough to hold a pointer (even on a 64bit machine) would suffice, as the relevant type AcceleratedWidget is already defined as either a pointer (OS_WIN, OS_IOS, OS_MACOSX, OS_ANDROID) or an integer (USE_X11, USE_OZONE).

    I understand that this may not hold true for any and all native handles you might expose at a later stage (although I can't come up with an actual example), and see how making such handles uniformly be stored as Buffers would help standardize them and make them future proof, but I would still like your opinion on this.

  7. omrilitov commented on Jan 6, 2016

    @omrilitov
    ContributorAuthor

    Unsigend integer would not suffice as explained here #3256 (comment).
    Stroring the pointer in a buffer is a pattern already being used in the pull request mentioned above.
    I actually started working on the pull request which should have been simple, but encountered unexpected problems.
    I had some difficulties finding time to keep working on it, but I will soon.
    @skreborn You are more then welcome to help with it if you'd like 😄

  8. skreborn commented on Jan 6, 2016

    @skreborn

    @omrilitov Okay, fair point about the inability to guarantee V8's inner workings, so a Buffer might just be the better choice. I would love to help out, although right now I have no idea how to do that.

    Also, doesn't GetAcceleratedWidget work on all platforms? If not, why not? Haven't had the time to check out the code regarding this. The type of value it returns (AcceleratedWidget) is defined for most (if not all) supported platforms.

  9. omrilitov commented on Jan 6, 2016

    @omrilitov
    ContributorAuthor

    It does work on all platforms, I actually don't know how to explain the weird behavior.
    If you want you can start by looking at the last commit in my fork https://github.com/omrilitov/electron, the basics are there.
    Hopefully in the next days I'll find some time to work on it.

  10. omrilitov commented on Jan 11, 2016

    @omrilitov
    ContributorAuthor

    Added in #4023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions