Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 328ee9b

Browse files
committed
[FlashFrame] change NativeWindow::FlashFrame input parameter to int, the javascript boolean parameter true redirected as -1, false as 0
1 parent 0afb547 commit 328ee9b

9 files changed

Lines changed: 29 additions & 15 deletions

src/api/window/window.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ void Window::Call(const std::string& method,
254254
arguments.GetInteger(1, &y))
255255
shell_->window()->SetPosition(gfx::Point(x, y));
256256
} else if (method == "RequestAttention") {
257-
bool flash;
258-
if (arguments.GetBoolean(0, &flash))
259-
shell_->window()->FlashFrame(flash);
257+
int count;
258+
if (arguments.GetInteger(0, &count))
259+
shell_->window()->FlashFrame(count);
260260
} else if (method == "SetBadgeLabel") {
261261
std::string label;
262262
if (arguments.GetString(0, &label))

src/api/window_bindings.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,10 @@ Window.prototype.setShowInTaskbar = function(flag) {
408408
}
409409

410410
Window.prototype.requestAttention = function(flash) {
411-
flash = Boolean(flash);
411+
if (typeof flash == 'boolean') {
412+
// boolean true is redirected as -1 value
413+
flash = flash ? -1 : 0;
414+
}
412415
CallObjectMethod(this, 'RequestAttention', [ flash ]);
413416
}
414417

src/browser/native_window.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class NativeWindow {
9999
virtual void SetPosition(const gfx::Point& position) = 0;
100100
virtual gfx::Point GetPosition() = 0;
101101
virtual void SetTitle(const std::string& title) = 0;
102-
virtual void FlashFrame(bool flash) = 0;
102+
virtual void FlashFrame(int count) = 0;
103103
virtual void SetBadgeLabel(const std::string& badge) = 0;
104104
virtual void SetKiosk(bool kiosk) = 0;
105105
virtual bool IsKiosk() = 0;

src/browser/native_window_gtk.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ void NativeWindowGtk::SetTitle(const std::string& title) {
294294
gtk_window_set_title(GTK_WINDOW(window_), title.c_str());
295295
}
296296

297-
void NativeWindowGtk::FlashFrame(bool flash) {
298-
gtk_window_set_urgency_hint(window_, flash);
297+
void NativeWindowGtk::FlashFrame(int count) {
298+
gtk_window_set_urgency_hint(window_, count);
299299
}
300300

301301
void NativeWindowGtk::SetBadgeLabel(const std::string& badge) {

src/browser/native_window_gtk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class NativeWindowGtk : public NativeWindow {
5959
virtual void SetPosition(const gfx::Point& position) OVERRIDE;
6060
virtual gfx::Point GetPosition() OVERRIDE;
6161
virtual void SetTitle(const std::string& title) OVERRIDE;
62-
virtual void FlashFrame(bool flash) OVERRIDE;
62+
virtual void FlashFrame(int count) OVERRIDE;
6363
virtual void SetBadgeLabel(const std::string& badge) OVERRIDE;
6464
virtual void SetKiosk(bool kiosk) OVERRIDE;
6565
virtual bool IsKiosk() OVERRIDE;

src/browser/native_window_mac.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class NativeWindowCocoa : public NativeWindow {
6363
virtual void SetPosition(const gfx::Point& position) OVERRIDE;
6464
virtual gfx::Point GetPosition() OVERRIDE;
6565
virtual void SetTitle(const std::string& title) OVERRIDE;
66-
virtual void FlashFrame(bool flash) OVERRIDE;
66+
virtual void FlashFrame(int count) OVERRIDE;
6767
virtual void SetBadgeLabel(const std::string& badge) OVERRIDE;
6868
virtual void SetKiosk(bool kiosk) OVERRIDE;
6969
virtual bool IsKiosk() OVERRIDE;

src/browser/native_window_mac.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,9 +636,9 @@ - (NSRect)contentRectForFrameRect:(NSRect)frameRect {
636636
[window() setTitle:base::SysUTF8ToNSString(title)];
637637
}
638638

639-
void NativeWindowCocoa::FlashFrame(bool flash) {
640-
if (flash) {
641-
attention_request_id_ = [NSApp requestUserAttention:NSInformationalRequest];
639+
void NativeWindowCocoa::FlashFrame(int count) {
640+
if (count != 0) {
641+
attention_request_id_ = count < 0 ? [NSApp requestUserAttention:NSInformationalRequest] : [NSApp requestUserAttention:NSCriticalRequest];
642642
} else {
643643
[NSApp cancelUserAttentionRequest:attention_request_id_];
644644
attention_request_id_ = 0;

src/browser/native_window_win.cc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,19 @@ gfx::Point NativeWindowWin::GetPosition() {
479479
return window_->GetWindowBoundsInScreen().origin();
480480
}
481481

482-
void NativeWindowWin::FlashFrame(bool flash) {
483-
window_->FlashFrame(flash);
482+
void NativeWindowWin::FlashFrame(int count) {
483+
FLASHWINFO fwi;
484+
fwi.cbSize = sizeof(fwi);
485+
fwi.hwnd = views::HWNDForWidget(window_);
486+
if (count != 0) {
487+
fwi.dwFlags = FLASHW_ALL;
488+
fwi.uCount = count < 0 ? 4 : count;
489+
fwi.dwTimeout = 0;
490+
}
491+
else {
492+
fwi.dwFlags = FLASHW_STOP;
493+
}
494+
FlashWindowEx(&fwi);
484495
}
485496

486497
HICON createBadgeIcon(const HWND hWnd, const TCHAR *value, const int sizeX, const int sizeY) {

src/browser/native_window_win.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class NativeWindowWin : public NativeWindow,
8484
virtual void SetPosition(const gfx::Point& position) OVERRIDE;
8585
virtual gfx::Point GetPosition() OVERRIDE;
8686
virtual void SetTitle(const std::string& title) OVERRIDE;
87-
virtual void FlashFrame(bool flash) OVERRIDE;
87+
virtual void FlashFrame(int count) OVERRIDE;
8888
virtual void SetKiosk(bool kiosk) OVERRIDE;
8989
virtual void SetBadgeLabel(const std::string& badge) OVERRIDE;
9090
virtual bool IsKiosk() OVERRIDE;

0 commit comments

Comments
 (0)