LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-15-2010, 02:01 PM   #1
supravat
LQ Newbie
 
Registered: Jun 2009
Posts: 21

Rep: Reputation: 15
Arrow 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...
 
Old 07-15-2010, 02:16 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by supravat View Post
...
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.
 
Old 07-15-2010, 03:20 PM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Debian, Mint, Puppy, Raspbian
Posts: 3,433

Rep: Reputation: 203Reputation: 203Reputation: 203
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.
 
Old 07-15-2010, 04:09 PM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by bigearsbilly View Post
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
.

Last edited by Sergei Steshenko; 07-15-2010 at 04:16 PM.
 
Old 07-16-2010, 06:35 AM   #5
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Debian, Mint, Puppy, Raspbian
Posts: 3,433

Rep: Reputation: 203Reputation: 203Reputation: 203
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.

Last edited by bigearsbilly; 07-16-2010 at 06:36 AM. Reason: typo
 
Old 07-16-2010, 08:30 AM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Isn't it better to let the WM decide where it should go?
 
Old 07-16-2010, 08:52 AM   #7
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Debian, Mint, Puppy, Raspbian
Posts: 3,433

Rep: Reputation: 203Reputation: 203Reputation: 203
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.
 
Old 07-16-2010, 09:13 AM   #8
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by bigearsbilly View Post
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.
 
Old 07-16-2010, 09:15 AM   #9
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by MTK358 View Post
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.
 
Old 07-16-2010, 10:10 AM   #10
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Do special dialog windows appear in the middle of the desktop automatically?
 
Old 07-17-2010, 02:55 PM   #11
Hidden Windshield
Member
 
Registered: Jul 2010
Distribution: Fedora
Posts: 65

Rep: Reputation: 27
Quote:
Originally Posted by MTK358 View Post
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.

Last edited by Hidden Windshield; 07-17-2010 at 02:57 PM. Reason: Clarify that I'm talking about GTK.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help in GTK+ programming supravat Programming 4 06-01-2010 11:53 PM
GTK Programming Help bkd Programming 3 10-16-2006 06:15 PM
GTK programming linetnew Programming 1 10-12-2005 12:34 PM
GTK programming exvor Programming 10 07-11-2005 04:59 AM
Gtk programming geminigal Programming 2 05-11-2005 09:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration