LinuxQuestions.org
Help answer threads with 0 replies.
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 09-27-2006, 02:39 PM   #1
ciotog
Member
 
Registered: Mar 2004
Location: Canada
Distribution: Slackware current
Posts: 728
Blog Entries: 2

Rep: Reputation: 43
XGrabPointer does not grab pointer reliably [SOLVED]


I'm the current maintainer of wmMand, a small dockable Mandlebrot browser for WindowMaker which was originally written by Mike Henderson in 1999. It's a small (54x54) window that shows part of the Mandelbrot fractal which can be scrolled around and zoomed in and out, and also launch a large window of the current view.

Since I've taken it over I decided to implement a much requested "autozoom" feature, as well as add keyboard input. Both of these are working fine in general, but outside of WindowMaker and Fluxbox I can't get the browser to grab the pointer as I would like.

Basically I want to confine the pointer while the button is being held down to the 54x54 window, and also grab keyboard focus when the pointer enters the small window. I've tried using XGrabPointer which works great in WindowMaker, Fluxbox and I'm sure other lightweight window managers, but not at all in any of the heavyweights (Gnome, KDE, XFCE4).

When calling XGrabPointer with the managers that work the return value is '0', but for those that don't the return value is '3' which AFAICT from X.h is a BadWindow error indicating that it doesn't recognize the identified Window (in this case it's called "iconwin" and is created in wmgeneral.c which was developed by Martijn Pieterse). Other than that, when the window does have focus it works fine.

I checked the code for gdk_pointer_grab which is in gdkmain-x11.c, and it doesn't do anything spectacularly different than what I'm trying to do. So does anyone have any ideas about how I can get it to work, without requiring the use of another library like gtk or qt? Or is anyone aware of any other applications that grab the pointer like this without using those extra libs?

Oh yeah, the current source for wmMand can be found here:
http://sourceforge.net/project/showf...roup_id=161419

Last edited by ciotog; 10-16-2006 at 05:34 PM.
 
Old 10-16-2006, 05:33 PM   #2
ciotog
Member
 
Registered: Mar 2004
Location: Canada
Distribution: Slackware current
Posts: 728

Original Poster
Blog Entries: 2

Rep: Reputation: 43
This issue has been solved. Basically for some reason when calling XGrabPointer with the Window to confine it in as the one created for that purpose as in
Code:
XGrabPointer(display, iconwin, True, 0, GrabModeAsync, GrabModeAsync, iconwin, None, CurrentTime);
it wouldn't work (threw a "invalid Window" error, I believe), but I replaced it with:
Code:
XGrabPointer(display, event.xbutton.window, True, 0, GrabModeAsync, GrabModeAsync, event.xbutton.window, None, CurrentTime);
Now it works perfectly.

The thing that still confuses me is that I use XQueryPointer elsewhere as follows
Code:
	XQueryPointer(display, iconwin, &rr, &cr, &rx, &ry, &x, &y, &mr);
where rr, cr, rx, ry, mr are dummy variables for the return values, and it works fine so I know that iconwin is a valid Window. Furthermore the program worked fine outside of Gnome/KDE/XFCE4.

Anyway, at least it's working now!
 
  


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
How to reliably detect UDP packet loss. rikusg Linux - Networking 2 07-14-2006 03:50 AM
pass pointer,, return pointer??? blizunt7 Programming 3 07-23-2005 01:36 PM
returning data to main() via a pointer to a pointer. slzckboy Programming 3 05-30-2005 01:20 PM
hot to set value of pointer to pointer to a structure in C alix123 Programming 2 11-17-2004 06:40 AM
Need to grab bookmarks from IE... slackMeUp Linux - Software 3 01-25-2004 05:02 PM

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

All times are GMT -5. The time now is 11:52 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