wayland-client-protocol.h [1]

wl_display
wl_display_add_listenerハンドラ設定
wl_display_set_user_dataユーザー定義値をセット
wl_display_get_user_dataユーザー定義値を取得
wl_display_syncイベントの同期
wl_display_get_registrywl_registry を作成
wl_registry
wl_registry_add_listenerハンドラ設定
wl_registry_bindバインドする
wl_registry_destroy破棄
wl_compositor
wl_compositor_destroy破棄
wl_compositor_create_surfacewl_surface を作成
wl_compositor_create_regionwl_region を作成
wl_shell
wl_shell_destroy破棄
wl_shell_get_shell_surfacewl_shell_surface を作成
wl_shm
wl_shm_add_listenerハンドラ設定
wl_shm_destroy破棄
wl_shm_create_poolwl_shm_pool を作成
wl_shm_pool
wl_shm_pool_create_bufferwl_buffer を作成
wl_shm_pool_destroy破棄
wl_shm_pool_resizeリサイズ
wl_buffer
wl_buffer_add_listenerハンドラ設定
wl_buffer_destroy破棄
wl_surface
wl_surface_add_listenerハンドラ設定
wl_surface_destroy破棄
wl_surface_attachサーフェスにイメージバッファをセット
wl_surface_damage再描画範囲を追加
wl_surface_frame再描画タイミングの通知用の wl_callback を作成
wl_surface_set_opaque_region完全不透明な範囲をセット
wl_surface_set_input_regionポインタイベントを受け取り可能な領域を設定
wl_surface_commitサーフェスの保留内容を適用
wl_surface_set_buffer_transformバッファ内容の回転や反転などの設定
wl_surface_set_buffer_scaleバッファ内容の倍率をセット
wl_surface_damage_bufferバッファの座標で再描画要求
wl_shell_surface
wl_shell_surface_add_listenerハンドラ設定
wl_shell_surface_destroy破棄
wl_shell_surface_pongping に応答する
wl_shell_surface_moveポインタによる位置移動を開始
wl_shell_surface_resizeポインタによるリサイズを開始
wl_shell_surface_set_toplevelトップレベルのウィンドウとしてセット
wl_shell_surface_set_transient常に親よりも前面に表示する
wl_shell_surface_set_fullscreenフルスクリーンにして表示
wl_shell_surface_set_popupポップアップウィンドウとして表示
wl_shell_surface_set_maximized最大化する
wl_shell_surface_set_titleタイトルをセット
wl_shell_surface_set_classクラスを設定
wl_callback
wl_callback_add_listenerハンドラ設定
wl_callback_destroy破棄
wl_region
wl_region_destroy破棄
wl_region_add矩形範囲を追加
wl_region_subtract矩形範囲を削除
<name>_get_user_data() と <name>_set_user_data() は、各々で載せてはいないが、すべてのオブジェクトで使用できる。
wl_display
static int wl_display_add_listener(struct wl_display *wl_display,
    const struct wl_display_listener *listener, void *data);
ハンドラの設定。

void (*error)(void *data, struct wl_display *wl_display, void *object_id, uint32_t code, const char *message);
void (*delete_id)(void *data, struct wl_display *wl_display, uint32_t id);
error
致命的なエラーが発生した時。
object_id は、エラーが発生したオブジェクト。
code は、各インターフェイスごとのエラーコード。
message は、エラーメッセージ。
delete_id
クライアントがオブジェクトを削除すると、サーバーはこのイベントを送信して、削除要求を受け取ったことを通知する。
このイベント後は、オブジェクト ID を安全に再利用できる。
static void wl_display_set_user_data(struct wl_display *wl_display, void *user_data);
ユーザー定義値をセット
static void *wl_display_get_user_data(struct wl_display *wl_display);
ユーザー定義値を取得
static struct wl_callback *wl_display_sync(struct wl_display *wl_display);
現時点で発行されているすべてのイベントが完了したら、wl_callback の done イベントを送信させる。

