wl_compositor

wl_compositor (ver 6)
wl_compositor_destroy破棄
wl_compositor_create_surfacewl_surface を作成
wl_compositor_create_regionwl_region を作成
wl_surface
struct wl_surface_listenerハンドラ構造体
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_surface_offset新しいオフセット位置を指定
wl_region
wl_region_destroy破棄
wl_region_add矩形範囲を追加
wl_region_subtract矩形範囲を削除
wl_compositor (ver 6)
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_surface
struct wl_surface_listener {
    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);
    # ver 6
    void (*preferred_buffer_scale)(void *data, struct wl_surface *wl_surface, int32_t factor);
    void (*preferred_buffer_transform)(void *data, struct wl_surface *wl_surface, uint32_t transform);
};
ハンドラ構造体
enter
サーフェスが、作成・移動・リサイズの結果、wl_output の画面領域内に入った時。
leave
サーフェスが、wl_output の画面領域内から出た時。
preferred_buffer_scale
ver 6
このサーフェスの優先バッファスケール (1 以上) を示す。
コンポジターの設定が変更されるたびに送信される。

このイベントを受信する前は、優先バッファスケールは 1。

スケーリング対応のクライアントが、このイベントを使用して内容をスケーリングし、wl_surface_set_buffer_scale() を使用して、レンダリングしたスケールを示すことが意図されている。
これにより、クライアントはより詳細なバッファを提供できる。
preferred_buffer_transform
ver 6
サーフェスの優先バッファ変形を示す。
コンポジターの設定が変更されるたびに送信される。

このイベントを受信する前は、優先バッファ変換は正常。

この変形をサーフェスバッファの内容に適用し、wl_surface_set_buffer_transform() を使用すると、コンポジターはサーフェスバッファをより効率的に使用できるようになる。
int wl_surface_add_listener(struct wl_surface *wl_surface,
    const struct wl_surface_listener *listener, void *data);
ハンドラ設定
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 は、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);
//ver 2
バッファ内容の変形処理の設定。

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

transform が範囲外の値の場合、invalid_transform プロトコルエラーが発生する。
transform
enum wl_output_transform の値。
void wl_surface_set_buffer_scale(struct wl_surface *wl_surface, int32_t scale);
//ver 3
拡大の倍率をセットする。

スケールが 1 より大きい場合は、目的のサーフェスサイズよりも大きいバッファを用意する必要がある。
スケールが正でない場合、invalid_scale プロトコルエラーが発生する。
void wl_surface_damage_buffer(struct wl_surface *wl_surface,
    int32_t x, int32_t y, int32_t width, int32_t height);
//ver 4
再描画の範囲を、バッファ座標で指定する。
void wl_surface_offset(struct wl_surface *wl_surface, int32_t x, int32_t y);
//ver 5
新しいオフセット位置を指定する。
wl_surface_attach() で指定された x,y の値を置き換える。
x,y
サーフェスのローカル座標。
現在のバッファの左上隅を基準として、新しい保留バッファの左上隅の位置を指定する。
x, y を新しいサーフェスサイズと組み合わせると、サーフェスのサイズが、どの方向に変化するかが定義される。
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);
矩形範囲を削除