@@ -70,7 +70,7 @@ + (void)setVisibility:(SetVisibilityParams*)params;
70
70
// Java provides an NSApplicationAWT implementation that we can't access or
71
71
// override directly. Therefore add the necessary CefAppProtocol
72
72
// functionality to NSApplication using categories and swizzling.
73
- @interface NSApplication (JCEFApplication)<CefAppProtocol>
73
+ @interface NSApplication (JCEFApplication) <CefAppProtocol>
74
74
75
75
- (BOOL )isHandlingSendEvent ;
76
76
- (void )setHandlingSendEvent : (BOOL )handlingSendEvent ;
@@ -109,10 +109,9 @@ + (void)load {
109
109
NSMouseEnteredMask |
110
110
NSMouseExitedMask )
111
111
handler: ^(NSEvent * evt) {
112
-
113
112
// Get corresponding CefWindowHandle of
114
113
// Java-Canvas
115
- CefWindowHandle browser = NULL ;
114
+ NSView * browser = NULL ;
116
115
NSPoint absPos = [evt locationInWindow ];
117
116
NSWindow * evtWin = [evt window ];
118
117
g_browsers_lock_.Lock ();
@@ -123,12 +122,15 @@ + (void)load {
123
122
std::set<CefWindowHandle>::iterator it;
124
123
for (it = browsers.begin ();
125
124
it != browsers.end (); ++it) {
126
- NSPoint relPos = [*it convertPoint: absPos
127
- fromView: nil ];
128
- if (evtWin == [*it window ] &&
129
- [*it mouse: relPos
130
- inRect: [*it frame ]]) {
131
- browser = *it;
125
+ NSView * wh =
126
+ CAST_CEF_WINDOW_HANDLE_TO_NSVIEW (
127
+ *it);
128
+ NSPoint relPos = [wh convertPoint: absPos
129
+ fromView: nil ];
130
+ if (evtWin == [wh window ] &&
131
+ [wh mouse: relPos
132
+ inRect: [wh frame ]]) {
133
+ browser = wh;
132
134
break ;
133
135
}
134
136
}
@@ -235,11 +237,12 @@ + (void)doMessageLoopWork {
235
237
236
238
+ (void )setVisibility : (SetVisibilityParams*)params {
237
239
if (g_client_app_) {
238
- bool isHidden = [params->handle_ isHidden ];
240
+ NSView * wh = CAST_CEF_WINDOW_HANDLE_TO_NSVIEW (params->handle_ );
241
+ bool isHidden = [wh isHidden ];
239
242
if (isHidden == params->isVisible_ ) {
240
- [params->handle_ setHidden: !params->isVisible_];
241
- [params->handle_ needsDisplay ];
242
- [[params->handle_ superview ] display ];
243
+ [wh setHidden: !params->isVisible_];
244
+ [wh needsDisplay ];
245
+ [[wh superview ] display ];
243
246
}
244
247
}
245
248
[params release ];
@@ -392,7 +395,7 @@ bool IsNSView(void* ptr) {
392
395
}
393
396
394
397
CefWindowHandle CreateBrowserContentView (NSWindow * window, CefRect& orig) {
395
- NSView * mainView = (CefWindowHandle) [window contentView ];
398
+ NSView * mainView = CAST_CEF_WINDOW_HANDLE_TO_NSVIEW ( [window contentView ]) ;
396
399
TranslateRect (mainView, orig);
397
400
NSRect frame = {{orig.x , orig.y }, {orig.width , orig.height }};
398
401
@@ -419,7 +422,8 @@ CefWindowHandle CreateBrowserContentView(NSWindow* window, CefRect& orig) {
419
422
420
423
// translate java's window origin to Obj-C's window origin
421
424
void TranslateRect (CefWindowHandle view, CefRect& orig) {
422
- NSRect bounds = [[[view window ] contentView ] bounds ];
425
+ NSRect bounds =
426
+ [[[CAST_CEF_WINDOW_HANDLE_TO_NSVIEW (view) window ] contentView ] bounds ];
423
427
orig.y = bounds.size .height - orig.height - orig.y ;
424
428
}
425
429
@@ -467,7 +471,9 @@ void UpdateView(CefWindowHandle handle,
467
471
CefRect contentRect,
468
472
CefRect browserRect) {
469
473
util_mac::TranslateRect (handle, contentRect);
470
- CefBrowserContentView* browser = (CefBrowserContentView*)[handle superview ];
474
+ CefBrowserContentView* browser =
475
+ (CefBrowserContentView*)[CAST_CEF_WINDOW_HANDLE_TO_NSVIEW (handle)
476
+ superview ];
471
477
browserRect.y = contentRect.height - browserRect.height - browserRect.y ;
472
478
473
479
// Only update the view if nobody is currently resizing the main window.
@@ -502,14 +508,16 @@ void AddCefBrowser(CefRefPtr<CefBrowser> browser) {
502
508
g_browsers_.insert (handle);
503
509
g_browsers_lock_.Unlock ();
504
510
CefBrowserContentView* browserImpl =
505
- (CefBrowserContentView*)[handle superview ];
511
+ (CefBrowserContentView*)[CAST_CEF_WINDOW_HANDLE_TO_NSVIEW (handle)
512
+ superview ];
506
513
[browserImpl addCefBrowser: browser];
507
514
}
508
515
509
516
void DestroyCefBrowser (CefRefPtr<CefBrowser> browser) {
510
517
if (!browser.get ())
511
518
return ;
512
- CefWindowHandle handle = browser->GetHost ()->GetWindowHandle ();
519
+ NSView * handle =
520
+ CAST_CEF_WINDOW_HANDLE_TO_NSVIEW (browser->GetHost ()->GetWindowHandle ());
513
521
g_browsers_lock_.Lock ();
514
522
g_browsers_.erase (handle);
515
523
g_browsers_lock_.Unlock ();
@@ -531,7 +539,8 @@ void SetParent(CefWindowHandle handle,
531
539
base::Closure* pCallback = new base::Closure (callback);
532
540
dispatch_async (dispatch_get_main_queue (), ^{
533
541
CefBrowserContentView* browser_view =
534
- (CefBrowserContentView*)[handle superview ];
542
+ (CefBrowserContentView*)[CAST_CEF_WINDOW_HANDLE_TO_NSVIEW (handle)
543
+ superview ];
535
544
[browser_view retain ];
536
545
[browser_view removeFromSuperview ];
537
546
@@ -540,7 +549,8 @@ void SetParent(CefWindowHandle handle,
540
549
NSWindow * window = (NSWindow *)parentHandle;
541
550
contentView = [window contentView ];
542
551
} else {
543
- contentView = TempWindow::GetWindowHandle ();
552
+ contentView =
553
+ CAST_CEF_WINDOW_HANDLE_TO_NSVIEW (TempWindow::GetWindowHandle ());
544
554
}
545
555
[contentView addSubview: browser_view];
546
556
[browser_view release ];
0 commit comments