Browse Source

Viewport: GLFW: Build fix for pre GLFW 3.2 (#1542)

omar 7 years ago
parent
commit
7abc368927
1 changed files with 6 additions and 0 deletions
  1. 6 0
      examples/imgui_impl_glfw.cpp

+ 6 - 0
examples/imgui_impl_glfw.cpp

@@ -45,6 +45,7 @@
 #define GLFW_HAS_WINDOW_ALPHA       (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwSetWindowOpacity
 #define GLFW_HAS_WINDOW_ALPHA       (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwSetWindowOpacity
 #define GLFW_HAS_PER_MONITOR_DPI    (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwGetMonitorContentScale
 #define GLFW_HAS_PER_MONITOR_DPI    (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwGetMonitorContentScale
 #define GLFW_HAS_VULKAN             (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ glfwCreateWindowSurface
 #define GLFW_HAS_VULKAN             (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ glfwCreateWindowSurface
+#define GLFW_HAS_FOCUS_WINDOW       (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ glfwFocusWindow
 
 
 // Data
 // Data
 enum GlfwClientApi
 enum GlfwClientApi
@@ -505,8 +506,13 @@ static void ImGui_ImplGlfw_SetWindowTitle(ImGuiViewport* viewport, const char* t
 
 
 static void ImGui_ImplGlfw_SetWindowFocus(ImGuiViewport* viewport)
 static void ImGui_ImplGlfw_SetWindowFocus(ImGuiViewport* viewport)
 {
 {
+#if GLFW_HAS_FOCUS_WINDOW
     ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData;
     ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData;
     glfwFocusWindow(data->Window);
     glfwFocusWindow(data->Window);
+#else
+    // FIXME: What are the effect of not having this function? At the moment imgui doesn't actually call SetWindowFocus - we set that up ahead, will answer that question later.
+    (void)viewport;
+#endif
 }
 }
 
 
 static bool ImGui_ImplGlfw_GetWindowFocus(ImGuiViewport* viewport)
 static bool ImGui_ImplGlfw_GetWindowFocus(ImGuiViewport* viewport)