diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in index 82d8c3b7f..a495c20ce 100644 --- a/CMakeLists.txt.in +++ b/CMakeLists.txt.in @@ -480,6 +480,22 @@ if(OS_WINDOWS) set(CEF_SANDBOX_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/cef_sandbox.lib") set(CEF_SANDBOX_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/cef_sandbox.lib") endif() + + # Configure use of ATL. + option(USE_ATL "Enable or disable use of ATL." ON) + if(USE_ATL) + # Determine if the Visual Studio install supports ATL. + get_filename_component(VC_BIN_DIR ${CMAKE_CXX_COMPILER} DIRECTORY) + get_filename_component(VC_DIR ${VC_BIN_DIR} DIRECTORY) + if(NOT IS_DIRECTORY "${VC_DIR}/atlmfc") + set(USE_ATL OFF) + endif() + endif() + + if(USE_ATL) + # Definition used by apps to test if ATL support is enabled. + add_definitions(-DCEF_USE_ATL) + endif() endif() @@ -531,6 +547,7 @@ endif() if(OS_WINDOWS) message(STATUS "CEF Windows sandbox: ${USE_SANDBOX}") + message(STATUS "Visual Studio ATL support: ${USE_ATL}") endif() set(LIBRARIES ${CEF_STANDARD_LIBS}) diff --git a/tests/cefclient/cefclient_osr_dragdrop_win.cpp b/tests/cefclient/cefclient_osr_dragdrop_win.cpp index 051bbb243..9d0125cf5 100644 --- a/tests/cefclient/cefclient_osr_dragdrop_win.cpp +++ b/tests/cefclient/cefclient_osr_dragdrop_win.cpp @@ -4,6 +4,8 @@ #include "cefclient/cefclient_osr_dragdrop_win.h" +#if defined(CEF_USE_ATL) + #include #include #include @@ -646,3 +648,5 @@ DataObjectWin::DataObjectWin(FORMATETC* fmtetc, STGMEDIUM* stgmed, int count) m_pStgMedium[i] = stgmed[i]; } } + +#endif // defined(CEF_USE_ATL) diff --git a/tests/cefclient/cefclient_osr_dragdrop_win.h b/tests/cefclient/cefclient_osr_dragdrop_win.h index cda91478e..53336e523 100644 --- a/tests/cefclient/cefclient_osr_dragdrop_win.h +++ b/tests/cefclient/cefclient_osr_dragdrop_win.h @@ -6,6 +6,14 @@ #define CEF_TESTS_CEFCLIENT_CEFCLIENT_OSR_DRAGDROP_WIN_H_ #pragma once +// When generating projects with CMake the CEF_USE_ATL value will be defined +// automatically if using a supported Visual Studio version. Pass -DUSE_ATL=OFF +// to the CMake command-line to disable use of ATL. +// Uncomment this line to manually enable ATL support. +// #define CEF_USE_ATL 1 + +#if defined(CEF_USE_ATL) + #include #include #include @@ -175,4 +183,6 @@ class DataObjectWin : public IDataObject { explicit DataObjectWin(FORMATETC *fmtetc, STGMEDIUM *stgmed, int count); }; +#endif // defined(CEF_USE_ATL) + #endif // CEF_TESTS_CEFCLIENT_CEFCLIENT_OSR_DRAGDROP_WIN_H_ diff --git a/tests/cefclient/cefclient_osr_widget_win.cpp b/tests/cefclient/cefclient_osr_widget_win.cpp index 630cd024b..49a5405e4 100644 --- a/tests/cefclient/cefclient_osr_widget_win.cpp +++ b/tests/cefclient/cefclient_osr_widget_win.cpp @@ -44,9 +44,12 @@ bool OSRWindow::CreateWidget(HWND hWndParent, const RECT& rect, // Reference released in OnDestroyed(). AddRef(); +#if defined(CEF_USE_ATL) drop_target_ = DropTargetWin::Create(this, hWnd_); HRESULT register_res = RegisterDragDrop(hWnd_, drop_target_); DCHECK_EQ(register_res, S_OK); +#endif + return true; } @@ -56,8 +59,11 @@ void OSRWindow::DestroyWidget() { } void OSRWindow::OnBeforeClose(CefRefPtr browser) { +#if defined(CEF_USE_ATL) RevokeDragDrop(hWnd_); drop_target_ = NULL; +#endif + DisableGL(); ::DestroyWindow(hWnd_); } @@ -155,6 +161,7 @@ bool OSRWindow::StartDragging(CefRefPtr browser, CefRefPtr drag_data, CefRenderHandler::DragOperationsMask allowed_ops, int x, int y) { +#if defined(CEF_USE_ATL) if (!drop_target_) return false; current_drag_op_ = DRAG_OPERATION_NONE; @@ -167,11 +174,17 @@ bool OSRWindow::StartDragging(CefRefPtr browser, browser->GetHost()->DragSourceEndedAt(pt.x, pt.y, result); browser->GetHost()->DragSourceSystemDragEnded(); return true; +#else + // Cancel the drag. The dragging implementation requires ATL support. + return false; +#endif } void OSRWindow::UpdateDragCursor(CefRefPtr browser, CefRenderHandler::DragOperation operation) { +#if defined(CEF_USE_ATL) current_drag_op_ = operation; +#endif } void OSRWindow::Invalidate() { @@ -202,6 +215,8 @@ void OSRWindow::WasHidden(bool hidden) { hidden_ = hidden; } +#if defined(CEF_USE_ATL) + CefBrowserHost::DragOperationsMask OSRWindow::OnDragEnter(CefRefPtr drag_data, CefMouseEvent ev, @@ -230,13 +245,17 @@ CefBrowserHost::DragOperationsMask return current_drag_op_; } +#endif // defined(CEF_USE_ATL) + OSRWindow::OSRWindow(OSRBrowserProvider* browser_provider, bool transparent) : renderer_(transparent), browser_provider_(browser_provider), hWnd_(NULL), hDC_(NULL), hRC_(NULL), +#if defined(CEF_USE_ATL) current_drag_op_(DRAG_OPERATION_NONE), +#endif painting_popup_(false), render_task_pending_(false), hidden_(false) { diff --git a/tests/cefclient/cefclient_osr_widget_win.h b/tests/cefclient/cefclient_osr_widget_win.h index c7542f426..700c83d86 100644 --- a/tests/cefclient/cefclient_osr_widget_win.h +++ b/tests/cefclient/cefclient_osr_widget_win.h @@ -19,8 +19,11 @@ class OSRBrowserProvider { virtual ~OSRBrowserProvider() {} }; -class OSRWindow : public ClientHandler::RenderHandler, - public DragEvents { +class OSRWindow : public ClientHandler::RenderHandler +#if defined(CEF_USE_ATL) + , public DragEvents +#endif +{ public: // Create a new OSRWindow instance. |browser_provider| must outlive this // object. @@ -75,6 +78,7 @@ class OSRWindow : public ClientHandler::RenderHandler, CefRefPtr browser, CefRenderHandler::DragOperation operation) OVERRIDE; +#if defined(CEF_USE_ATL) // DragEvents methods virtual CefBrowserHost::DragOperationsMask OnDragEnter( CefRefPtr drag_data, @@ -85,6 +89,7 @@ class OSRWindow : public ClientHandler::RenderHandler, virtual void OnDragLeave() OVERRIDE; virtual CefBrowserHost::DragOperationsMask OnDrop(CefMouseEvent ev, CefBrowserHost::DragOperationsMask effect) OVERRIDE; +#endif // defined(CEF_USE_ATL) void Invalidate(); void WasHidden(bool hidden); @@ -115,8 +120,10 @@ class OSRWindow : public ClientHandler::RenderHandler, HDC hDC_; HGLRC hRC_; +#if defined(CEF_USE_ATL) CComPtr drop_target_; CefRenderHandler::DragOperation current_drag_op_; +#endif bool painting_popup_; bool render_task_pending_;