title: X11 Mouse Movement Event
body: <p>When creating a Window in XLib </p>
  
  <ol>
  <li>What are the masks I provide to the <code>SetWindowAttributes.event_mask</code> member? </li>
  <li>What do I have to pass to the 11th paramater of <code>XCreateWindow()</code></li>
  <li>What are the Events I am looking for in the main message loop (Where I use <code>XNextEvent(lDisplay, &amp;xEvent);</code>?</li>
  <li>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?</li>
  </ol>
  
  <p>I have looked for a similar post. If there is already one out there please point me in the right direction.</p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>For those who want the easy answer to parts 1-3:</p>
  
  <p>1.</p>
  
  <pre><code>xAttributes.event_mask =  ExposureMask | KeyPressMask | ButtonPress |
                            StructureNotifyMask | ButtonReleaseMask |
                            KeyReleaseMask | EnterWindowMask | LeaveWindowMask |
                            PointerMotionMask | Button1MotionMask | VisibilityChangeMask |
                            ColormapChangeMask;
  </code></pre>
  
  <hr>
  
  <p>2.</p>
  
  <p><code>unsigned long valuemask = CWEventMask | CWBackPixel | CWBorderPixel | CWCursor;</code> </p>
  
  <hr>
  
  <ol>
  <li><pre><code>                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-&gt;HandleInput(lDisplay, &amp;xEvent);
                      break;
                  case KeyPress:
                  case KeyRelease:
                      if(_keyboardHandler)
                          _keyboardHandler-&gt;HandleInput(lDisplay, &amp;xEvent);
                      break;
                  default:
                      if(_keyboardHandler)
                          _keyboardHandler-&gt;HandleInput(lDisplay, &amp;xEvent);
                      break;
                  }
  </code></pre></li>
  </ol>