コールバックで渡される callback_data は、イベントシリアル値。
戻り値
コールバックが発生した後はコンポジターによって破棄されるため、それ以降はこのポインタを使ってはならない。
static struct wl_registry *wl_display_get_registry(struct wl_display *wl_display);
クライアントが、コンポジターから利用可能なグローバルオブジェクトを一覧表示およびバインドできるようにする wl_registry を作成する。
wl_registry
int wl_registry_add_listener(struct wl_registry *wl_registry,
    const struct wl_registry_listener *listener, void *data);
void (*global)(void *data,
   struct wl_registry *wl_registry, uint32_t name,
   const char *interface, uint32_t version);

void (*global_remove)(void *data,
  struct wl_registry *wl_registry, uint32_t name);
global
グローバルオブジェクトが利用可能になった時
global_remove
グローバルオブジェクトが利用できない状態になった時。
バインドしている場合は、オブジェクトを削除する必要がある。
void *wl_registry_bind(struct wl_registry *wl_registry,
    uint32_t name, const struct wl_interface *interface, uint32_t version);
サーバーにバインドして、オブジェクトを作成する。
name
オブジェクトの数値識別子
interface
インターフェースごとに定義されているグローバル変数のポインタを渡す。
「<name>_interface」の名前で定義されている。
version
使用するバージョン。
クライアントが対応しているバージョンより高い値を指定しないこと。
void wl_registry_destroy(struct wl_registry *wl_registry);
破棄
wl_compositor
void wl_compositor_destroy(struct wl_compositor *wl_compositor);
破棄
struct wl_surface *wl_compositor_create_surface(struct wl_compositor *wl_compositor);
wl_surface を作成
struct wl_region * wl_compositor_create_region(struct wl_compositor *wl_compositor);
wl_region を作成
wl_shell
void wl_shell_destroy(struct wl_shell *wl_shell);
破棄
struct wl_shell_surface *wl_shell_get_shell_surface(
    struct wl_shell *wl_shell, struct wl_surface *surface);
wl_surface から wl_shell_surface を作成する。
これにより、wl_surface にシェルサーフェスの役割が与えられる。
(通常のウィンドウとしての扱いをすることが可能になる)

wl_surface にすでに別の役割がある場合は、プロトコルエラーが発生する。

サーフェスに関連付けられるシェルサーフェスは1つだけ。
wl_shm
int wl_shm_add_listener(struct wl_shm *wl_shm, const struct wl_shm_listener *listener, void *data);
void (*format)(void *data, struct wl_shm *wl_shm, uint32_t format);

有効なピクセルフォーマットを取得する。

WL_SHM_FORMAT_ARGB8888 = 0
WL_SHM_FORMAT_XRGB8888 = 1

これ以外は、ASCII文字 x 4 の数値となっている。
void wl_shm_destroy(struct wl_shm *wl_shm);
破棄
struct wl_shm_pool *wl_shm_create_pool(struct wl_shm *wl_shm, int32_t fd, int32_t size);
新しい wl_shm_pool オブジェクトを作成する。
サーバーは、渡された fd の size バイトを mmap する。
wl_shm_pool
struct wl_buffer *wl_shm_pool_create_buffer(struct wl_shm_pool *wl_shm_pool,
    int32_t offset, int32_t width, int32_t height, int32_t stride, uint32_t format);
wl_shm_pool から wl_buffer オブジェクトを作成する。
wl_buffer は wl_shm_pool への参照を保持するので、作成後は wl_shm_pool を削除してもよい。
offset
バイト数
stride
Y1行のバイト数
void wl_shm_pool_destroy(struct wl_shm_pool *wl_shm_pool);
オブジェクトを削除する。
mmap されたメモリは、wl_shm_pool から作成されたすべての wl_buffer が削除されると、解放される。
void wl_shm_pool_resize(struct wl_shm_pool *wl_shm_pool, int32_t size);
wl_shm_pool 作成時の fd から、新しいサイズを使用してメモリを再マップする。
サイズを増やす時のみ使用できる。
wl_buffer
int wl_buffer_add_listener(struct wl_buffer *wl_buffer,
    const struct wl_buffer_listener *listener, void *data);
void (*release)(void *data, struct wl_buffer *wl_buffer);

