chore: fix chromium-style errors in windows code
This commit is contained in:
parent
aa4ca406c8
commit
43c1a7778d
11 changed files with 56 additions and 47 deletions
|
@ -35,7 +35,7 @@ namespace brightray {
|
|||
class NotificationPresenterWin : public NotificationPresenter {
|
||||
public:
|
||||
NotificationPresenterWin();
|
||||
~NotificationPresenterWin();
|
||||
~NotificationPresenterWin() override;
|
||||
|
||||
bool Init();
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ brightray::Notification* NotificationPresenterWin7::CreateNotificationObject(
|
|||
|
||||
Win32Notification* NotificationPresenterWin7::GetNotificationObjectByRef(
|
||||
const DesktopNotificationController::Notification& ref) {
|
||||
for (auto n : this->notifications()) {
|
||||
auto w32n = static_cast<Win32Notification*>(n);
|
||||
for (auto* n : this->notifications()) {
|
||||
auto* w32n = static_cast<Win32Notification*>(n);
|
||||
if (w32n->GetRef() == ref)
|
||||
return w32n;
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ Win32Notification* NotificationPresenterWin7::GetNotificationObjectByRef(
|
|||
|
||||
Win32Notification* NotificationPresenterWin7::GetNotificationObjectByTag(
|
||||
const std::string& tag) {
|
||||
for (auto n : this->notifications()) {
|
||||
auto w32n = static_cast<Win32Notification*>(n);
|
||||
for (auto* n : this->notifications()) {
|
||||
auto* w32n = static_cast<Win32Notification*>(n);
|
||||
if (w32n->GetTag() == tag)
|
||||
return w32n;
|
||||
}
|
||||
|
@ -35,14 +35,14 @@ Win32Notification* NotificationPresenterWin7::GetNotificationObjectByTag(
|
|||
|
||||
void NotificationPresenterWin7::OnNotificationClicked(
|
||||
Notification& notification) {
|
||||
auto n = GetNotificationObjectByRef(notification);
|
||||
auto* n = GetNotificationObjectByRef(notification);
|
||||
if (n)
|
||||
n->NotificationClicked();
|
||||
}
|
||||
|
||||
void NotificationPresenterWin7::OnNotificationDismissed(
|
||||
Notification& notification) {
|
||||
auto n = GetNotificationObjectByRef(notification);
|
||||
auto* n = GetNotificationObjectByRef(notification);
|
||||
if (n)
|
||||
n->NotificationDismissed();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ struct ScreenMetrics {
|
|||
GetProcAddress(GetModuleHandle(TEXT("shcore")), "GetDpiForMonitor"));
|
||||
|
||||
if (GetDpiForMonitor) {
|
||||
auto monitor = MonitorFromPoint({}, MONITOR_DEFAULTTOPRIMARY);
|
||||
auto* monitor = MonitorFromPoint({}, MONITOR_DEFAULTTOPRIMARY);
|
||||
if (GetDpiForMonitor(monitor, 0, &dpi_x, &dpi_y) == S_OK)
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ LRESULT CALLBACK DesktopNotificationController::WndProc(HWND hwnd,
|
|||
LPARAM lparam) {
|
||||
switch (message) {
|
||||
case WM_CREATE: {
|
||||
auto& cs = reinterpret_cast<const CREATESTRUCT*&>(lparam);
|
||||
auto*& cs = reinterpret_cast<const CREATESTRUCT*&>(lparam);
|
||||
SetWindowLongPtr(hwnd, 0, (LONG_PTR)cs->lpCreateParams);
|
||||
} break;
|
||||
|
||||
|
@ -94,7 +94,7 @@ LRESULT CALLBACK DesktopNotificationController::WndProc(HWND hwnd,
|
|||
return 0;
|
||||
|
||||
case WM_DISPLAYCHANGE: {
|
||||
auto inst = Get(hwnd);
|
||||
auto* inst = Get(hwnd);
|
||||
inst->ClearAssets();
|
||||
inst->AnimateAll();
|
||||
} break;
|
||||
|
@ -182,13 +182,13 @@ void DesktopNotificationController::AnimateAll() {
|
|||
POINT origin = {work_area.right,
|
||||
work_area.bottom - metrics.Y(toast_margin_)};
|
||||
|
||||
auto hdwp = BeginDeferWindowPos(static_cast<int>(instances_.size()));
|
||||
auto* hdwp = BeginDeferWindowPos(static_cast<int>(instances_.size()));
|
||||
|
||||
for (auto&& inst : instances_) {
|
||||
if (!inst.hwnd)
|
||||
continue;
|
||||
|
||||
auto notification = Toast::Get(inst.hwnd);
|
||||
auto* notification = Toast::Get(inst.hwnd);
|
||||
hdwp = notification->Animate(hdwp, origin);
|
||||
if (!hdwp)
|
||||
break;
|
||||
|
@ -245,7 +245,7 @@ void DesktopNotificationController::AnimateAll() {
|
|||
int target_pos = 0;
|
||||
for (auto&& inst : instances_) {
|
||||
if (inst.hwnd) {
|
||||
auto toast = Toast::Get(inst.hwnd);
|
||||
auto* toast = Toast::Get(inst.hwnd);
|
||||
|
||||
if (toast->IsHighlighted())
|
||||
target_pos = toast->GetVerticalPosition();
|
||||
|
@ -288,9 +288,9 @@ void DesktopNotificationController::CloseNotification(
|
|||
}
|
||||
|
||||
// Dismiss active toast
|
||||
auto hwnd = GetToast(notification.data_.get());
|
||||
auto* hwnd = GetToast(notification.data_.get());
|
||||
if (hwnd) {
|
||||
auto toast = Toast::Get(hwnd);
|
||||
auto* toast = Toast::Get(hwnd);
|
||||
toast->Dismiss();
|
||||
}
|
||||
}
|
||||
|
@ -303,8 +303,8 @@ void DesktopNotificationController::CheckQueue() {
|
|||
}
|
||||
|
||||
void DesktopNotificationController::CreateToast(NotificationLink&& data) {
|
||||
auto hinstance = RegisterWndClasses();
|
||||
auto hwnd = Toast::Create(hinstance, data);
|
||||
auto* hinstance = RegisterWndClasses();
|
||||
auto* hwnd = Toast::Create(hinstance, data);
|
||||
if (hwnd) {
|
||||
int toast_pos = 0;
|
||||
if (!instances_.empty()) {
|
||||
|
@ -312,7 +312,7 @@ void DesktopNotificationController::CreateToast(NotificationLink&& data) {
|
|||
_ASSERT(item.hwnd);
|
||||
|
||||
ScreenMetrics scr;
|
||||
auto toast = Toast::Get(item.hwnd);
|
||||
auto* toast = Toast::Get(item.hwnd);
|
||||
toast_pos = toast->GetVerticalPosition() + toast->GetHeight() +
|
||||
scr.Y(toast_margin_);
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ void DesktopNotificationController::CreateToast(NotificationLink&& data) {
|
|||
NULL, hinstance, this);
|
||||
}
|
||||
|
||||
auto toast = Toast::Get(hwnd);
|
||||
auto* toast = Toast::Get(hwnd);
|
||||
toast->PopUp(toast_pos);
|
||||
}
|
||||
}
|
||||
|
@ -356,12 +356,18 @@ void DesktopNotificationController::DestroyToast(ToastInstance& inst) {
|
|||
}
|
||||
}
|
||||
|
||||
DesktopNotificationController::Notification::Notification() = default;
|
||||
DesktopNotificationController::Notification::Notification(
|
||||
const DesktopNotificationController::Notification&) = default;
|
||||
|
||||
DesktopNotificationController::Notification::Notification(
|
||||
const shared_ptr<NotificationData>& data)
|
||||
: data_(data) {
|
||||
_ASSERT(data != nullptr);
|
||||
}
|
||||
|
||||
DesktopNotificationController::Notification::~Notification() = default;
|
||||
|
||||
bool DesktopNotificationController::Notification::operator==(
|
||||
const Notification& other) const {
|
||||
return data_ == other.data_;
|
||||
|
@ -392,9 +398,9 @@ void DesktopNotificationController::Notification::Set(std::wstring caption,
|
|||
data_->body_text = move(body_text);
|
||||
data_->image = CopyBitmap(image);
|
||||
|
||||
auto hwnd = data_->controller->GetToast(data_.get());
|
||||
auto* hwnd = data_->controller->GetToast(data_.get());
|
||||
if (hwnd) {
|
||||
auto toast = Toast::Get(hwnd);
|
||||
auto* toast = Toast::Get(hwnd);
|
||||
toast->ResetContents();
|
||||
}
|
||||
|
||||
|
@ -409,7 +415,7 @@ DesktopNotificationController::NotificationLink::NotificationLink(
|
|||
}
|
||||
|
||||
DesktopNotificationController::NotificationLink::~NotificationLink() {
|
||||
auto p = get();
|
||||
auto* p = get();
|
||||
if (p)
|
||||
p->controller = nullptr;
|
||||
}
|
||||
|
|
|
@ -88,8 +88,10 @@ class DesktopNotificationController {
|
|||
|
||||
class DesktopNotificationController::Notification {
|
||||
public:
|
||||
Notification() = default;
|
||||
Notification();
|
||||
explicit Notification(const std::shared_ptr<NotificationData>& data);
|
||||
Notification(const Notification&);
|
||||
~Notification();
|
||||
|
||||
bool operator==(const Notification& other) const;
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ static HBITMAP StretchBitmap(HBITMAP bitmap, unsigned width, unsigned height) {
|
|||
if (GetDIBits(hdc_screen, bitmap, 0, 0, 0,
|
||||
reinterpret_cast<BITMAPINFO*>(&bmi), DIB_RGB_COLORS) &&
|
||||
bmi.biSizeImage > 0 && (bmi.biSizeImage % 4) == 0) {
|
||||
auto buf = reinterpret_cast<BYTE*>(
|
||||
auto* buf = reinterpret_cast<BYTE*>(
|
||||
_aligned_malloc(bmi.biSizeImage, sizeof(DWORD)));
|
||||
|
||||
if (buf) {
|
||||
|
@ -117,12 +117,12 @@ static HBITMAP StretchBitmap(HBITMAP bitmap, unsigned width, unsigned height) {
|
|||
bmi.biCompression = BI_RGB;
|
||||
|
||||
void* color_bits;
|
||||
auto color_bitmap =
|
||||
auto* color_bitmap =
|
||||
CreateDIBSection(NULL, reinterpret_cast<BITMAPINFO*>(&bmi),
|
||||
DIB_RGB_COLORS, &color_bits, NULL, 0);
|
||||
|
||||
void* alpha_bits;
|
||||
auto alpha_bitmap =
|
||||
auto* alpha_bitmap =
|
||||
CreateDIBSection(NULL, reinterpret_cast<BITMAPINFO*>(&bmi),
|
||||
DIB_RGB_COLORS, &alpha_bits, NULL, 0);
|
||||
|
||||
|
@ -148,9 +148,9 @@ static HBITMAP StretchBitmap(HBITMAP bitmap, unsigned width, unsigned height) {
|
|||
GdiFlush();
|
||||
|
||||
// apply the alpha channel
|
||||
auto dest = reinterpret_cast<BYTE*>(color_bits);
|
||||
auto src = reinterpret_cast<const BYTE*>(alpha_bits);
|
||||
auto end = src + (width * height * 4);
|
||||
auto* dest = reinterpret_cast<BYTE*>(color_bits);
|
||||
auto* src = reinterpret_cast<const BYTE*>(alpha_bits);
|
||||
auto* end = src + (width * height * 4);
|
||||
while (src != end) {
|
||||
dest[3] = src[0];
|
||||
dest += 4;
|
||||
|
@ -214,10 +214,10 @@ LRESULT DesktopNotificationController::Toast::WndProc(HWND hwnd,
|
|||
LPARAM lparam) {
|
||||
switch (message) {
|
||||
case WM_CREATE: {
|
||||
auto& cs = reinterpret_cast<const CREATESTRUCT*&>(lparam);
|
||||
auto data =
|
||||
auto*& cs = reinterpret_cast<const CREATESTRUCT*&>(lparam);
|
||||
auto* data =
|
||||
static_cast<shared_ptr<NotificationData>*>(cs->lpCreateParams);
|
||||
auto inst = new Toast(hwnd, data);
|
||||
auto* inst = new Toast(hwnd, data);
|
||||
SetWindowLongPtr(hwnd, 0, (LONG_PTR)inst);
|
||||
} break;
|
||||
|
||||
|
@ -236,7 +236,7 @@ LRESULT DesktopNotificationController::Toast::WndProc(HWND hwnd,
|
|||
return 0;
|
||||
|
||||
case WM_LBUTTONDOWN: {
|
||||
auto inst = Get(hwnd);
|
||||
auto* inst = Get(hwnd);
|
||||
|
||||
inst->Dismiss();
|
||||
|
||||
|
@ -249,7 +249,7 @@ LRESULT DesktopNotificationController::Toast::WndProc(HWND hwnd,
|
|||
return 0;
|
||||
|
||||
case WM_MOUSEMOVE: {
|
||||
auto inst = Get(hwnd);
|
||||
auto* inst = Get(hwnd);
|
||||
if (!inst->is_highlighted_) {
|
||||
inst->is_highlighted_ = true;
|
||||
|
||||
|
@ -269,7 +269,7 @@ LRESULT DesktopNotificationController::Toast::WndProc(HWND hwnd,
|
|||
return 0;
|
||||
|
||||
case WM_MOUSELEAVE: {
|
||||
auto inst = Get(hwnd);
|
||||
auto* inst = Get(hwnd);
|
||||
inst->is_highlighted_ = false;
|
||||
inst->is_close_hot_ = false;
|
||||
inst->UpdateContents();
|
||||
|
@ -283,7 +283,7 @@ LRESULT DesktopNotificationController::Toast::WndProc(HWND hwnd,
|
|||
return 0;
|
||||
|
||||
case WM_WINDOWPOSCHANGED: {
|
||||
auto& wp = reinterpret_cast<WINDOWPOS*&>(lparam);
|
||||
auto*& wp = reinterpret_cast<WINDOWPOS*&>(lparam);
|
||||
if (wp->flags & SWP_HIDEWINDOW) {
|
||||
if (!IsWindowVisible(hwnd))
|
||||
Get(hwnd)->is_highlighted_ = false;
|
||||
|
@ -357,7 +357,7 @@ void DesktopNotificationController::Toast::Draw() {
|
|||
|
||||
// Draw background
|
||||
{
|
||||
auto brush = CreateSolidBrush(back_color);
|
||||
auto* brush = CreateSolidBrush(back_color);
|
||||
|
||||
RECT rc = {0, 0, toast_size_.cx, toast_size_.cy};
|
||||
FillRect(hdc_, &rc, brush);
|
||||
|
@ -368,8 +368,8 @@ void DesktopNotificationController::Toast::Draw() {
|
|||
SetBkMode(hdc_, TRANSPARENT);
|
||||
|
||||
const auto close = L'\x2715';
|
||||
auto caption_font = data_->controller->GetCaptionFont();
|
||||
auto body_font = data_->controller->GetBodyFont();
|
||||
auto* caption_font = data_->controller->GetCaptionFont();
|
||||
auto* body_font = data_->controller->GetBodyFont();
|
||||
|
||||
TEXTMETRIC tm_cap;
|
||||
SelectFont(hdc_, caption_font);
|
||||
|
@ -520,7 +520,7 @@ void DesktopNotificationController::Toast::UpdateBufferSize() {
|
|||
if (new_size.cx != this->toast_size_.cx ||
|
||||
new_size.cy != this->toast_size_.cy) {
|
||||
HDC hdc_screen = GetDC(NULL);
|
||||
auto new_bitmap =
|
||||
auto* new_bitmap =
|
||||
CreateCompatibleBitmap(hdc_screen, new_size.cx, new_size.cy);
|
||||
ReleaseDC(NULL, hdc_screen);
|
||||
|
||||
|
@ -733,7 +733,7 @@ HDWP DesktopNotificationController::Toast::Animate(HDWP hdwp,
|
|||
// ULWI fails, which can happen when one of the dimensions is zero (e.g.
|
||||
// at the beginning of ease-in).
|
||||
|
||||
auto ulw_result = UpdateLayeredWindowIndirect(hwnd_, &ulw);
|
||||
UpdateLayeredWindowIndirect(hwnd_, &ulw);
|
||||
hdwp = DeferWindowPos(hdwp, hwnd_, HWND_TOPMOST, pt.x, pt.y, size.cx, size.cy,
|
||||
dwpFlags);
|
||||
return hdwp;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
namespace brightray {
|
||||
|
||||
void Win32Notification::Show(const NotificationOptions& options) {
|
||||
auto presenter = static_cast<NotificationPresenterWin7*>(this->presenter());
|
||||
auto* presenter = static_cast<NotificationPresenterWin7*>(this->presenter());
|
||||
if (!presenter)
|
||||
return;
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ WindowsToastNotification::~WindowsToastNotification() {
|
|||
}
|
||||
|
||||
void WindowsToastNotification::Show(const NotificationOptions& options) {
|
||||
auto presenter_win = static_cast<NotificationPresenterWin*>(presenter());
|
||||
auto* presenter_win = static_cast<NotificationPresenterWin*>(presenter());
|
||||
std::wstring icon_path =
|
||||
presenter_win->SaveIconToFilesystem(options.icon, options.icon_url);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class WindowsToastNotification : public Notification {
|
|||
|
||||
WindowsToastNotification(NotificationDelegate* delegate,
|
||||
NotificationPresenter* presenter);
|
||||
~WindowsToastNotification();
|
||||
~WindowsToastNotification() override;
|
||||
|
||||
protected:
|
||||
// Notification:
|
||||
|
@ -108,7 +108,7 @@ class ToastEventHandler : public RuntimeClass<RuntimeClassFlags<ClassicCom>,
|
|||
DesktopToastFailedEventHandler> {
|
||||
public:
|
||||
explicit ToastEventHandler(Notification* notification);
|
||||
~ToastEventHandler();
|
||||
~ToastEventHandler() override;
|
||||
|
||||
IFACEMETHODIMP Invoke(
|
||||
ABI::Windows::UI::Notifications::IToastNotification* sender,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define BRIGHTRAY_COMMON_APPLICATION_INFO_H_
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "base/strings/string16.h"
|
||||
#include "brightray/browser/win/scoped_hstring.h"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -22,14 +22,14 @@ base::string16 g_app_user_model_id;
|
|||
const wchar_t kAppUserModelIDFormat[] = L"electron.app.$1";
|
||||
|
||||
std::string GetApplicationName() {
|
||||
auto module = GetModuleHandle(nullptr);
|
||||
auto* module = GetModuleHandle(nullptr);
|
||||
std::unique_ptr<FileVersionInfo> info(
|
||||
FileVersionInfo::CreateFileVersionInfoForModule(module));
|
||||
return base::UTF16ToUTF8(info->product_name());
|
||||
}
|
||||
|
||||
std::string GetApplicationVersion() {
|
||||
auto module = GetModuleHandle(nullptr);
|
||||
auto* module = GetModuleHandle(nullptr);
|
||||
std::unique_ptr<FileVersionInfo> info(
|
||||
FileVersionInfo::CreateFileVersionInfoForModule(module));
|
||||
return base::UTF16ToUTF8(info->product_version());
|
||||
|
|
Loading…
Reference in a new issue