cef/tests/cefsimple/simple_handler_mac.mm
Marshall Greenblatt 57bad703ee views: mac: Add CEF_SHOW_STATE_HIDDEN (fixes #3630)
- Adds `--initial-show-state=hidden` support for cefclient and cefsimple
  where the window launches as initially hidden (no dock thumbnail).
- Adds `--hide-window-on-close` support for cefclient where clicking the
  red traffic light button hides the window instead of closing it.
2024-01-30 12:16:03 -05:00

33 lines
995 B
Plaintext

// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "tests/cefsimple/simple_handler.h"
#import <Cocoa/Cocoa.h>
#include "include/cef_browser.h"
namespace {
NSWindow* GetNSWindowForBrowser(CefRefPtr<CefBrowser> browser) {
NSView* view =
CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(browser->GetHost()->GetWindowHandle());
return [view window];
}
} // namespace
void SimpleHandler::PlatformTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) {
NSWindow* window = GetNSWindowForBrowser(browser);
std::string titleStr(title);
NSString* str = [NSString stringWithUTF8String:titleStr.c_str()];
[window setTitle:str];
}
void SimpleHandler::PlatformShowWindow(CefRefPtr<CefBrowser> browser) {
NSWindow* window = GetNSWindowForBrowser(browser);
[window makeKeyAndOrderFront:window];
}