Skip to content

Commit

Permalink
Remove the dependency on WTL from renderer_style_handler.cc
Browse files Browse the repository at this point in the history
This commit updates

  renderer_style_handler.cc

with WIL so as not to depend on WTL (#861).

This is a mechanical code change. There must be no observable behavior
change.

#codehealth

PiperOrigin-RevId: 599404848
  • Loading branch information
yukawa authored and hiroyuki-komatsu committed Jan 18, 2024
1 parent 0c7ed79 commit 827ec31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
9 changes: 6 additions & 3 deletions src/renderer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ load(
"BRANDING",
"MACOS_BUNDLE_ID_PREFIX",
)
load("//bazel/win32:build_defs.bzl", "copts_wtl", "features_gdi")
load("//bazel/win32:build_defs.bzl", "features_gdi")

package(default_visibility = ["//:__subpackages__"])

Expand Down Expand Up @@ -214,13 +214,16 @@ mozc_cc_library(
name = "renderer_style_handler",
srcs = ["renderer_style_handler.cc"],
hdrs = ["renderer_style_handler.h"],
copts = copts_wtl(), # for Windows
features = features_gdi(), # for Windows
deps = [
"//base:singleton",
"//protocol:renderer_cc_proto",
] + mozc_select(
windows = ["//third_party/wtl"],
windows = [
"//bazel/win32:gdi32",
"//bazel/win32:user32",
"@com_microsoft_wil//:wil",
],
),
)

Expand Down
12 changes: 4 additions & 8 deletions src/renderer/renderer_style_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@

#include "renderer/renderer_style_handler.h"

// clang-format off
#if defined(_WIN32)
#include <windows.h>
#include <atlbase.h>
#include <atlapp.h>
#include <atlgdi.h>
#include <wil/resource.h>
#endif // _WIN32
// clang-format on

#include "base/singleton.h"
#include "protocol/renderer_style.pb.h"
Expand Down Expand Up @@ -205,9 +201,9 @@ void RendererStyleHandler::GetDefaultRendererStyle(RendererStyle *style) {

void RendererStyleHandler::GetDPIScalingFactor(double *x, double *y) {
#ifdef _WIN32
WTL::CDC desktop_dc(::GetDC(nullptr));
const int dpi_x = desktop_dc.GetDeviceCaps(LOGPIXELSX);
const int dpi_y = desktop_dc.GetDeviceCaps(LOGPIXELSY);
wil::unique_hdc_window desktop_dc(::GetDC(nullptr));
const int dpi_x = ::GetDeviceCaps(desktop_dc.get(), LOGPIXELSX);
const int dpi_y = ::GetDeviceCaps(desktop_dc.get(), LOGPIXELSY);
if (x != nullptr) {
*x = static_cast<double>(dpi_x) / kDefaultDPI;
}
Expand Down

0 comments on commit 827ec31

Please sign in to comment.