Skip to content

Commit

Permalink
Chrome 47.2 RC. Fixed mouse cursor indicator during
Browse files Browse the repository at this point in the history
loading of a web page (Issue #148).
  • Loading branch information
cztomczak committed Feb 11, 2016
1 parent af5ba7b commit 0b2a014
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 4 deletions.
12 changes: 12 additions & 0 deletions phpdesktop-chrome47/cef/client_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
extern HINSTANCE g_hInstance;
extern wchar_t g_windowClassName[256];
extern std::map<HWND, BrowserWindow*> g_browserWindows; // browser_window.cpp
std::map<HWND, bool> g_isBrowserLoading;

// This will be set to false when application completes loading
// of the initial webpage in main browser window. If the OnLoadError
// callback gets called it means that firewall has blocked the
Expand Down Expand Up @@ -322,6 +324,16 @@ void ClientHandler::OnLoadingStateChange(CefRefPtr<CefBrowser> cefBrowser,
bool canGoForward) {
LOG_DEBUG << "OnLoadingStateChange: loading=" << isLoading << ", url="
<< cefBrowser->GetMainFrame()->GetURL().ToString().c_str();

// Is browser loading - if so changing mouse cursor in main.cpp
BrowserWindow* browserWindow = GetBrowserWindow(cefBrowser->GetHost()->GetWindowHandle());
if (!browserWindow) {
LOG_ERROR << "GetWindowHandle() failed in OnLoadingStateChange";
return;
}
g_isBrowserLoading[browserWindow->GetWindowHandle()] = isLoading;

// Start page loading
static int calls = 0;
calls++;
if (calls > 1) {
Expand Down
40 changes: 40 additions & 0 deletions phpdesktop-chrome47/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ SingleInstanceApplication g_singleInstanceApplication;
wchar_t* g_singleInstanceApplicationGuid = 0;
wchar_t g_windowClassName[256] = L"";
HINSTANCE g_hInstance = 0;

extern std::map<HWND, bool> g_isBrowserLoading; // client_handler.cpp
// Default cursor
HCURSOR g_arrowCursor = 0;
// Standard arrow and small hourglass
HCURSOR g_appStartingCursor = 0;

extern std::map<HWND, BrowserWindow*> g_browserWindows; // browser_window.cpp
std::string g_cgiEnvironmentFromArgv = "";

Expand Down Expand Up @@ -160,9 +167,42 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

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);
}
}
}

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpstrCmdLine, int nCmdShow) {
g_hInstance = hInstance;

// Mouse cursor indicator during loading of a web page
g_arrowCursor = (HCURSOR) LoadImage(
0, MAKEINTRESOURCE(IDC_ARROW), IMAGE_CURSOR, 0, 0,
LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_SHARED);
g_appStartingCursor = (HCURSOR) LoadImage(
0, MAKEINTRESOURCE(IDC_APPSTARTING), IMAGE_CURSOR, 0, 0,
LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_SHARED);
SetTimer(NULL, 0, 100, (TIMERPROC)&CheckMousePointerTimer);

json_value* appSettings = GetApplicationSettings();
if (GetApplicationSettingsError().length()) {
std::string error = GetApplicationSettingsError();
Expand Down
8 changes: 4 additions & 4 deletions phpdesktop-chrome47/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ IDR_MAINWINDOW ICON "icon.ico"
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 47,1,0,0
PRODUCTVERSION 47,1,0,0
FILEVERSION 47,2,0,0
PRODUCTVERSION 47,2,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -65,12 +65,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "PHP Desktop"
VALUE "FileDescription", "PHP Desktop Chrome"
VALUE "FileVersion", "47.1.0.0"
VALUE "FileVersion", "47.2.0.0"
VALUE "InternalName", "phpdesktop"
VALUE "LegalCopyright", "(c) Czarek Tomczak 2012"
VALUE "OriginalFilename", "phpdesktop-chrome.exe"
VALUE "ProductName", "PHP Desktop Chrome"
VALUE "ProductVersion", "47.1.0.0"
VALUE "ProductVersion", "47.2.0.0"
END
END
BLOCK "VarFileInfo"
Expand Down
11 changes: 11 additions & 0 deletions phpdesktop-chrome47/www/mouse-cursor-loading.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
sleep(5);
?>

<style type="text/css">@import url("style.css");</style>
<a href="index.php">Go back to index</a>
| <a href="<?php echo $_SERVER["REQUEST_URI"];?>">Refresh</a>

<h1>Mouse cursor loading</h1>

Testing mouse cursor indicator during long loading of a page.

0 comments on commit 0b2a014

Please sign in to comment.