コンポジタが描画時にバッファを解放した時。
wl_surface_commit() 後にこの wl_buffer がコンポジタで使用されなくなった時に送信される。
このコールバック後、wl_buffer は削除したりすることができる。

wl_surface_frame() のコールバックより前に release イベントが来た場合、コンポジタがコピーを保持しているので、wl_buffer は自由に使って良い。
void wl_buffer_destroy(struct wl_buffer *wl_buffer);
破棄
wl_surface
int wl_surface_add_listener(struct wl_surface *wl_surface,
    const struct wl_surface_listener *listener, void *data);
void (*enter)(void *data,
    struct wl_surface *wl_surface,struct wl_output *output);

void (*leave)(void *data,
    struct wl_surface *wl_surface,struct wl_output *output);
enter
サーフェスが、作成・移動・リサイズの結果、wl_output の画面領域内に入った時。
leave
wl_output の画面領域内から出た時。
void wl_surface_destroy(struct wl_surface *wl_surface);
サーフェスを削除し、オブジェクト ID を無効にする。
void wl_surface_attach(struct wl_surface *wl_surface,
    struct wl_buffer *buffer, int32_t x, int32_t y);
このサーフェスの内容として wl_buffer を設定する。
適用保留としてデータが設定され、内容はダブルバッファリングされる。

サーフェスの新しいサイズは、wl_surface_set_buffer_transform() と wl_surface_set_buffer_scale() によって変換されたサイズに基づいて計算される。
よって、指定されたバッファは buffer_scale の整数倍でなければならない。

commit すると、コンポジタは wl_buffer 内のピクセルを読み取り、画面に転送する。
コンポジタが読み込みを終えると、wl_buffer:release イベントが送信される。
commit されずに別の wl_buffer に置き換えられた場合、release イベントは送信されず、コンポジタでは使用されない。

wl_buffer:release の後に wl_buffer を破棄しても、サーフェスの内容に変化はない。
ただし、wl_buffer:release イベントを受け取る前に wl_buffer を破棄すると、サーフェスの内容は未定義となる。
buffer
セットするバッファ。
NULL の場合、wl_surface_commit() 時にサーフェスの内容が削除される。
x,y
現在のバッファの左上を基準にした、新しい左上の位置を、サーフェスの座標で指定する。
void wl_surface_damage(struct wl_surface *wl_surface,
    int32_t x, int32_t y, int32_t width, int32_t height);
現在のサーフェス内容と異なる領域(再描画する範囲)を追加する。
コンポジタは、範囲外の部分を無視する。

矩形はサーフェスの座標で指定する。
すでに範囲が設定されている場合、範囲を追加する。
struct wl_callback *wl_surface_frame (struct wl_surface *wl_surface);
アニメーションや再描画する時のタイミングを知りたい時に、このコールバックを使う。

※ wl_surface_commit() を実行した時に適用される。

一度の設定で、一回しかコールバックは呼ばれない。
コールバックは、commit された順に送信される。

サーフェスが画面上に表示されない場合、サーバーはコールバックを送信しない。
(サーフェスが非表示、または他のウィンドウで完全に隠れている場合など)

wl_callback は、コールバックが実行された後にコンポジタによって破棄されるため、クライアントはそれ以降に wl_callback のポインタを使ってはならない。

コールバックで渡される callback_data は、ベース未定義の現在の時間(ミリ秒単位)。
void wl_surface_set_opaque_region(struct wl_surface *wl_surface, struct wl_region *region);
サーフェスの完全不透明な範囲を、サーフェスの座標でセットする。

セットすると、その範囲の後ろにあるウィンドウは再描画されず、サーフェスは完全不透明として描画される。
サーフェスが完全不透明なら、描画を最適化できる。

不透明領域の初期値は空。
wl_region は、設定後すぐに破棄することができる。
region
NULL で、保留中の領域をクリアする。
void wl_surface_set_input_region(struct wl_surface *wl_surface, struct wl_region *region);
wl_pointer と wl_touch のイベントを受け取ることができるサーフェス内の領域を設定する。
サーフェスの範囲外部分は無視される。

