Ejemplo n.º 1
0
static void gfx_ctx_xegl_check_window(void *data, bool *quit,
      bool *resize, unsigned *width, unsigned *height, unsigned frame_count)
{
   XEvent event;
   unsigned new_width  = *width;
   unsigned new_height = *height;

   (void)frame_count;

   gfx_ctx_xegl_get_video_size(data, &new_width, &new_height);

   if (new_width != *width || new_height != *height)
   {
      *resize = true;
      *width  = new_width;
      *height = new_height;
   }

   while (XPending(g_dpy))
   {
      bool filter;
      
      /* Can get events from older windows. Check this. */
      XNextEvent(g_dpy, &event);
      filter = XFilterEvent(&event, g_win);

      switch (event.type)
      {
         case ClientMessage:
            if (event.xclient.window == g_win && (Atom)event.xclient.data.l[0] == g_quit_atom)
               g_quit = true;
            break;

         case DestroyNotify:
            if (event.xdestroywindow.window == g_win)
               g_quit = true;
            break;

         case MapNotify:
            if (event.xmap.window == g_win)
               g_has_focus = true;
            break;

         case UnmapNotify:
            if (event.xunmap.window == g_win)
               g_has_focus = false;
            break;

         case KeyPress:
         case KeyRelease:
            if (event.xkey.window == g_win)
               x11_handle_key_event(&event, g_xic, filter);
            break;
      }
   }

   *quit = g_quit;
}
Ejemplo n.º 2
0
static void gfx_ctx_glx_check_window(void *data, bool *quit,
      bool *resize, unsigned *width, unsigned *height, unsigned frame_count)
{
   gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)driver.video_context_data;
   unsigned new_width = *width, new_height = *height;

   (void)frame_count;

   gfx_ctx_glx_get_video_size(data, &new_width, &new_height);

   if (new_width != *width || new_height != *height)
   {
      *resize = true;
      *width  = new_width;
      *height = new_height;
   }

   XEvent event;
   while (XPending(glx->g_dpy))
   {
      XNextEvent(glx->g_dpy, &event);
      bool filter = XFilterEvent(&event, glx->g_win);

      switch (event.type)
      {
         case ClientMessage:
            if (event.xclient.window == glx->g_win &&
                  (Atom)event.xclient.data.l[0] == g_quit_atom)
               g_quit = true;
            break;

         case DestroyNotify:
            if (event.xdestroywindow.window == glx->g_win)
               g_quit = true;
            break;

         case MapNotify:
            if (event.xmap.window == glx->g_win)
               glx->g_has_focus = true;
            break;

         case UnmapNotify:
            if (event.xunmap.window == glx->g_win)
               glx->g_has_focus = false;
            break;

         case KeyPress:
         case KeyRelease:
            x11_handle_key_event(&event, glx->g_xic, filter);
            break;
      }
   }

   *quit = g_quit;
}
Ejemplo n.º 3
0
static void gfx_ctx_check_window(bool *quit,
      bool *resize, unsigned *width, unsigned *height, unsigned frame_count)
{
   (void)frame_count;

   unsigned new_width = *width, new_height = *height;
   gfx_ctx_get_video_size(&new_width, &new_height);

   if (new_width != *width || new_height != *height)
   {
      *resize = true;
      *width  = new_width;
      *height = new_height;
   }

   XEvent event;
   while (XPending(g_dpy))
   {
      XNextEvent(g_dpy, &event);
      switch (event.type)
      {
         case ClientMessage:
            if ((Atom)event.xclient.data.l[0] == g_quit_atom)
               g_quit = true;
            break;

         case DestroyNotify:
            g_quit = true;
            break;

         case MapNotify:
            g_has_focus = true;
            break;

         case UnmapNotify:
            g_has_focus = false;
            break;

         case KeyPress:
         case KeyRelease:
            x11_handle_key_event(&event);
            break;
      }
   }

   *quit = g_quit;
}
Ejemplo n.º 4
0
bool x11_alive(void *data)
{
   while (XPending(g_x11_dpy))
   {
      XEvent event;
      bool filter = false;

      /* Can get events from older windows. Check this. */
      XNextEvent(g_x11_dpy, &event);
      filter = XFilterEvent(&event, g_x11_win);

      switch (event.type)
      {
         case ClientMessage:
            if (event.xclient.window == g_x11_win &&
                  (Atom)event.xclient.data.l[0] == g_x11_quit_atom)
               frontend_driver_set_signal_handler_state(1);
            break;

         case DestroyNotify:
            if (event.xdestroywindow.window == g_x11_win)
               frontend_driver_set_signal_handler_state(1);
            break;

         case MapNotify:
            if (event.xmap.window == g_x11_win)
               g_x11_has_focus = true;
            break;

         case UnmapNotify:
            if (event.xunmap.window == g_x11_win)
               g_x11_has_focus = false;
            break;

         case ButtonPress:
            switch (event.xbutton.button)
            {
               case 1: /* Left click */
#if 0
                  RARCH_LOG("Click occurred : [%d, %d]\n",
                        event.xbutton.x_root,
                        event.xbutton.y_root);
#endif
                  break;
               case 2: /* Grabbed  */
                       /* Middle click */
                  break;
               case 3: /* Right click */
                  break;
               case 4: /* Grabbed  */
                       /* Scroll up */
               case 5: /* Scroll down */
                  x_input_poll_wheel(&event.xbutton, true);
                  break;
            }
            break;

         case EnterNotify:
            g_x11_entered = true;
            break;

         case LeaveNotify:
            g_x11_entered = false;
            break;

         case ButtonRelease:
            break;

         case KeyPress:
         case KeyRelease:
            if (event.xkey.window == g_x11_win)
               x11_handle_key_event(&event, g_x11_xic, filter);
            break;
      }
   }

   return !((bool)frontend_driver_get_signal_handler_state());
}