GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Jul 22, 2014 11:22 am

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Gtk equivalent for FindWindow, GetWindowRect, SetCursorPos?
PostPosted: Thu Jan 17, 2008 9:00 am 
Offline
Familiar Face

Joined: Thu Jan 17, 2008 8:50 am
Posts: 5
Hi,
Does anybody knows any equivalent in gtk for the Win32APIs FindWindow, GetWindowRect, SetCursorPos?

I am porting a Win32 application to Linux using gtk, so I need to get a handle to a window, the name of the handle I will be giving as Input, and then
I will have to get the x,y coordinates of that window and finally I have to move the mouse to that window...

by
Suresh


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 17, 2008 4:21 pm 
Offline
Familiar Face

Joined: Wed Jan 16, 2008 12:05 pm
Posts: 8
Location: Schaafheim - Frankfurt / Germany
Yes, there are equivalent to your listed callbacks from the WIN32 API, but not in GTK. You can find these callbacks at the X11-Api... I'am looking for them.

I'll tell you, when I have found anything ;)

Ercan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 17, 2008 6:06 pm 
Offline
GTK+ Guru

Joined: Fri Jan 04, 2008 3:17 pm
Posts: 183
Location: France (92340 Bourg La Reine)
Hello

I don't know Windows (never really used that in more than 30 years of computing, except to change once a year some password at work) , only Linux (and older Unixes).

I don't understand what you want exactly, but I guess it is related to (what in Unix is called) window management.

In that case, you basically want to code a window manager or to communicate with it. There are many conventions and caveats to follow, so be careful.

Look at here and the ICCCM.

The details are quite ugly. See the unix hater

But maybe I am completely wrong and mis-understood your goals. Try to explain them in details.

Regards.

_________________
Basile Starynkevitch (France)
http://starynkevitch.net/Basile/


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 17, 2008 6:58 pm 
Offline
Familiar Face

Joined: Wed Jan 16, 2008 12:05 pm
Posts: 8
Location: Schaafheim - Frankfurt / Germany
I have just found this callback from the X-lib:

http://tronche.com/gui/x/xlib/ICC/clien ... sHint.html

maybe you can find the window class name or other properties of the window.

here you can find the API for xlib:

http://tronche.com/gui/x/xlib/

Ercan


Top
 Profile  
 
 Post subject: Gtk equivalent for FindWindow, GetWindowRect, SetCursorPos?
PostPosted: Fri Jan 18, 2008 4:18 am 
Offline
Familiar Face

Joined: Thu Jan 17, 2008 8:50 am
Posts: 5
hi,

My exact requirement is to bring a background window into focus and then getting its x,y coordinates and finally I will set the cursor position to these x,y
locations, so in Windows I use the functions like FindWindow(), SetCursorPos() etc. I want to do the same in Linux too, so I am trying to find
equivalents for these functions, but I couldn't find any.

thanks
Suresh


Top
 Profile  
 
 Post subject: Re: Gtk equivalent for FindWindow, GetWindowRect, SetCursorP
PostPosted: Fri Jan 18, 2008 6:53 am 
Offline
GTK+ Guru

Joined: Fri Jan 04, 2008 3:17 pm
Posts: 183
Location: France (92340 Bourg La Reine)
sureshc2k1 wrote:
My exact requirement is to bring a background window into focus and then getting its x,y coordinates and finally I will set the cursor position to these x,y locations,


I may be wrong, but IIRC this is against the ICCCM conventions. I leave you to check this.
The intuition is that focus management is the responsability of the window manager, not of any application.

Never forget that with Unix, any well behaved application should work with any kind of window managers, and there are lots of them, all (supposedly) respecting the ICCCM & others conventions.

Don't forget the X11 motto: provide mechanism, not policy.

So I tend to believe that your requirement is impossible with Unix. I leave you to check the details by reading the many required pages....

_________________
Basile Starynkevitch (France)
http://starynkevitch.net/Basile/


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 18, 2008 8:47 am 
Offline
Familiar Face

Joined: Thu Jan 17, 2008 8:50 am
Posts: 5
so are you telling that my requirement is not possible in Linux?


Top
 Profile  
 
 Post subject: Re: Gtk equivalent for FindWindow, GetWindowRect, SetCursorP
PostPosted: Sat Jan 19, 2008 9:34 pm 
Offline
Familiar Face

Joined: Wed Jan 16, 2008 12:05 pm
Posts: 8
Location: Schaafheim - Frankfurt / Germany
sureshc2k1 wrote:
hi,

My exact requirement is to bring a background window into focus and then getting its x,y coordinates and finally I will set the cursor position to these x,y
locations, so in Windows I use the functions like FindWindow(), SetCursorPos() etc. I want to do the same in Linux too, so I am trying to find
equivalents for these functions, but I couldn't find any.

thanks
Suresh


Can you may send me an example for win32, because I can't really imagine what you mean....
Maybe a can find for you a solution.

If you want more information, you can (or I) write a PM.

Ercan


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 21, 2008 4:57 am 
Offline
Familiar Face

Joined: Thu Jan 17, 2008 8:50 am
Posts: 5
This is the code;

{
RECT ps;

hwnd = ::FindWindow(NULL, windowname);
SetForegroundWindow(hwnd);

::GetWindowRect(hwnd, &ps);
::SetCursorPos((ps.left + ps.right)/2, (ps.top + ps.bottom)/2);
}

by
Suresh C


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group