LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 01: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, 01: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, 02:20 PM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
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, 03: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 03:16 PM.
 
Old 07-16-2010, 05:35 AM   #5
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
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 05:36 AM. Reason: typo
 
Old 07-16-2010, 07:30 AM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

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

Rep: Reputation: 239Reputation: 239Reputation: 239
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, 08: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, 08: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, 09:10 AM   #10
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

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

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 01:57 PM. Reason: Clarify that I'm talking about GTK.
 
  


Reply



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 10:53 PM
GTK Programming Help bkd Programming 3 10-16-2006 05:15 PM
GTK programming linetnew Programming 1 10-12-2005 11:34 AM
GTK programming exvor Programming 10 07-11-2005 03:59 AM
Gtk programming geminigal Programming 2 05-11-2005 08:07 PM

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

All times are GMT -5. The time now is 05:11 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
Open Source Consulting | Domain Registration