Exemplo n.º 1
0
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
      WPARAM wparam, LPARAM lparam)
{
   settings_t *settings = config_get_ptr();

   switch (message)
   {
      case WM_SYSCOMMAND:
         /* Prevent screensavers, etc, while running. */
         switch (wparam)
         {
            case SC_SCREENSAVE:
            case SC_MONITORPOWER:
               return 0;
         }
         break;

      case WM_CHAR:
      case WM_KEYDOWN:
      case WM_KEYUP:
      case WM_SYSKEYUP:
      case WM_SYSKEYDOWN:
         return win32_handle_keyboard_event(hwnd, message, wparam, lparam);

      case WM_CREATE:
         create_gl_context(hwnd);
         return 0;

      case WM_CLOSE:
      case WM_DESTROY:
      case WM_QUIT:
      {
         WINDOWPLACEMENT placement;
         GetWindowPlacement(g_hwnd, &placement);
         g_pos_x = placement.rcNormalPosition.left;
         g_pos_y = placement.rcNormalPosition.top;
         g_quit = true;
         return 0;
      }
      case WM_SIZE:
         /* Do not send resize message if we minimize. */
         if (wparam != SIZE_MAXHIDE && wparam != SIZE_MINIMIZED)
         {
            g_resize_width  = LOWORD(lparam);
            g_resize_height = HIWORD(lparam);
            g_resized = true;
         }
         return 0;
	  case WM_COMMAND:
         if (settings->ui.menubar_enable)
         {
            LRESULT ret = win32_menu_loop(g_hwnd, wparam);
         }
         break;
   }

   if (dinput_handle_message(dinput_wgl, message, wparam, lparam))
      return 0;
   return DefWindowProc(hwnd, message, wparam, lparam);
}
Exemplo n.º 2
0
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message,
      WPARAM wParam, LPARAM lParam)
{
   driver_t *driver     = driver_get_ptr();
   settings_t *settings = config_get_ptr();

   switch (message)
   {
      case WM_CREATE:
         {
            LPCREATESTRUCT p_cs   = (LPCREATESTRUCT)lParam;
            curD3D                = (d3d_video_t*)p_cs->lpCreateParams;
         }
         break;
      case WM_CHAR:
      case WM_KEYDOWN:
      case WM_KEYUP:
      case WM_SYSKEYUP:
      case WM_SYSKEYDOWN:
         return win32_handle_keyboard_event(hWnd, message, wParam, lParam);

      case WM_DESTROY:
         d3d_quit = true;
         return 0;
      case WM_SIZE:
         {
            unsigned new_width  = LOWORD(lParam);
            unsigned new_height = HIWORD(lParam);

            if (new_width && new_height)
               d3d_resize(driver->video_data, new_width, new_height);
         }
         return 0;
      case WM_COMMAND:
         if (settings->ui.menubar_enable)
         {
            d3d_video_t *d3d = (d3d_video_t*)driver->video_data;
            HWND        d3dr = d3d->hWnd;
            LRESULT      ret = win32_menu_loop(d3dr, wParam);
         }
         break;
   }

   if (dinput_handle_message(dinput, message, wParam, lParam))
      return 0;
   return DefWindowProc(hWnd, message, wParam, lParam);
}
Exemplo n.º 3
0
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
      WPARAM wparam, LPARAM lparam)
{
   settings_t *settings     = config_get_ptr();
   driver_t   *driver       = driver_get_ptr();
   const char *video_driver = win32_video_get_ident();

   switch (message)
   {
      case WM_SYSCOMMAND:
         /* Prevent screensavers, etc, while running. */
         switch (wparam)
         {
            case SC_SCREENSAVE:
            case SC_MONITORPOWER:
               return 0;
         }
         break;

      case WM_CHAR:
      case WM_KEYDOWN:
      case WM_KEYUP:
      case WM_SYSKEYUP:
      case WM_SYSKEYDOWN:
         return win32_handle_keyboard_event(hwnd, message, wparam, lparam);

      case WM_CREATE:
         if (!strcmp(video_driver, "gl"))
            create_gl_context(hwnd);
         else if (!strcmp(video_driver, "d3d"))
         {
            LPCREATESTRUCT p_cs   = (LPCREATESTRUCT)lparam;
            curD3D                = p_cs->lpCreateParams;
         }
         return 0;

      case WM_CLOSE:
      case WM_DESTROY:
      case WM_QUIT:
      {
         WINDOWPLACEMENT placement;
         GetWindowPlacement(g_hwnd, &placement);
         g_pos_x = placement.rcNormalPosition.left;
         g_pos_y = placement.rcNormalPosition.top;
         g_quit = true;
         return 0;
      }
      case WM_SIZE:
         /* Do not send resize message if we minimize. */
         if (wparam != SIZE_MAXHIDE && wparam != SIZE_MINIMIZED)
         {
            g_resize_width  = LOWORD(lparam);
            g_resize_height = HIWORD(lparam);
            g_resized = true;
         }
         return 0;
	  case WM_COMMAND:
         if (settings->ui.menubar_enable)
         {
            HWND d3dr = g_hwnd;
            if (!strcmp(video_driver, "d3d"))
            {
               d3d_video_t *d3d = (d3d_video_t*)driver->video_data;
               d3dr = g_hwnd;
            }
            LRESULT ret = win32_menu_loop(d3dr, wparam);
            (void)ret;
         }
         break;
   }

   if (dinput_handle_message((!strcmp(video_driver, "gl")) ? dinput_wgl : dinput, message, wparam, lparam))
      return 0;
   return DefWindowProc(hwnd, message, wparam, lparam);
}
Exemplo n.º 4
0
static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message,
      WPARAM wparam, LPARAM lparam)
{

   if (message == WM_NCLBUTTONDBLCLK)
      doubleclick_on_titlebar = true;

   switch (message)
   {
      case WM_SYSCOMMAND:
         /* Prevent screensavers, etc, while running. */
         switch (wparam)
         {
            case SC_SCREENSAVE:
            case SC_MONITORPOWER:
               *quit = true;
               break;
         }
         break;
      case WM_DROPFILES:
         {
            int ret = win32_drag_query_file(hwnd, wparam);
            DragFinish((HDROP)wparam);
            if (ret != 0)
               return 0;
         }
         break;
      case WM_CHAR:
      case WM_KEYDOWN:
      case WM_KEYUP:
      case WM_SYSKEYUP:
      case WM_SYSKEYDOWN:
         *quit = true;
         return win32_handle_keyboard_event(hwnd, message, wparam, lparam);

      case WM_CLOSE:
      case WM_DESTROY:
      case WM_QUIT:
         {
            WINDOWPLACEMENT placement;
            GetWindowPlacement(main_window.hwnd, &placement);
            g_pos_x = placement.rcNormalPosition.left;
            g_pos_y = placement.rcNormalPosition.top;
            g_quit  = true;
            *quit   = true;
         }
         break;
      case WM_SIZE:
         /* Do not send resize message if we minimize. */
         if (wparam != SIZE_MAXHIDE && wparam != SIZE_MINIMIZED)
         {
            g_resize_width  = LOWORD(lparam);
            g_resize_height = HIWORD(lparam);
            g_resized = true;
         }
         *quit = true;
         break;
	  case WM_COMMAND:
         {
            settings_t *settings     = config_get_ptr();
            if (settings->ui.menubar_enable)
               win32_menu_loop(main_window.hwnd, wparam);
         }
         break;
   }
   return 0;
}