Skip to content

Commit

Permalink
Add emulate-im-popups feature
Browse files Browse the repository at this point in the history
  • Loading branch information
tadeokondrak committed Feb 8, 2024
1 parent 94c8e27 commit 6d615ee
Show file tree
Hide file tree
Showing 8 changed files with 525 additions and 13 deletions.
1 change: 1 addition & 0 deletions data/default_config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
active-at-startup
# emulate-im-popups

global-bindings {
Ctrl+Shift+Backspace toggle
Expand Down
6 changes: 6 additions & 0 deletions doc/anthywl.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ See https://git.sr.ht/~emersion/scfg for details.
}
```

*emulate-im-popups*:

When enabled, anthywl will mirror the contents of input method popups to a
layer-shell (overlay) window. This is useful for compositors that do not
yet support input method popups.

# ACTIONS

*enable*:
Expand Down
14 changes: 13 additions & 1 deletion include/anthywl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "input-method-unstable-v2-client-protocol.h"
#include "text-input-unstable-v3-client-protocol.h"
#include "virtual-keyboard-unstable-v1-client-protocol.h"
#include "wlr-layer-shell-unstable-v1-client-protocol.h"

#include "actions.h"
#include "buffer.h"
Expand Down Expand Up @@ -48,6 +49,7 @@ struct anthywl_state {
struct wl_registry *wl_registry;
struct wl_compositor *wl_compositor;
struct wl_shm *wl_shm;
struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1;
struct zwp_input_method_manager_v2 *zwp_input_method_manager_v2;
struct zwp_virtual_keyboard_manager_v1 *zwp_virtual_keyboard_manager_v1;
struct wl_cursor_theme *wl_cursor_theme;
Expand Down Expand Up @@ -144,8 +146,10 @@ struct anthywl_seat {
anthy_context_t anthy_context;

// popup
struct wl_surface *wl_surface;
struct wl_surface *popup_wl_surface;
struct wl_surface *layer_wl_surface;
struct zwp_input_popup_surface_v2 *zwp_input_popup_surface_v2;
struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1;
};

struct anthywl_binding {
Expand All @@ -164,6 +168,12 @@ void zwp_input_popup_surface_v2_text_input_rectangle(void *data,
struct zwp_input_popup_surface_v2 *zwp_input_popup_surface_v2,
int32_t x, int32_t y, int32_t width, int32_t height);

void zwlr_layer_surface_v1_configure(void *data,
struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t serial,
uint32_t width, uint32_t height);
void zwlr_layer_surface_v1_closed(void *data,
struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1);

void wl_surface_enter(void *data, struct wl_surface *wl_surface,
struct wl_output *wl_output);
void wl_surface_leave(void *data, struct wl_surface *wl_surface,
Expand Down Expand Up @@ -277,6 +287,8 @@ void anthywl_state_finish(struct anthywl_state *state);

extern struct zwp_input_popup_surface_v2_listener const
zwp_input_popup_surface_v2_listener;
extern struct zwlr_layer_surface_v1_listener const
zwlr_layer_surface_v1_listener;
extern struct wl_seat_listener const wl_seat_listener;
extern struct wl_surface_listener const wl_surface_listener;
extern struct zwp_input_method_keyboard_grab_v2_listener const
Expand Down
1 change: 1 addition & 0 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

struct anthywl_config {
bool active_at_startup;
bool emulate_im_popups;
struct wl_array global_bindings;
struct wl_array composing_bindings;
struct wl_array selecting_bindings;
Expand Down
2 changes: 2 additions & 0 deletions protocol/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ wayland_scanner_bin = find_program(
)

protocols = {
'xdg-shell': wayland_protocols_dir / 'stable/xdg-shell/xdg-shell.xml',
'text-input-v3': wayland_protocols_dir / 'unstable/text-input/text-input-unstable-v3.xml',
'zwp-input-method-unstable-v2': 'input-method-unstable-v2.xml',
'zwp-virtual-keyboard-unstable-v1': 'virtual-keyboard-unstable-v1.xml',
'wlr-layer-shell-unstable-v1': 'wlr-layer-shell-unstable-v1.xml',
}

protocols_src = []
Expand Down
Loading

0 comments on commit 6d615ee

Please sign in to comment.