LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Gtk Programming (https://www.linuxquestions.org/questions/programming-9/gtk-programming-820027/)

supravat 07-15-2010 01:01 PM

Gtk Programming
 
I have created a window using gtk+ programming in Linux. But when I'm running the program the window is appearing any where of the screen i.e not a particular position of the screen. Is there any way or function so that window will always appear at the center of the screen ???

Please help me...

Sergei Steshenko 07-15-2010 01:16 PM

Quote:

Originally Posted by supravat (Post 4034320)
...
Please help me...

Read the documentation, looking for data/methods setting window position - they do exist. You will also need to know screen size in pixels - I vaguely remember that gtk+ has such functionality too. Anyway, that's secondary - first you need to know how to position the window, and you you know your screen resolution, so querying screen resolution can be dealt with later.

bigearsbilly 07-15-2010 02:20 PM

definitively, probably not.
it depends on the window manager.
the window manager can put the window wherever the hell it wants.

of course, I could be wrong.

unless you draw the window yourself of course,
but that's a horse of a different colour.

Sergei Steshenko 07-15-2010 03:09 PM

Quote:

Originally Posted by bigearsbilly (Post 4034460)
definitively, probably not.
it depends on the window manager.
the window manager can put the window wherever the hell it wants.

of course, I could be wrong.

unless you draw the window yourself of course,
but that's a horse of a different colour.

Try to enter

gtk+ set window position

into your favorite WEB search engine (I tried in Yahoo).
...
Better yet, try in Google

gtk+ set window position stie:www.gtk.org
.

bigearsbilly 07-16-2010 05:35 AM

true but the window manager doesn't have to honour the request.

Code:

GTK Window Position Constants

The Window Position constants specify hints for initial window placement.

I have an app which I programmed to go to the top right,
but I can force the position to anywhere via my sawfish matched windows.

MTK358 07-16-2010 07:30 AM

Isn't it better to let the WM decide where it should go?

bigearsbilly 07-16-2010 07:52 AM

well, I can see what the OP wants, and I have written an app that places
a window as I mentioned.
but the WM doesn't have to honour it, I was just warning of the
possibility.

Sergei Steshenko 07-16-2010 08:13 AM

Quote:

Originally Posted by bigearsbilly (Post 4035245)
well, I can see what the OP wants, and I have written an app that places
a window as I mentioned.
but the WM doesn't have to honour it, I was just warning of the
possibility.

Window position can be queried, and window can be moved. I think the two are sufficient to ultimately place a window where desired.

Sergei Steshenko 07-16-2010 08:15 AM

Quote:

Originally Posted by MTK358 (Post 4035230)
Isn't it better to let the WM decide where it should go?

No. For example, in gtk+ file selection dialog is a separate window, so from user's point of view it shouldn't be placed randomly on desktop.

MTK358 07-16-2010 09:10 AM

Do special dialog windows appear in the middle of the desktop automatically?

Hidden Windshield 07-17-2010 01:55 PM

Quote:

Originally Posted by MTK358 (Post 4035325)
Do special dialog windows appear in the middle of the desktop automatically?

In GTK at least, it's configurable. I always set my dialogs to center on their parent window, because that's what makes sense to me.

But like others have said, the window manager can override that if it wants to.


All times are GMT -5. The time now is 02:33 PM.