ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi all,
I want to have a x window program that get keyboard and mouse event.
I do this with peekmessage and other message loop.But I want to have my own message and send them when needed and peek them at message loop.That's easy in windows, but in linux I don't know.
can you tell me how create, send and receive my own message in linux?
Thanks
The fundamental messaging system under X11 deals with structures of type XEvent . The main difference to Windows is that X11 also requires a connection to an X11 display to exchange messages ('XOpenDisplay' et al). There's 'XSendEvent' for sending events and 'XNextEvent' and related for receiving . I think these infos should suffice to help you find more informations about this system on your own
If you don't want to go this deep, there are of course also the common toolkits like GTK, Qt etc., which take care of the low-level stuff by themselves already, and provide interfaces which might be easier to use in the long run.
Hi,
I have a window that create with x window command, and some subwindow on it.
I read serial port and show some value on subwindow.
I want to send a message to my message loop to repaint a subwindow when receive a value from serial.
Now How can I create and send this message?
Like SendMessage(WM_PAINT,,) in windows.
Thanks
// setup event data
XExposeEvent ev = { Expose, 0, 1, xdisplay, xsubwin, 0, 0, xsubwinwidth, xsubwinheight, 0 };
// send event to display connection
XSendEvent(xdisplay, xsubwin, False, ExposureMask, (XEvent *) &ev);
// if you want the message to arrive immediately add a call to XFlush(xdisplay) here ...
Hi fantas,
I have 2 class one for subwin and other for win, the window of win class is parent of subwin window.
I create a window and have 4 subwindow, and want to repaint window.
There are some of my code below:
#1#
In SubWindow class
XNextEvent(display,&event);
switch(event.type)
{
case Expose:
// return subwindow number for subwindow Window
WindowNumber = RepaintWindow(event.xexpose.window); switch( WindowNumber )
{
case 0:
Paint();
break;
case 1:
sub1.Paint();
break;
...
}
#########
In section 1, I printf the EventPaint.xexpose.window and that has correct value,
but in section 2, that is the main program when I printf the EventPaint.xexpose.window,I have only the main window number. And only my main(parent) window redisplay.
I think that send message don't work!
Why when I receive message I receive main window insted of subwindow window??
And why not use my example code ? The values I put in are the ones that will work for the default case (just replace the ones that are obviously different).
Hi fantas
I have another question.
When close,minimize or maximize icon of window clicked,which message sends to server? I want to manage them myself. And when resize window with mouse which message send?
The functions you mention are closely dependent on the window manager you are using. In general, you first query the window manager setting and then send a client message to the display connection with the new settings.
Here is an example code (copied from the Motif FAQ) to showcase how it's done e.g. for minimizing a window:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.