入力領域は、サーフェス座標で指定する。
この領域の外で発生した入力イベントは、スタック内の次のサーフェスへ移る。

入力領域の初期値は全体。
wl_region オブジェクトはただちに破棄できる。
region
NULL で、範囲をクリアして制限なしにする。
void wl_surface_commit(struct wl_surface *wl_surface);
設定した内容を実際に適用させる。

wl_buffer が最初に適用され、その後、他の状態が適用される。
(wl_surface_attach() 以外では wl_buffer の座標を指定する必要があるため、先に wl_buffer を適用する必要がある)

保留中の wl_buffer がない場合、座標は現在のサーフェスの内容を元に適用される。
void wl_surface_set_buffer_transform(struct wl_surface *wl_surface, int32_t transform);
バッファ内容の変形処理の設定。

90 度または 270 度の回転が含まれる場合、バッファの幅はサーフェスの高さになり、バッファの高さはサーフェスの幅になる。

transform が範囲外の値の場合、invalid_transform プロトコルエラーが発生する。

ver 2 から
transform
enum wl_output_transform の値。
void wl_surface_set_buffer_scale(struct wl_surface *wl_surface, int32_t scale);
拡大の倍率をセットする。

スケールが 1 より大きい場合は、目的のサーフェスサイズよりも大きいバッファを用意する必要がある。
スケールが正でない場合、invalid_scale プロトコルエラーが発生する。

ver 3 から
void wl_surface_damage_buffer (struct wl_surface *wl_surface,
    int32_t x, int32_t y, int32_t width, int32_t height);
再描画の範囲を、バッファ座標で指定する。

ver 4 から
wl_shell_surface
int wl_shell_surface_add_listener(struct wl_shell_surface *wl_shell_surface,
    const struct wl_shell_surface_listener *listener, void *data);
void (*ping)(void *data,
    struct wl_shell_surface *wl_shell_surface,uint32_t serial);

void (*configure)(void *data,
    struct wl_shell_surface *wl_shell_surface,
    uint32_t edges,int32_t width,int32_t height);

void (*popup_done)(void *data,
    struct wl_shell_surface *wl_shell_surface);
ping
クライアントが応答可能な状態かどうか、サーバーが定期的に問い合わせてくるので、pong 要求で応答する。
configure
サーフェスのサイズがユーザー操作により変更された時。

edges は、enum wl_shell_surface_resize の値。どの位置で変更されたか。
width, height はウィンドウのサイズ (サーフェス座標)。

受信した最後の configure イベントより前の configure は無視しても構わない。
popup_done
ポップアップのグラブが破棄されたとき、つまり、ユーザーがポップアップサーフェス以外をクリックしたときに送信される。
void wl_shell_surface_destroy(struct wl_shell_surface *wl_shell_surface);
破棄
void wl_shell_surface_pong(struct wl_shell_surface *wl_shell_surface, uint32_t serial);
ping イベントの応答に使う。
void wl_shell_surface_move(struct wl_shell_surface *wl_shell_surface,
    struct wl_seat *seat, uint32_t serial);
ユーザー操作によるポインタでのウィンドウ位置の移動を開始する。

この要求は、ボタン押しイベントに応答して使用する必要がある。
サーバは、サーフェスの状態(フルスクリーンや最大化など)によって、この要求を無視することがある。
void wl_shell_surface_resize(struct wl_shell_surface *wl_shell_surface,
    struct wl_seat *seat, uint32_t serial, uint32_t edges);
ユーザー操作によるポインタでのウィンドウリサイズを開始する。

この要求は、ボタン押しイベントに応答して使用する必要がある。
サーバは、サーフェスの状態(フルスクリーンや最大化など)によって、この要求を無視することがある。

