skia2/tools/sk_app/mac/Window_mac.h
Jim Van Verth e94af49a3f Fix a couple of Mac windowing issues.
* Set correct backing size for Metal and Vulkan
* Don't capture mouse events when resizing

Bug: skia:8737
Change-Id: I7798ca95aebe0c11b75b23a55a94514550317b32
Reviewed-on: https://skia-review.googlesource.com/c/196423
Auto-Submit: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-02-28 19:24:52 +00:00

74 lines
1.5 KiB
Objective-C

/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef Window_mac_DEFINED
#define Window_mac_DEFINED
#include "../Window.h"
#include "SkTDynamicHash.h"
#import <Cocoa/Cocoa.h>
namespace sk_app {
class Window_mac : public Window {
public:
Window_mac()
: INHERITED()
, fWindow(nil)
, fMSAASampleCount(1)
, fIsMouseDown(false) {}
~Window_mac() override {
this->closeWindow();
}
bool initWindow();
void setTitle(const char*) override;
void show() override;
bool attach(BackendType) override;
void onInval() override {}
static void PaintWindows();
static void HandleWindowEvent(const NSEvent* event);
static const NSInteger& GetKey(const Window_mac& w) {
return w.fWindowNumber;
}
static uint32_t Hash(const NSInteger& windowNumber) {
return windowNumber;
}
bool needsPaint() { return this->fIsContentInvalidated; }
NSWindow* window() { return fWindow; }
void closeWindow();
void resetMouse();
private:
void handleEvent(const NSEvent* event);
NSWindow* fWindow;
NSInteger fWindowNumber;
int fMSAASampleCount;
bool fIsMouseDown;
NSPoint fMouseDownPos;
uint32_t fMouseModifiers;
static SkTDynamicHash<Window_mac, NSInteger> gWindowMap;
typedef Window INHERITED;
};
} // namespace sk_app
#endif