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

@creeperxie
Copy link

Choose a reason for hiding this comment

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

Thank you very much.

@dontbethatguy209
Copy link

@dontbethatguy209 dontbethatguy209 commented on 45c024a May 9, 2024 via email

Choose a reason for hiding this comment

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

Please sign in to comment.