Computing.Net > Forums > Programming > x11 events and CPU%

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

x11 events and CPU%

Reply to Message Icon

Name: karluk87
Date: April 30, 2005 at 02:41:17 Pacific
OS: Mandrake Linux 10.0 Kerne
CPU/Ram: Celeron 1.3GHz / 640MB RA
Comment:

Hi, how's it going.

So I'm loving programming under Xlib so
far, but I need to know a few things.

OK. I find it really disturbing that
when I run a program I've written for X, X
suddenly takes up 20% of CPU function!

Also, I would like to know how to get it
so that the user can't resize, maximize or
close the window.

I would also like to know what XEvent
value is sent when the user clicks the
close box of the window.

Finally, I would like to know how to find
out the position of the mouse within the
window when the user clicks on it. I
already know the event sent when this
happens.

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: Wolfbone
Date: April 30, 2005 at 06:57:53 Pacific
Reply:

It shouldn't use any CPU if your code isn't doing anything ie if your code has just called XNextEvent() or something similar and you're not playing with things in the window.

Not sure about fixed size windows, I'd guess you should just set size_hints->max_* and size_hints->min_* equal in pairs.

DestroyWindow (Xlib.h) for closing actions (I think) and since you already know the event sent for clicking - RTFM - 'man XButtonEvent' or whatever it is ;-)


0

Response Number 2
Name: Wolfbone
Date: April 30, 2005 at 13:23:44 Pacific
Reply:

For making fixed size windows, 'man XSetWMNormalHints' and/or 'man XSetWMProperties'

http://standards.freedesktop.org/wm-spec/1.3/ar01s07.html#NORESIZE



0

Response Number 3
Name: karluk87
Date: April 30, 2005 at 16:05:58 Pacific
Reply:

Thanks a lot for the help Wolfbone. I did
get working the fixed border with XSetWMNormalHints() (first doing
XAllocSizeHints()).

I got rid of the CPU% problem by using
XWindowEvent() instead of XNextEvent(). Also, I had a timer regulate the event loop so that the event was checked every 50ms. For some reason, this has the same effect alone as using XWindowEvent alone, so I combined them.

I also got the mouse location working, by
using (x_event.xbutton.x) and
(x_event.xbutton.y).

DestroyWindow doesn't seem to exist
according to my compiler, but I'm OK
without closebox stuff this for my
purposes. Yeah, this stuff's pretty neat.

Thanks.


0

Response Number 4
Name: Wolfbone
Date: April 30, 2005 at 18:13:22 Pacific
Reply:

Yeah, sorry - it's DestroyNotify (X.h) not DestroyWindow.

"Yeah, this stuff's pretty neat."

It sure is - there's nothing remotely comparable to the X standards framework, it's extensions and all the toolkits and WMs etc. that have been built on top of it. It may be complex and hard to work with raw X like you are doing, but you can end up with stuff like this:

http://enlightenment.org/data/vid/e17_video.avi


0

Response Number 5
Name: karluk87
Date: April 30, 2005 at 21:50:16 Pacific
Reply:

Cool video. I kinda figured, after
searching the web, that it would be
DestroyNotify. For some reason, even when
I included StructureNotifyMask in the event
mask, it didn't seem to pick up. So I
found an alternative way using
WM_DELETE_WINDOW, which you can get the
window manager to send to the window. I
just wanted to stop the user from quitting
the program in the middle without giving me
a chance to free allocated stuff.


0

Related Posts

See More



Response Number 6
Name: Wolfbone
Date: May 1, 2005 at 06:40:56 Pacific
Reply:

Yes, using WM protocols is the right way to do what you want to do when top level windows are closed.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Shared memory in C ASP:Textbox Behaviour



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: x11 events and CPU%

Click and DblClick events www.computing.net/answers/programming/click-and-dblclick-events/3251.html

Simultaneous kbd events www.computing.net/answers/programming/simultaneous-kbd-events/12783.html

Program an event to run auto daily www.computing.net/answers/programming/program-an-event-to-run-auto-daily/6166.html