wayland helloworld(二)のWaylandマウスメッセージ
Waylandマウスメッセージ
Waylandはwl_しか提供していませんpointer_Listenerでは、マウスに関するメッセージを取得するには、まずリスナーを設定する必要があります.
wl_pointerのメッセージは次のとおりです.
Enterウィンドウ範囲へ
leaveウィンドウ範囲から離れる
マウス移動
buttonマウスクリック、マウスボタンid定義ファイルでは、例えばBTN_LEFTはマウスの左ボタンを表します.
初期化wl_pointer_Listenerオブジェクト:
Waylandはwl_しか提供していませんpointer_Listenerでは、マウスに関するメッセージを取得するには、まずリスナーを設定する必要があります.
wl_pointerのメッセージは次のとおりです.
Enterウィンドウ範囲へ
leaveウィンドウ範囲から離れる
マウス移動
buttonマウスクリック、マウスボタンid定義ファイル
初期化wl_pointer_Listenerオブジェクト:
void pointer_enter(void *data, HPOINTER wl_pointer, uint32_t serial, HSURFACE surface, wl_fixed_t surface_x, wl_fixed_t surface_y)
{
wlGetRegistry()->s_pointer_surface = surface;
}
void pointer_leave(void *data, HPOINTER wl_pointer, uint32_t serial, HSURFACE surface)
{
wlGetRegistry()->s_pointer_surface = NULL;
}
void pointer_motion(void *data, HPOINTER wl_pointer, uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y)
{
}
void pointer_button(void *data, HPOINTER wl_pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state)
{
if (wlGetRegistry()->s_pointer_surface == NULL)
return;
if (BTN_LEFT == button && state == WL_POINTER_BUTTON_STATE_PRESSED)
{
HSHELLSURFACE shell_surface = _wlGetSurfacePrivate(wlGetRegistry()->s_pointer_surface)->shell_surface;
wl_shell_surface_move(shell_surface, wlGetRegistry()->s_seat, serial);
return;
}
}
void pointer_axis(void *data, struct wl_pointer *wl_pointer, uint32_t time, uint32_t axis, wl_fixed_t value)
{
}
struct wl_pointer_listener pointer_listener =
{
.enter = pointer_enter,
.leave = pointer_leave,
.motion = pointer_motion,
.button = pointer_button,
.axis = pointer_axis
};