Skip to content

Commit 0b2a014

Browse files
committed
Chrome 47.2 RC. Fixed mouse cursor indicator during
loading of a web page (Issue cztomczak#148).
1 parent af5ba7b commit 0b2a014

File tree

4 files changed

+67
-4
lines changed

4 files changed

+67
-4
lines changed

phpdesktop-chrome47/cef/client_handler.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
extern HINSTANCE g_hInstance;
2626
extern wchar_t g_windowClassName[256];
2727
extern std::map<HWND, BrowserWindow*> g_browserWindows; // browser_window.cpp
28+
std::map<HWND, bool> g_isBrowserLoading;
29+
2830
// This will be set to false when application completes loading
2931
// of the initial webpage in main browser window. If the OnLoadError
3032
// callback gets called it means that firewall has blocked the
@@ -322,6 +324,16 @@ void ClientHandler::OnLoadingStateChange(CefRefPtr<CefBrowser> cefBrowser,
322324
bool canGoForward) {
323325
LOG_DEBUG << "OnLoadingStateChange: loading=" << isLoading << ", url="
324326
<< cefBrowser->GetMainFrame()->GetURL().ToString().c_str();
327+
328+
// Is browser loading - if so changing mouse cursor in main.cpp
329+
BrowserWindow* browserWindow = GetBrowserWindow(cefBrowser->GetHost()->GetWindowHandle());
330+
if (!browserWindow) {
331+
LOG_ERROR << "GetWindowHandle() failed in OnLoadingStateChange";
332+
return;
333+
}
334+
g_isBrowserLoading[browserWindow->GetWindowHandle()] = isLoading;
335+
336+
// Start page loading
325337
static int calls = 0;
326338
calls++;
327339
if (calls > 1) {

phpdesktop-chrome47/main.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ SingleInstanceApplication g_singleInstanceApplication;
3232
wchar_t* g_singleInstanceApplicationGuid = 0;
3333
wchar_t g_windowClassName[256] = L"";
3434
HINSTANCE g_hInstance = 0;
35+
36+
extern std::map<HWND, bool> g_isBrowserLoading; // client_handler.cpp
37+
// Default cursor
38+
HCURSOR g_arrowCursor = 0;
39+
// Standard arrow and small hourglass
40+
HCURSOR g_appStartingCursor = 0;
41+
3542
extern std::map<HWND, BrowserWindow*> g_browserWindows; // browser_window.cpp
3643
std::string g_cgiEnvironmentFromArgv = "";
3744

@@ -160,9 +167,42 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
160167
}
161168
return DefWindowProc(hwnd, uMsg, wParam, lParam);
162169
}
170+
171+
void CALLBACK CheckMousePointerTimer(HWND hwnd, UINT uMsg, UINT timerId, DWORD dwTime)
172+
{
173+
HWND activeHwnd = GetActiveWindow();
174+
if (!activeHwnd) {
175+
return;
176+
}
177+
BrowserWindow* browserWindow = GetBrowserWindow(activeHwnd);
178+
if (!browserWindow) {
179+
return;
180+
}
181+
std::map<HWND, bool>::iterator it;
182+
it = g_isBrowserLoading.find(browserWindow->GetWindowHandle());
183+
if (it != g_isBrowserLoading.end()) {
184+
bool isLoading = it->second;
185+
if (isLoading && GetCursor() == g_arrowCursor) {
186+
SetCursor(g_appStartingCursor);
187+
} else if (!isLoading && GetCursor() == g_appStartingCursor) {
188+
SetCursor(g_arrowCursor);
189+
}
190+
}
191+
}
192+
163193
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
164194
LPTSTR lpstrCmdLine, int nCmdShow) {
165195
g_hInstance = hInstance;
196+
197+
// Mouse cursor indicator during loading of a web page
198+
g_arrowCursor = (HCURSOR) LoadImage(
199+
0, MAKEINTRESOURCE(IDC_ARROW), IMAGE_CURSOR, 0, 0,
200+
LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_SHARED);
201+
g_appStartingCursor = (HCURSOR) LoadImage(
202+
0, MAKEINTRESOURCE(IDC_APPSTARTING), IMAGE_CURSOR, 0, 0,
203+
LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_SHARED);
204+
SetTimer(NULL, 0, 100, (TIMERPROC)&CheckMousePointerTimer);
205+
166206
json_value* appSettings = GetApplicationSettings();
167207
if (GetApplicationSettingsError().length()) {
168208
std::string error = GetApplicationSettingsError();

phpdesktop-chrome47/resource.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ IDR_MAINWINDOW ICON "icon.ico"
4747
//
4848

4949
VS_VERSION_INFO VERSIONINFO
50-
FILEVERSION 47,1,0,0
51-
PRODUCTVERSION 47,1,0,0
50+
FILEVERSION 47,2,0,0
51+
PRODUCTVERSION 47,2,0,0
5252
FILEFLAGSMASK 0x3fL
5353
#ifdef _DEBUG
5454
FILEFLAGS 0x1L
@@ -65,12 +65,12 @@ BEGIN
6565
BEGIN
6666
VALUE "CompanyName", "PHP Desktop"
6767
VALUE "FileDescription", "PHP Desktop Chrome"
68-
VALUE "FileVersion", "47.1.0.0"
68+
VALUE "FileVersion", "47.2.0.0"
6969
VALUE "InternalName", "phpdesktop"
7070
VALUE "LegalCopyright", "(c) Czarek Tomczak 2012"
7171
VALUE "OriginalFilename", "phpdesktop-chrome.exe"
7272
VALUE "ProductName", "PHP Desktop Chrome"
73-
VALUE "ProductVersion", "47.1.0.0"
73+
VALUE "ProductVersion", "47.2.0.0"
7474
END
7575
END
7676
BLOCK "VarFileInfo"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
sleep(5);
3+
?>
4+
5+
<style type="text/css">@import url("style.css");</style>
6+
<a href="index.php">Go back to index</a>
7+
| <a href="<?php echo $_SERVER["REQUEST_URI"];?>">Refresh</a>
8+
9+
<h1>Mouse cursor loading</h1>
10+
11+
Testing mouse cursor indicator during long loading of a page.

0 commit comments

Comments
 (0)