enum wl_shell_surface_resize {
WL_SHELL_SURFACE_RESIZE_NONE = 0
WL_SHELL_SURFACE_RESIZE_TOP = 1
WL_SHELL_SURFACE_RESIZE_BOTTOM = 2
WL_SHELL_SURFACE_RESIZE_LEFT = 4
WL_SHELL_SURFACE_RESIZE_TOP_LEFT = 5
WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT = 6
WL_SHELL_SURFACE_RESIZE_RIGHT = 8
WL_SHELL_SURFACE_RESIZE_TOP_RIGHT = 9
WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT = 10
};
void wl_shell_surface_set_toplevel(struct wl_shell_surface *wl_shell_surface);
サーフェスをトップレベルのウィンドウとして表示する。
void wl_shell_surface_set_transient(struct wl_shell_surface *wl_shell_surface,
    struct wl_surface *parent, int32_t x, int32_t y, uint32_t flags);
指定サーフェスよりも常に前面に表示されるようにする。
x,y
親サーフェスからの相対的な左上位置
flags
WL_SHELL_SURFACE_TRANSIENT_INACTIVE (1) : キーボードフォーカスをセットしない
void wl_shell_surface_set_fullscreen(struct wl_shell_surface *wl_shell_surface,
    uint32_t method, uint32_t framerate, struct wl_output *output);
フルスクリーンウィンドウとして表示する。

FILL では、拡大は行わないが、出力スケールは適用される。
method
出力タイプ。
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT : 優先度なし、既定のポリシーを適用する
WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE : アスペクト比を保持し、中央位置へ
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER : サーフェスにフィットする最小のモードに画面を切り替え、余りは黒い枠線を追加
WL_SHELL_SURFACE_FULLSCREEN_METHOD_FILL : 拡大縮小なしで中央位置へ、余りは黒い枠線を追加
framerate
FILL の場合のみ。フレームレート (mHz) を指定する。
0 でデフォルト値。60 Hz なら 60000 mHz。
output
出力する wl_output の指定。NULL でデフォルト。
void wl_shell_surface_set_popup(struct wl_shell_surface *wl_shell_surface,
    struct wl_seat *seat, uint32_t serial, struct wl_surface *parent,
    int32_t x, int32_t y, uint32_t flags);
ポップアップウィンドウとして表示する。

ボタン押しイベントによって表示したい場合、内部のグラブが終了した後で、ポップアップのグラブが行われるため、一度ボタンを離さないとポップアップが表示されない。

ポップアップのグラブは、ウィンドウが破棄されるか、ポップアップ外でマウスボタンが押されるまで続く。
ポップアップ外でのクリックイベントは破棄される。
x,y
親サーフェスからの相対的な位置 (サーフェス座標)
void wl_shell_surface_set_maximized(
    struct wl_shell_surface *wl_shell_surface, struct wl_output *output);
ウィンドウを最大化する。

configure イベントで新しいウィンドウサイズが送られてくる。

最大化されたサーフェスは、通常、パネルなどのデスクトップ要素を除いて、出力全体に広がる。
詳細はコンポーザの実装に依存する。
output
NULL 以外で、指定画面に出力する
void wl_shell_surface_set_title(struct wl_shell_surface *wl_shell_surface, const char *title);
ウィンドウの短いタイトルを UTF-8 で設定する。

この文字列は、タスクバー・ウィンドウリスト・コンポジタによって提供される他のウィンドウなどを識別するために使用できる。
void wl_shell_surface_set_class(struct wl_shell_surface *wl_shell_surface, const char *class_);
クラスを設定する。

サーフェスが属するアプリケーションの一般的なクラスを識別する。
一般的な規則では、アプリケーションの .desktop ファイルのファイル名(または非標準の場所ならフルパス)をクラスとして使用する。

サーバーは、この名前で .desktop ファイルを読み込み、アプリケーションのアイコンなどを取得する場合もある。
wl_callback
int wl_callback_add_listener(struct wl_callback *wl_callback,
    const struct wl_callback_listener *listener, void *data);
void (*done)(void *data, struct wl_callback *wl_callback, uint32_t callback_data);
void wl_callback_destroy(struct wl_callback *wl_callback);
破棄
wl_region
void wl_region_destroy(struct wl_region *wl_region);
破棄
void wl_region_add(struct wl_region *wl_region,
    int32_t x, int32_t y, int32_t width, int32_t height);
矩形範囲を追加
void wl_region_subtract(struct wl_region *wl_region,
    int32_t x, int32_t y, int32_t width, int32_t height);
矩形範囲を削除