-
Notifications
You must be signed in to change notification settings - Fork 244
panel: Propagate "focus-in" event to browser host #508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -178,6 +178,8 @@ QCefWidgetInternal::QCefWidgetInternal(QWidget *parent, const std::string &url_, | |||||
| #ifndef __APPLE__ | ||||||
| window = new QWindow(); | ||||||
| window->setFlags(Qt::FramelessWindowHint); | ||||||
| window->setObjectName("QCefWidgetInternalWindow"); | ||||||
| window->installEventFilter(this); | ||||||
| #endif | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -186,6 +188,34 @@ QCefWidgetInternal::~QCefWidgetInternal() | |||||
| closeBrowser(); | ||||||
| } | ||||||
|
|
||||||
| bool QCefWidgetInternal::eventFilter(QObject *object, QEvent *event) | ||||||
| { | ||||||
| #ifdef __APPLE__ | ||||||
| UNUSED_PARAMETER(object); | ||||||
| UNUSED_PARAMETER(event); | ||||||
|
|
||||||
| return true; | ||||||
| #else | ||||||
| // Return early event does not target the window wrapper or no browser instance is present | ||||||
| if (object != window_ || !cefBrowser) { | ||||||
| return true; | ||||||
| } | ||||||
|
|
||||||
| // Also return early if the event is not a "FocusIn" event, only necessary to check if the wrapper is targeted | ||||||
| if (event->type() != QEvent::FocusIn) { | ||||||
| return true; | ||||||
| } | ||||||
|
|
||||||
| CefRefPtr<CefBrowserHost> host{cefBrowser->GetHost()}; | ||||||
|
|
||||||
| if (host) { | ||||||
| host->SetFocus(hasFocus); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Most checks in Qt are functions.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That should actually simply be Implicit type conversions are evil like that.. |
||||||
| } | ||||||
|
|
||||||
| return true; | ||||||
| #endif | ||||||
| } | ||||||
|
|
||||||
| void QCefWidgetInternal::closeBrowser() | ||||||
| { | ||||||
| if (!cefBrowser) { | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may have uncommitted code where you've renamed it, but currently it's called
window.