Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6979845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:56:16+00:00 2026-05-27T17:56:16+00:00

Under windows, the GUI thread usually call GetMessage to waiting for message, when another

  • 0

Under windows, the GUI thread usually call GetMessage to waiting for message,
when another thread use PoseMessage put a message into the queue, then the
GUI thread will return GetMessage (quit blocking).

Does anyone can tell me, when I use XNextEvent under XWindows to waiting for
event, how can I “wakeup” the GUI thread in another thread. Is there some
API like PoseMessage I can use ?.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:56:16+00:00Added an answer on May 27, 2026 at 5:56 pm

    No. This is why most UI frameworks (Gtk, KDE, etc) use custom main loops to be able to listen for more event sources.

    Internally, XNextEvent uses a socket, so it calls select() to know when input is available. Call ConnectionNumber(display) to get the file descriptor that you need to pass select()

    That allows you to listen for several file descriptors.

    Sample code from http://www.linuxquestions.org/questions/showthread.php?p=2431345#post2431345

    #include <stdio.h>
    #include <stdlib.h>
    #include <X11/Xlib.h>
    #include <X11/Xutil.h>
    
    Display *dis;
    Window win;
    int x11_fd;
    fd_set in_fds;
    
    struct timeval tv;
    XEvent ev;
    
    int main() {
        dis = XOpenDisplay(NULL);
        win = XCreateSimpleWindow(dis, RootWindow(dis, 0), 1, 1, 256, 256, \
            0, BlackPixel (dis, 0), BlackPixel(dis, 0));
    
        // You don't need all of these. Make the mask as you normally would.
        XSelectInput(dis, win, 
            ExposureMask | KeyPressMask | KeyReleaseMask | PointerMotionMask |
            ButtonPressMask | ButtonReleaseMask  | StructureNotifyMask 
            );
    
        XMapWindow(dis, win);
        XFlush(dis);
    
        // This returns the FD of the X11 display (or something like that)
        x11_fd = ConnectionNumber(dis);
    
        // Main loop
        while(1) {
            // Create a File Description Set containing x11_fd
            FD_ZERO(&in_fds);
            FD_SET(x11_fd, &in_fds);
    
            // Set our timer.  One second sounds good.
            tv.tv_usec = 0;
            tv.tv_sec = 1;
    
            // Wait for X Event or a Timer
            int num_ready_fds = select(x11_fd + 1, &in_fds, NULL, NULL, &tv);
            if (num_ready_fds > 0)
                printf("Event Received!\n");
            else if (num_ready_fds == 0)
                // Handle timer here
                printf("Timer Fired!\n");
            else
                printf("An error occured!\n");
    
            // Handle XEvents and flush the input 
            while(XPending(dis))
                XNextEvent(dis, &ev);
        }
        return(0);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am going to program a GUI under windows (will be about 10,000 line
Greetings everyone! I programmed GUI Application using Java Swing under Windows. Under windows everything
Under Windows XP WPF true 3D content (which is usually displayed using the Viewport3D
I have a Delphi application running under Windows that needs to block until another
I have a pretty basic understanding of the GUI thread and the message loop,
My Java program is in working order when i use it under Windows(Eclipse and
Under Windows Server 2003, Enterprise Edition, SP2 (/3GB switch not enabled) As I understand
Under Windows there are some handy functions like QueryPerformanceCounter from mmsystem.h to create a
Under Windows Vista, when I check whether my current user account is in Administrators
Under Windows Vista (2008 and Seven), an application cannot write in Program Files Folder.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.