ui icon indicating copy to clipboard operation
ui copied to clipboard

Change window position

Open mainrs opened this issue 8 years ago • 17 comments

Is it somehow possible to change the window position? Every time I call the show method, my window is in the bottom left corner beneath other windows. I Would really like to bring it to the front into the center.

mainrs avatar Jun 27 '16 14:06 mainrs

There is in libui; it will be added to Go after alpha 4. Are you on OS X?

andlabs avatar Jun 27 '16 14:06 andlabs

Ye.Would really like to do it somehow from golang

mainrs avatar Jun 27 '16 14:06 mainrs

The window not being on top thing is intentional; it works that way so as to not break app bundles. If you run from within an app bundle or through some other Launch Services means, the window will appear on top like normal. See this for details.

andlabs avatar Jun 27 '16 14:06 andlabs

There is in libui

Is it somehow possible to call it in ui (the go project)?

mainrs avatar Jun 27 '16 15:06 mainrs

If you build libui from source, you can replace the static objects and ui.h file, then add a SetPosition() (and Center()) to window.go.

andlabs avatar Jun 27 '16 15:06 andlabs

May I ask how you create the other static object files for windows or linux? Would you update the ui dependency to libui? Looks like you use some build scripts. Quite new to the go and c world. I mainly write in Java and never used make before. I get errors all over the place.

mainrs avatar Jun 27 '16 15:06 mainrs

Please see https://github.com/andlabs/libui/issues/127#issuecomment-231081446

andlabs avatar Jul 07 '16 13:07 andlabs

It's darn inconvenient that the window starts up in OS X right down the bottom left of the screen, instead of in the middle of the screen like every other app. I there a reason why you chose the bottom left for the starting position? Wrapping it in an app bundle doesn't help the unusual positioning issue, and from what I can find, there's no way in the bundle to give an alternate window position.

norganna avatar Aug 03 '16 08:08 norganna

Because OS X doesn't have a concept of a default position chosen by the OS, so right now it just uses (0, 0). Does every program start centered? If so I can also start centered.

andlabs avatar Aug 03 '16 10:08 andlabs

Not every program starts centred I don't think, but it's quite a substantial amount more common than any other position. I've certainly never seen an app that starts at 0,0.

I actually think when you're creating the traditional application in xcode, it defaults to an approximately centered position, and you can adjust it if you want, but most people just leave it where it suggests.

norganna avatar Aug 03 '16 12:08 norganna

Yes. It's that position I'm not sure about. I suppose I can just auto-center new windows on OS X since the OS doesn't provide any other facility for default placement other than "absolute screen coordinates".

andlabs avatar Aug 03 '16 13:08 andlabs

Just to not forget it, there is a patch here that puts window on a better place on macOS, following Java AWT's setLocationByPlatform.

ebraminio avatar Jun 28 '17 09:06 ebraminio

Just ran into this, too. Would be brillant if the window could be centered. :)

philiplb avatar May 19 '18 22:05 philiplb

Centered as default seems good default. Ideally to be settable on the window struct window.SetPosition(x int, y int).

lunemec avatar Nov 28 '18 15:11 lunemec

Push and agree...

dertuxmalwieder avatar Mar 29 '20 18:03 dertuxmalwieder

This has been sitting for 4 years, what's the big deal? I'm sure there are at least a couple different merge buttons to pick from, that can each fix this problem in one click.

edit: Sorry, wrong issue, this is so confusing. The correct issue would be on the libui repo

~~edit 2: It looks like libui has a uiWindowCenter function.. so is this solved or not? I'm confused now~~

edit 3: Okay, so those functions were removed. Nevermind.

LoganDark avatar Aug 22 '20 22:08 LoganDark

Hi @andlabs, Is there any plan to fix this issue?

pstuashiqcse avatar Jan 26 '21 06:01 pstuashiqcse