UI/Qt: Restore AppKit focus before focusing location edit
After web content has focus on macOS, its native QRhiWidget can remain the AppKit first responder even after Qt focuses the location edit. Make the top-level Qt content view first responder before focusing the location edit so keyboard input returns to chrome.
This commit is contained in:
parent
2f0fe26ce9
commit
702904f6b3
3 changed files with 24 additions and 0 deletions
|
|
@ -17,6 +17,7 @@ namespace Ladybird {
|
|||
void set_rounded_window_corners(QWidget&, bool enabled, double radius, QColor const& background_color);
|
||||
void install_always_active_window_control_hover_tracking(QWidget&, void (*hover_changed)(QWidget*));
|
||||
void install_appkit_event_capture();
|
||||
void make_appkit_window_first_responder(QWidget&);
|
||||
bool start_appkit_window_drag(QWidget&);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -176,6 +176,23 @@ void install_always_active_window_control_hover_tracking(QWidget& widget, void (
|
|||
#endif
|
||||
}
|
||||
|
||||
void make_appkit_window_first_responder(QWidget& widget)
|
||||
{
|
||||
auto* window_widget = widget.window();
|
||||
if (!window_widget)
|
||||
return;
|
||||
|
||||
auto* view = reinterpret_cast<NSView*>(window_widget->winId());
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
auto* window = view.window;
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
[window makeFirstResponder:view];
|
||||
}
|
||||
|
||||
bool start_appkit_window_drag(QWidget& widget)
|
||||
{
|
||||
auto* window_widget = widget.window();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
#include <UI/Qt/ChromeLayout.h>
|
||||
#include <UI/Qt/ChromeStyle.h>
|
||||
#include <UI/Qt/Icon.h>
|
||||
#if defined(AK_OS_MACOS)
|
||||
# include <UI/Qt/MacWindow.h>
|
||||
#endif
|
||||
#include <UI/Qt/Menu.h>
|
||||
#include <UI/Qt/StringUtils.h>
|
||||
#include <UI/Qt/WindowControlButton.h>
|
||||
|
|
@ -598,6 +601,9 @@ Tab::~Tab() = default;
|
|||
|
||||
void Tab::focus_location_editor()
|
||||
{
|
||||
#if defined(AK_OS_MACOS)
|
||||
make_appkit_window_first_responder(*m_location_edit);
|
||||
#endif
|
||||
m_location_edit->setFocus();
|
||||
m_location_edit->selectAll();
|
||||
m_location_edit->show_autocomplete();
|
||||
|
|
|
|||
Loading…
Reference in a new issue