wdmtg/xsync.vapi

244 lines
9.0 KiB
Vala

//
// xsync.vapi: selected XSync APIs
//
// Copyright (c) 2016, Přemysl Janouch <p.janouch@gmail.com>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
// vim: set sw=2 ts=2 sts=2 et tw=80:
// modules: x11
// TODO: move this outside, I didn't expect the Xlib binding to be this shitty
namespace X {
[CCode (cname = "XErrorHandler", has_target = false)]
public delegate int ErrorHandler (Display dpy, ErrorEvent *ee);
[CCode (cname = "XSetErrorHandler")]
public ErrorHandler set_error_handler (ErrorHandler handler);
// XXX: can we extend the Display class so that the argument goes away?
[CCode (cname = "XSync")]
public int sync (Display dpy, bool discard);
[CCode (cname = "XSupportsLocale")]
public int supports_locale ();
[CCode (cname = "XTextProperty", has_type_id = false)]
public struct TextProperty {
// There is always a null byte at the end but it may also appear earlier
// depending on the other fields, so this is a bit misleading
[CCode (array_null_terminated = true)]
// Vala tries to g_free0() owned arrays, you still need to call XFree()
public unowned uint8[]? @value;
public Atom encoding;
public int format;
public ulong nitems;
}
[CCode (cname = "XGetTextProperty")]
public int get_text_property (Display dpy, Window window, out TextProperty text_prop_return, Atom property);
[CCode (cname = "XmbTextPropertyToTextList")]
public int mb_text_property_to_text_list (Display dpy, ref TextProperty text_prop, [CCode (type = "char ***")] out uint8 **list_return, out int count_return);
[CCode (cname = "XFreeStringList")]
public void free_string_list ([CCode (type = "char **")] uint8** list);
}
namespace X {
[CCode (cprefix = "", cheader_filename = "X11/extensions/sync.h")]
namespace Sync {
[CCode (cprefix = "XSync", cname = "int", has_type_id = false)]
public enum EventType {
CounterNotify,
AlarmNotify
}
[CCode (cprefix = "", cname = "int", has_type_id = false)]
public enum ErrorCode {
[CCode (cname = "XSyncBadCounter")]
BAD_COUNTER,
[CCode (cname = "XSyncBadAlarm")]
BAD_ALARM,
[CCode (cname = "XSyncBadFence")]
BAD_FENCE
}
[CCode (cprefix = "XSyncCA", cname = "int")]
[Flags]
public enum CA {
Counter,
ValueType,
Value,
TestType,
Delta,
Events
}
[CCode (cname = "XSyncValueType", cprefix = "XSync")]
public enum ValueType {
Absolute,
Relative
}
[CCode (cname = "XSyncTestType", cprefix = "XSync")]
public enum TestType {
PositiveTransition,
NegativeTransition,
PositiveComparison,
NegativeComparison
}
[CCode (cname = "XSyncAlarmState", cprefix = "XSyncAlarm")]
public enum AlarmState {
Active,
Inactive,
Destroyed
}
[CCode (cname = "XSyncValue", has_type_id = false)]
[SimpleType]
public struct Value {
public int hi;
public uint lo;
}
[CCode (cname = "XSyncIntToValue")]
public void int_to_value (out Value value, int v);
[CCode (cname = "XSyncIntsToValue")]
public void ints_to_value (out Value value, uint l, int h);
[CCode (cname = "XSyncValueGreaterThan")]
public int value_greater_than (Value a, Value b);
[CCode (cname = "XSyncValueLessThan")]
public int value_less_than (Value a, Value b);
[CCode (cname = "XSyncValueGreaterOrEqual")]
public int value_greater_or_equal (Value a, Value b);
[CCode (cname = "XSyncValueLessOrEqual")]
public int value_less_or_equal (Value a, Value b);
[CCode (cname = "XSyncValueEqual")]
public int value_equal (Value a, Value b);
[CCode (cname = "XSyncValueIsNegative")]
public int value_is_negative (Value a, Value b);
[CCode (cname = "XSyncValueIsZero")]
public int value_is_zero (Value a, Value b);
[CCode (cname = "XSyncValueIsPositive")]
public int value_is_positive (Value a, Value b);
[CCode (cname = "XSyncValueLow32")]
public uint value_low32 (Value value);
[CCode (cname = "XSyncValueHigh32")]
public int value_high32 (Value value);
[CCode (cname = "XSyncValueAdd")]
public void value_add (out Value result, Value a, Value b, out int poverflow);
[CCode (cname = "XSyncValueSubtract")]
public void value_subtract (out Value result, Value a, Value b, out int poverflow);
[CCode (cname = "XSyncMaxValue")]
public void max_value (out Value pv);
[CCode (cname = "XSyncMinValue")]
public void min_value (out Value pv);
[CCode (cname = "XSyncSystemCounter", has_type_id = false)]
public struct SystemCounter {
public string name;
public X.ID counter;
public Value resolution;
}
[CCode (cname = "XSyncTrigger", has_type_id = false)]
public struct Trigger {
public X.ID counter;
public ValueType value_type;
public Value wait_value;
public TestType test_type;
}
[CCode (cname = "XSyncWaitCondition", has_type_id = false)]
public struct WaitCondition {
public Trigger trigger;
public Value event_threshold;
}
[CCode (cname = "XSyncAlarmAttributes", has_type_id = false)]
public struct AlarmAttributes {
public Trigger trigger;
public Value delta;
public int events;
public AlarmState state;
}
[CCode (cname = "XSyncCounterNotifyEvent", has_type_id = false)]
public struct CounterNotifyEvent {
// TODO: other fields
public X.ID counter;
public Value wait_value;
public Value counter_value;
}
[CCode (cname = "XSyncAlarmNotifyEvent", has_type_id = false)]
public struct AlarmNotifyEvent {
// TODO: other fields
public X.ID alarm;
public Value counter_value;
public Value alarm_value;
public AlarmState state;
}
// TODO: XSyncAlarmError
// TODO: XSyncCounterError
[CCode (cname = "XSyncQueryExtension")]
public X.Status query_extension (X.Display dpy, out int event_base, out int error_base);
[CCode (cname = "XSyncInitialize")]
public X.Status initialize (X.Display dpy, out int major_version, out int minor_version);
[CCode (cname = "XSyncListSystemCounters")]
public SystemCounter *list_system_counters (X.Display dpy, out int n_counters);
[CCode (cname = "XSyncFreeSystemCounterList")]
public void free_system_counter_list (SystemCounter *counters);
[CCode (cname = "XSyncCreateCounter")]
public X.ID create_counter (X.Display dpy, Value initial_value);
[CCode (cname = "XSyncSetCounter")]
public X.Status set_counter (X.Display dpy, X.ID counter, Value value);
[CCode (cname = "XSyncChangeCounter")]
public X.Status change_counter (X.Display dpy, X.ID counter, Value value);
[CCode (cname = "XSyncDestroyCounter")]
public X.Status destroy_counter (X.Display dpy, X.ID counter);
[CCode (cname = "XSyncQueryCounter")]
public X.Status query_counter (X.Display dpy, X.ID counter, out Value value);
[CCode (cname = "XSyncAwait")]
public X.Status await (X.Display dpy, WaitCondition *wait_list, int n_conditions);
[CCode (cname = "XSyncCreateAlarm")]
public X.ID create_alarm (X.Display dpy, CA values_mask, ref AlarmAttributes values);
[CCode (cname = "XSyncDestroyAlarm")]
public X.Status destroy_alarm (X.Display dpy, X.ID alarm);
[CCode (cname = "XSyncQueryAlarm")]
public X.Status query_alarm (X.Display dpy, X.ID alarm, out AlarmAttributes values_return);
[CCode (cname = "XSyncChangeAlarm")]
public X.Status change_alarm (X.Display dpy, X.ID alarm, CA values_mask, ref AlarmAttributes values);
[CCode (cname = "XSyncSetPriority")]
public X.Status set_priority (X.Display dpy, X.ID alarm, int priority);
[CCode (cname = "XSyncGetPriority")]
public X.Status get_priority (X.Display dpy, X.ID alarm, out int priority);
[CCode (cname = "XSyncCreateFence")]
public X.ID create_fence (X.Display dpy, X.Drawable d, int initially_triggered);
[CCode (cname = "XSyncTriggerFence")]
public int trigger_fence (X.Display dpy, X.ID fence);
[CCode (cname = "XSyncResetFence")]
public int reset_fence (X.Display dpy, X.ID fence);
[CCode (cname = "XSyncDestroyFence")]
public int destroy_fence (X.Display dpy, X.ID fence);
[CCode (cname = "XSyncQueryFence")]
public int query_fence (X.Display dpy, X.ID fence, out int triggered);
[CCode (cname = "XSyncAwaitFence")]
public int await_fence (X.Display dpy, X.ID *fence_list, int n_fences);
}
}