breach / thrust

Chromium-based cross-platform / cross-language application framework
MIT License
2.77k stars 121 forks source link

Launch window in different screen #235

Open lonelycode opened 9 years ago

lonelycode commented 9 years ago

Looked through the Window class and can't seem to find an API binding for setting a target screen for a new window, was wondering if it was possible?

droekm commented 9 years ago

How you mean:

setting a target screen

Please explain it a little more deeper :)

lonelycode commented 9 years ago

Ah, I mean that I have two monitors, and I would like the window to open on my second (non-primary) monitor instead of the first. Usually the window manager will handle this depending on mouse position, but it doesn't seem to in (tested in OSX or X-Windows).

BTW I was using the Go binding to test this out.

droekm commented 9 years ago

Basically you can try it for your own by setting an startup position (x, y) of the window. I am currently don't have installed an go env so I cannot show you how todo this, but I may think you can also do this in the main thrust source: https://github.com/breach/thrust/blob/master/src/browser/thrust_window.cc#L152

By using something like this: http://stackoverflow.com/questions/8706212/how-to-set-the-windows-default-position

lonelycode commented 9 years ago

Ah, yes I can confirm calling Move(x,y) does work in X-Windows, when I tried this in OSX it wouldn't but I think OSX handles multi-screen in a strange way.

Interestingly, when calling Move() it automatically maximises the window. Might be a bug in the golang-bindings though as they send an implicit size (I think), will raise it there.

Thanks!

droekm commented 9 years ago

Basically the move-function is here: https://github.com/miketheprogrammer/go-thrust/blob/e13e3d6b5f49b8cb4c45dc6a5769f7b4f2b98a44/window/window.go#L283

I am not a pro at Go, but If you know whats the problem there, please report it! ;)

lonelycode commented 9 years ago

Will do!

miketheprogrammer commented 9 years ago

@lonelycode @droekm And any other go devs please feel free to post issues to the go-thrust issue board, it is a seperately managed project. Also if you wish we have a gitter.im room as well that we are very active in. We are working as fast as possible to stabilize the project and provide improved current features as well as new features.

droekm commented 9 years ago

idea

(from scratch, only an idea)

Basically I think that we can create a new function like NewWindowOnSecScreen() or so. First we get the screen size (in example 2560x1440, means the size of Screen1+Screen2), then we divide the width (in example we get 1280). Then we set the Y point to 1280 and the X point to 0, for setting (hopefully) the startup position to the second screen in the top left corner. I don't have an second monitor, because I have an laptop so I don't can try this out, I also don't know if (basically on Windows) the screen size means of Screen1+Screen2 or only Screen1. It's an idea for current.

BTW: API binding for setting a target screen, I have looked up in some code of the chrome browser and I didn't find anything, but I think it would be great when an API/API binding for this exists.

lonelycode commented 9 years ago

There's a caveat with this - I ran into it while working with Kivy (NUI framework, python), we need to know the screen configuration before pushing the window. What I mean is, if the screens are beside one another, then the above will work, but if they are one on top of the other then you need to increment Y.

Also, often times the screen resolutions will not be homogeneous, (one smaller screen + one bigger one, or one vertical screen and one horizontal screen). Can be a real headache!

droekm commented 9 years ago

(one smaller screen + one bigger one, or one vertical screen and one horizontal screen) thats an heavy problem and is not easy todo. For current the best way is set the points manually for your screen, I hope anyone will lookup to this and helps here.

spolu commented 9 years ago

Depending on the platforms, there are APIs to detect screens, so we would have to look into that.

spolu commented 9 years ago

I'll reopen the issue and mark it as enhancement