7

When creating a Window in XLib

  1. What are the masks I provide to the SetWindowAttributes.event_mask member?
  2. What do I have to pass to the 11th paramater of XCreateWindow()
  3. What are the Events I am looking for in the main message loop (Where I use XNextEvent(lDisplay, &xEvent);?
  4. Since X behaves differently than Microsoft's Win32 API, how do I determine if the mouse is over my window or a window in my "Application" and not over the desktop?

I have looked for a similar post. If there is already one out there please point me in the right direction.


Update

For those who want the easy answer to parts 1-3:

1.

xAttributes.event_mask =  ExposureMask | KeyPressMask | ButtonPress |
                          StructureNotifyMask | ButtonReleaseMask |
                          KeyReleaseMask | EnterWindowMask | LeaveWindowMask |
                          PointerMotionMask | Button1MotionMask | VisibilityChangeMask |
                          ColormapChangeMask;

2.

unsigned long valuemask = CWEventMask | CWBackPixel | CWBorderPixel | CWCursor;


  1.                 switch (xEvent.type)
                    {
                    case MapNotify:
                        break;
                    case Expose:
                        // If this is not the last expose event break
                        if (xEvent.xexpose.count != 0)
                            break;
                        else
                            break;
                    case ConfigureNotify:
                        break;
                    case VisibilityNotify:
                        break;
                    case DestroyNotify:
                        break;
                    case ButtonPress:
                    case ButtonRelease:
                    case EnterNotify:
                    case MotionNotify:
                    case LeaveNotify:
                        if(_mouseHandler)
                            _mouseHandler->HandleInput(lDisplay, &xEvent);
                        break;
                    case KeyPress:
                    case KeyRelease:
                        if(_keyboardHandler)
                            _keyboardHandler->HandleInput(lDisplay, &xEvent);
                        break;
                    default:
                        if(_keyboardHandler)
                            _keyboardHandler->HandleInput(lDisplay, &xEvent);
                        break;
                    }
    
Matthew Hoggan
  • 7,402
  • 16
  • 75
  • 140
  • 1
    XLib is pretty well documented. Did you try searching the Internet? For example [XLib Programming Manual: Event Masks](http://tronche.com/gui/x/xlib/events/mask.html) – Jim Garrison Feb 20 '12 at 07:14

2 Answers2

4

XLib is pretty well documented. For example XLib Programming Manual: Event Masks

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
2

The first three are well-documented, I think.

To determine whether the mouse is over your window, listen to Enter and Leave events. The xev utility is a great way to understand what events exist in the X window system, and when they are sent.

Simon Richter
  • 28,572
  • 1
  • 42
  • 64