Class: XCB::ClientMessageEvent

Inherits:
GenericEvent show all
Defined in:
ext/xproto.c

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(r_format, r_window, r_type, r_data) ⇒ Object



2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
# File 'ext/xproto.c', line 2830

static VALUE
r_XCB_ClientMessageEvent_new(VALUE r_klass, VALUE r_format, VALUE r_window, VALUE r_type, VALUE r_data)
{
	xcb_client_message_event_t *self = malloc(sizeof(xcb_client_message_event_t));
	if (self == NULL)
		rb_raise(rb_eNoMemError, "NoMemoryError");
	VALUE r_self = Data_Wrap_Struct(r_klass, NULL, NULL, self);
	self->response_type = XCB_CLIENT_MESSAGE;
	self->sequence = 0;
	self->format = FIX2INT(r_format);
	self->window = FIX2INT(r_window);
	self->type = FIX2INT(r_type);
	uint8_t format = self->format;
	switch (format) {
	case 8:
		{
			int i;
			for (i = 0; i < 20; i += 1)
				self->data.data8[i] = FIX2INT(rb_ary_entry(r_data, i));
			break;
		}
	case 16:
		{
			int i;
			for (i = 0; i < 10; i += 1)
				self->data.data16[i] = FIX2INT(rb_ary_entry(r_data, i));
			break;
		}
	case 32:
		{
			int i;
			for (i = 0; i < 5; i += 1)
				self->data.data32[i] = FIX2INT(rb_ary_entry(r_data, i));
			break;
		}
	default:
		rb_raise(rb_eArgError, "invalid format");
	}
	return r_self;
}

Instance Method Details

#dataObject



1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
# File 'ext/xproto.c', line 1930

static VALUE
r_XCB_ClientMessageEvent_get_data(VALUE r_self)
{
	xcb_client_message_event_t *event;
	Data_Get_Struct(r_self, xcb_client_message_event_t, event);
	VALUE r_data;
	uint8_t format = event->format;
	switch (format) {
	case 8:
		{
			r_data = rb_ary_new2(20);
			int i;
			for (i = 0; i < 20; i += 1)
				rb_ary_store(r_data, i, INT2FIX(event->data.data8[i]));
			break;
		}
	case 16:
		{
			r_data = rb_ary_new2(10);
			int i;
			for (i = 0; i < 10; i += 1)
				rb_ary_store(r_data, i, INT2FIX(event->data.data16[i]));
			break;
		}
	case 32:
		{
			r_data = rb_ary_new2(5);
			int i;
			for (i = 0; i < 5; i += 1)
				rb_ary_store(r_data, i, INT2FIX(event->data.data32[i]));
			break;
		}
	default:
		rb_raise(rb_eArgError, "invalid format");
	}
	return r_data;
}

#formatObject



1909
1910
1911
1912
1913
1914
1915
# File 'ext/xproto.c', line 1909

static VALUE
r_XCB_ClientMessageEvent_get_format(VALUE r_self)
{
	xcb_client_message_event_t *event;
	Data_Get_Struct(r_self, xcb_client_message_event_t, event);
	return INT2FIX(event->format);
}

#typeObject



1923
1924
1925
1926
1927
1928
1929
# File 'ext/xproto.c', line 1923

static VALUE
r_XCB_ClientMessageEvent_get_type(VALUE r_self)
{
	xcb_client_message_event_t *event;
	Data_Get_Struct(r_self, xcb_client_message_event_t, event);
	return INT2FIX(event->type);
}

#visit(r_visitor) ⇒ Object



2870
2871
2872
2873
2874
# File 'ext/xproto.c', line 2870

static VALUE
r_XCB_ClientMessageEvent_visit(VALUE r_self, VALUE r_visitor)
{
	return rb_funcall(r_visitor, rb_intern("visit_client_message"), 1, r_self);
}

#windowObject



1916
1917
1918
1919
1920
1921
1922
# File 'ext/xproto.c', line 1916

static VALUE
r_XCB_ClientMessageEvent_get_window(VALUE r_self)
{
	xcb_client_message_event_t *event;
	Data_Get_Struct(r_self, xcb_client_message_event_t, event);
	return INT2FIX(event->window);
}