Example #1
0
void Fullscreen::ToggleFullscreen() {
    // Original code in chromium > fullscreen_handler.cc > FullscreenHandler::SetFullscreenImpl:
    // http://src.chromium.org/viewvc/chrome/trunk/src/ui/views/win/fullscreen_handler.cc
    BrowserWindow* browserWindow = GetBrowserWindow(
            cefBrowser_->GetHost()->GetWindowHandle());
    if (!browserWindow) {
        LOG_ERROR << "GetBrowserWindow() failed in ToggleFullscreen()";
        return;
    }
    HWND hwnd = browserWindow->GetWindowHandle();
    if (!isFullscreen_) {
        isMaximized_ = (IsZoomed(hwnd) != 0);
        if (isMaximized_) {
            SendMessage(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
        }
        gwlStyle_ = GetWindowLong(hwnd, GWL_STYLE);
        gwlExStyle_ = GetWindowLong(hwnd, GWL_EXSTYLE);
        RECT rect;
        GetWindowRect(hwnd, &rect);
        windowRect_ = rect;
        int removeStyle, removeExStyle;
        removeStyle = WS_CAPTION | WS_THICKFRAME;
        removeExStyle = (WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
                | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
        SetWindowLong(hwnd, GWL_STYLE, gwlStyle_ & ~(removeStyle));
        SetWindowLong(hwnd, GWL_EXSTYLE, gwlExStyle_ & ~(removeExStyle));
        HMONITOR monitor;
        MONITORINFO monitorInfo = {};
        monitorInfo.cbSize = sizeof(monitorInfo);
        // MONITOR_DEFAULTTONULL, MONITOR_DEFAULTTOPRIMARY, 
        // MONITOR_DEFAULTTONEAREST
        monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
        GetMonitorInfo(monitor, &monitorInfo);
        int left, top, right, bottom;
        left = monitorInfo.rcMonitor.left;
        top = monitorInfo.rcMonitor.top;
        right = monitorInfo.rcMonitor.right;
        bottom = monitorInfo.rcMonitor.bottom;
        SetWindowPos(hwnd, NULL,
                left, top, right-left, bottom-top,
                SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
    } else {
        SetWindowLong(hwnd, GWL_STYLE, gwlStyle_);
        SetWindowLong(hwnd, GWL_EXSTYLE, gwlExStyle_);
        RECT rect = windowRect_;
        SetWindowPos(hwnd, NULL, rect.left, rect.top,
                rect.right - rect.left, rect.bottom - rect.top,
                SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
        if (isMaximized_) {
            SendMessage(hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
        }
    }
    isFullscreen_ = !(isFullscreen_);
}
Example #2
0
void RemoveBrowserWindow(HWND hwnd) {
    LOG_DEBUG << "RemoveBrowserWindow(): hwnd = " << (int)hwnd;
    BrowserWindow* browser = GetBrowserWindow(hwnd);
    if (!browser) {
        LOG_WARNING << "RemoveBrowserWindow() failed: "
                    << "GetBrowserWindow() failed";
        return;
    }
    std::map<HWND, BrowserWindow*>::iterator it;
    it = g_browserWindows.find(browser->GetWindowHandle());
    if (it != g_browserWindows.end()) {
        // BrowserWindow* browser = it->second;
        g_browserWindows.erase(it);
        delete browser;
    } else {
        LOG_WARNING << "RemoveBrowserWindow() failed: not found";
    }
}
Example #3
0
void CALLBACK CheckMousePointerTimer(HWND hwnd, UINT uMsg, UINT timerId, DWORD dwTime)
{
    HWND activeHwnd = GetActiveWindow();
    if (!activeHwnd) {
        return;
    }
    BrowserWindow* browserWindow = GetBrowserWindow(activeHwnd);
    if (!browserWindow) {
        return;
    }
    std::map<HWND, bool>::iterator it;
    it = g_isBrowserLoading.find(browserWindow->GetWindowHandle());
    if (it != g_isBrowserLoading.end()) {
        bool isLoading = it->second;
        if (isLoading && GetCursor() == g_arrowCursor) {
            SetCursor(g_appStartingCursor);
        } else if (!isLoading && GetCursor() == g_appStartingCursor) {
            SetCursor(g_arrowCursor);
        }
    }
}