31 HINSTANCE hInstance = (HINSTANCE)platformData;
34 if (!
window->init(hInstance)) {
42void Window_win::closeWindow() {
44 if (GetWindowRect(fHWnd, &r)) {
61 fHInstance = hInstance ? hInstance : GetModuleHandle(
nullptr);
64 static const TCHAR gSZWindowClass[] = _T(
"SkiaApp");
66 static WNDCLASSEX wcex;
67 static bool wcexInit =
false;
69 wcex.cbSize =
sizeof(WNDCLASSEX);
71 wcex.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
75 wcex.hInstance = fHInstance;
76 wcex.hIcon =
LoadIcon(fHInstance, (LPCTSTR)IDI_WINLOGO);
77 wcex.hCursor = LoadCursor(
nullptr, IDC_ARROW);
78 wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
79 wcex.lpszMenuName =
nullptr;
80 wcex.lpszClassName = gSZWindowClass;
81 wcex.hIconSm =
LoadIcon(fHInstance, (LPCTSTR)IDI_WINLOGO);
83 if (!RegisterClassEx(&wcex)) {
110 fHWnd = CreateWindow(gSZWindowClass,
nullptr, WS_OVERLAPPEDWINDOW,
112 nullptr,
nullptr, fHInstance,
nullptr);
118 SetWindowLongPtr(fHWnd, GWLP_USERDATA, (
LONG_PTR)
this);
119 RegisterTouchWindow(fHWnd, 0);
125 static const struct {
154 if (gPair[
i].fVK ==
vk) {
155 return gPair[
i].fKey;
167 if (0 == (lParam & (1 << 30))) {
170 if (lParam & (1 << 29)) {
177 if (0 == (lParam & (1 << 30))) {
180 if (lParam & (1 << 29)) {
187 if (lParam & (1 << 29)) {
196 if (wParam & MK_CONTROL) {
199 if (wParam & MK_SHIFT) {
214 bool eventHandled =
false;
218 BeginPaint(hWnd, &ps);
234 window->onResize(LOWORD(lParam), HIWORD(lParam));
244 const uint16_t* cPtr =
reinterpret_cast<uint16_t*
>(&wParam);
263 int xPos = GET_X_LPARAM(lParam);
264 int yPos = GET_Y_LPARAM(lParam);
277 eventHandled =
window->onMouse(xPos, yPos, istate,
282 int xPos = GET_X_LPARAM(lParam);
283 int yPos = GET_Y_LPARAM(lParam);
297 case WM_MOUSEWHEEL: {
298 int xPos = GET_X_LPARAM(lParam);
299 int yPos = GET_Y_LPARAM(lParam);
300 eventHandled =
window->onMouseWheel(GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f,
307 uint16_t numInputs = LOWORD(wParam);
308 std::unique_ptr<TOUCHINPUT[]>
inputs(
new TOUCHINPUT[numInputs]);
309 if (GetTouchInputInfo((HTOUCHINPUT)lParam, numInputs,
inputs.get(),
310 sizeof(TOUCHINPUT))) {
311 POINT topLeft = {0, 0};
312 ClientToScreen(hWnd, &topLeft);
313 for (uint16_t
i = 0;
i < numInputs; ++
i) {
316 if (ti.dwFlags & TOUCHEVENTF_DOWN) {
318 }
else if (ti.dwFlags & TOUCHEVENTF_MOVE) {
320 }
else if (ti.dwFlags & TOUCHEVENTF_UP) {
327 LONG tx = (ti.x / 100) - topLeft.x;
328 LONG ty = (ti.y / 100) - topLeft.y;
329 eventHandled =
window->onTouch(ti.dwID,
state, tx, ty) || eventHandled;
335 return DefWindowProc(hWnd,
message, wParam, lParam);
338 return eventHandled ? 0 : 1;
342 SetWindowTextA(fHWnd, title);
346 ShowWindow(fHWnd, SW_SHOW);
351 fBackend = attachType;
352 fInitializedBackend =
true;
354 switch (attachType) {
356 case kNativeGL_BackendType:
361 case kANGLE_BackendType:
366#if defined(SK_GRAPHITE)
367 case kGraphiteDawn_BackendType:
376 case kVulkan_BackendType:
379#if defined(SK_GRAPHITE)
380 case kGraphiteVulkan_BackendType:
386 case kDirect3D_BackendType:
397 InvalidateRect(fHWnd,
nullptr,
false);
402 if (
params.fMSAASampleCount != this->getRequestedDisplayParams().fMSAASampleCount
409 this->
init(fHInstance);
410 if (fInitializedBackend) {
static constexpr bool SkToBool(const T &x)
void setRequestedDisplayParams(const DisplayParams &, bool allowReattach) override
bool init(HINSTANCE instance)
bool attach(BackendType) override
void setTitle(const char *) override
static Window * CreateNativeWindow(void *platformData)
virtual void setRequestedDisplayParams(const DisplayParams &, bool allowReattach=true)
DisplayParams fRequestedDisplayParams
std::unique_ptr< skwindow::WindowContext > fWindowContext
const EmbeddedViewParams * params
SK_SPI SkUnichar NextUTF16(const uint16_t **ptr, const uint16_t *end)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
static skui::ModifierKey get_modifiers(const XEvent &event)
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
static skui::Key get_key(KeySym keysym)
@ kHome
the home key - added to match android
std::unique_ptr< WindowContext > MakeVulkanForWin(HWND hwnd, const DisplayParams ¶ms)
std::unique_ptr< WindowContext > MakeD3D12ForWin(HWND hwnd, const DisplayParams ¶ms)
std::unique_ptr< WindowContext > MakeRasterForWin(HWND wnd, const DisplayParams ¶ms)
std::unique_ptr< WindowContext > MakeANGLEForWin(HWND wnd, const DisplayParams ¶ms)
std::unique_ptr< WindowContext > MakeGLForWin(HWND wnd, const DisplayParams ¶ms)
std::unique_ptr< WindowContext > MakeGraphiteDawnD3D12ForWin(HWND hwnd, const DisplayParams ¶ms)
std::unique_ptr< WindowContext > MakeGraphiteVulkanForWin(HWND hwnd, const DisplayParams ¶ms)