Skip to content

Commit

Permalink
Revert "Destroy virtual keyboard when it is not activated."
Browse files Browse the repository at this point in the history
This reverts commit b2924bd.

While I don't think it's doing anything wrong, but many wlroots
comopsitor does not like this and may make Gtk app choke.

(#1044, #1037, #1039)
swaywm/sway#8143
  • Loading branch information
wengxt committed May 7, 2024
1 parent a6ec0bd commit 45c024a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
20 changes: 8 additions & 12 deletions src/frontend/waylandim/waylandimserverv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ void WaylandIMServerV2::refreshSeat() {
if (icMap_.count(seat.get())) {
continue;
}
auto *ic =
new WaylandIMInputContextV2(inputContextManager(), this, seat);
auto *ic = new WaylandIMInputContextV2(
inputContextManager(), this, seat,
virtualKeyboardManagerV1_->createVirtualKeyboard(seat.get()));
ic->setFocusGroup(group_);
ic->setCapabilityFlags(baseFlags);
}
Expand All @@ -121,10 +122,11 @@ void WaylandIMServerV2::remove(wayland::WlSeat *seat) {

WaylandIMInputContextV2::WaylandIMInputContextV2(
InputContextManager &inputContextManager, WaylandIMServerV2 *server,
std::shared_ptr<wayland::WlSeat> seat)
std::shared_ptr<wayland::WlSeat> seat, wayland::ZwpVirtualKeyboardV1 *vk)
: VirtualInputContextGlue(inputContextManager), server_(server),
seat_(std::move(seat)),
ic_(server->inputMethodManagerV2()->getInputMethod(seat_.get())) {
ic_(server->inputMethodManagerV2()->getInputMethod(seat_.get())),
vk_(vk) {
server->add(this, seat_.get());
ic_->surroundingText().connect(
[this](const char *text, uint32_t cursor, uint32_t anchor) {
Expand Down Expand Up @@ -162,19 +164,13 @@ WaylandIMInputContextV2::WaylandIMInputContextV2(
Key(FcitxKey_None, KeyStates(), vkkey + 8),
WL_KEYBOARD_KEY_STATE_RELEASED);
}
vk_->modifiers(0, 0, 0, 0);
}
focusOutWrapper();
}
vk_.reset();
vkReady_ = false;
}
if (pendingActivate_) {
pendingActivate_ = false;
vk_.reset();
vkReady_ = false;
vk_.reset(
server_->virtualKeyboardManagerV1()->createVirtualKeyboard(
seat_.get()));
// There can be only one grab. Always release old grab first.
// It is possible when switching between two client, there will be
// two activate. In that case we will have already one grab. The
Expand Down Expand Up @@ -424,7 +420,7 @@ void WaylandIMInputContextV2::keymapCallback(uint32_t format, int32_t fd,
server_->stateMask_.mod5_mask =
1 << xkb_keymap_mod_get_index(server_->keymap_.get(), "Mod5");

if (keymapChanged || !vkReady_) {
if (keymapChanged) {
vk_->keymap(format, scopeFD.fd(), size);
vkReady_ = true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/waylandim/waylandimserverv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class WaylandIMServerV2 : public WaylandIMServerBase {
FocusGroup *group() { return group_; }
auto *xkbState() { return state_.get(); }
auto *inputMethodManagerV2() { return inputMethodManagerV2_.get(); }
auto *virtualKeyboardManagerV1() { return virtualKeyboardManagerV1_.get(); }

bool hasKeyboardGrab() const;

Expand Down Expand Up @@ -73,7 +72,8 @@ class WaylandIMInputContextV2 : public VirtualInputContextGlue {
public:
WaylandIMInputContextV2(InputContextManager &inputContextManager,
WaylandIMServerV2 *server,
std::shared_ptr<wayland::WlSeat> seat);
std::shared_ptr<wayland::WlSeat> seat,
wayland::ZwpVirtualKeyboardV1 *vk);
~WaylandIMInputContextV2() override;

const char *frontend() const override { return "wayland_v2"; }
Expand Down

2 comments on commit 45c024a

@dontbethatguy209

This comment was marked as spam.

@tokyo4j
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This revert causes labwc's window switcher to be terminated when switching between text-input-v3 enabled clients with Alt-Tab.

I haven't looked deeper into the context of this revert and I guess @wengxt already acknowledges a similar misbehavior in Hyprland (from the commit message of b2924bd).
So take this comment just as a notice that this revert broke something in labwc.

Please sign in to comment.