Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wayland
wayland
Commits
e9088930
Commit
e9088930
authored
Aug 19, 2011
by
Kristian Høgsberg
Browse files
Bind globals to client provided object IDs
parent
a7c68243
Changes
6
Hide whitespace changes
Inline
Side-by-side
protocol/wayland.xml
View file @
e9088930
...
...
@@ -31,9 +31,10 @@
It is used for internal wayland protocol features. -->
<interface
name=
"wl_display"
version=
"1"
>
<request
name=
"bind"
>
<arg
name=
"
id
"
type=
"uint"
/>
<arg
name=
"
name
"
type=
"uint"
/>
<arg
name=
"interface"
type=
"string"
/>
<arg
name=
"version"
type=
"uint"
/>
<arg
name=
"id"
type=
"new_id"
interface=
"wl_object"
/>
</request>
<!-- sync is an just an echo, which will reply with a key event.
...
...
src/scanner.c
View file @
e9088930
...
...
@@ -347,19 +347,6 @@ emit_stubs(struct wl_list *message_list, struct interface *interface)
if
(
strcmp
(
interface
->
name
,
"wl_display"
)
==
0
)
return
;
printf
(
"static inline struct %s *
\n
"
"%s_create(struct wl_display *display, uint32_t id, uint32_t version)
\n
"
"{
\n
"
"
\t
wl_display_bind(display, id,
\"
%s
\"
, version);
\n\n
"
"
\t
return (struct %s *)
\n
"
"
\t\t
wl_proxy_create_for_id(display, &%s_interface, id);
\n
"
"}
\n\n
"
,
interface
->
name
,
interface
->
name
,
interface
->
name
,
interface
->
name
,
interface
->
name
);
printf
(
"static inline void
\n
"
"%s_set_user_data(struct %s *%s, void *user_data)
\n
"
"{
\n
"
...
...
src/wayland-client.c
View file @
e9088930
...
...
@@ -122,10 +122,10 @@ wl_display_remove_global_listener(struct wl_display *display,
}
WL_EXPORT
struct
wl_proxy
*
wl_proxy_create_for_id
(
struct
wl_display
*
display
,
const
struct
wl_interface
*
interface
,
uint32_t
id
)
wl_proxy_create
(
struct
wl_proxy
*
factory
,
const
struct
wl_interface
*
interface
)
{
struct
wl_proxy
*
proxy
;
struct
wl_display
*
display
=
factory
->
display
;
proxy
=
malloc
(
sizeof
*
proxy
);
if
(
proxy
==
NULL
)
...
...
@@ -133,21 +133,13 @@ wl_proxy_create_for_id(struct wl_display *display,
proxy
->
object
.
interface
=
interface
;
proxy
->
object
.
implementation
=
NULL
;
proxy
->
object
.
id
=
id
;
proxy
->
object
.
id
=
wl_display_allocate_id
(
display
)
;
proxy
->
display
=
display
;
wl_hash_table_insert
(
display
->
objects
,
proxy
->
object
.
id
,
proxy
);
return
proxy
;
}
WL_EXPORT
struct
wl_proxy
*
wl_proxy_create
(
struct
wl_proxy
*
factory
,
const
struct
wl_interface
*
interface
)
{
return
wl_proxy_create_for_id
(
factory
->
display
,
interface
,
wl_display_allocate_id
(
factory
->
display
));
}
WL_EXPORT
void
wl_proxy_destroy
(
struct
wl_proxy
*
proxy
)
{
...
...
@@ -367,8 +359,6 @@ wl_display_connect(const char *name)
return
NULL
;
}
wl_display_bind
(
display
,
1
,
"wl_display"
,
1
);
return
display
;
}
...
...
@@ -524,12 +514,20 @@ wl_display_allocate_id(struct wl_display *display)
return
display
->
id
++
;
}
WL_EXPORT
void
WL_EXPORT
void
*
wl_display_bind
(
struct
wl_display
*
display
,
uint32_t
id
,
const
char
*
interface
,
uint32_t
version
)
uint32_t
name
,
const
struct
wl_interface
*
interface
)
{
wl_proxy_marshal
(
&
display
->
proxy
,
WL_DISPLAY_BIND
,
id
,
interface
,
version
);
struct
wl_proxy
*
proxy
;
proxy
=
wl_proxy_create
(
&
display
->
proxy
,
interface
);
if
(
proxy
==
NULL
)
return
NULL
;
wl_proxy_marshal
(
&
display
->
proxy
,
WL_DISPLAY_BIND
,
name
,
interface
->
name
,
interface
->
version
,
proxy
);
return
proxy
;
}
WL_EXPORT
struct
wl_callback
*
...
...
src/wayland-client.h
View file @
e9088930
...
...
@@ -44,8 +44,9 @@ int wl_proxy_add_listener(struct wl_proxy *proxy,
void
wl_proxy_set_user_data
(
struct
wl_proxy
*
proxy
,
void
*
user_data
);
void
*
wl_proxy_get_user_data
(
struct
wl_proxy
*
proxy
);
void
wl_display_bind
(
struct
wl_display
*
display
,
uint32_t
id
,
const
char
*
interface
,
uint32_t
version
);
void
*
wl_display_bind
(
struct
wl_display
*
display
,
uint32_t
name
,
const
struct
wl_interface
*
interface
);
struct
wl_callback
*
wl_display_sync
(
struct
wl_display
*
display
);
#include "wayland-client-protocol.h"
...
...
src/wayland-server.c
View file @
e9088930
...
...
@@ -544,26 +544,24 @@ wl_input_device_update_grab(struct wl_input_device *device,
static
void
display_bind
(
struct
wl_client
*
client
,
struct
wl_resource
*
resource
,
uint32_t
id
,
const
char
*
interface
,
uint32_t
version
)
struct
wl_resource
*
resource
,
uint32_t
name
,
const
char
*
interface
,
uint32_t
version
,
uint32_t
id
)
{
struct
wl_global
*
global
;
struct
wl_display
*
display
=
resource
->
data
;
wl_list_for_each
(
global
,
&
display
->
global_list
,
link
)
if
(
global
->
object
->
id
==
id
)
if
(
global
->
object
->
id
==
name
)
break
;
if
(
&
global
->
link
==
&
display
->
global_list
)
wl_client_post_error
(
client
,
&
client
->
display
->
resource
.
object
,
WL_DISPLAY_ERROR_INVALID_OBJECT
,
"invalid
object
%d"
,
id
);
"invalid
global
%d"
,
name
);
else
if
(
global
->
bind
)
global
->
bind
(
client
,
global
->
object
,
version
);
global
->
bind
(
client
,
global
->
object
,
version
,
id
);
wl_hash_table_insert
(
client
->
objects
,
global
->
object
->
id
,
global
->
object
);
wl_hash_table_insert
(
client
->
objects
,
id
,
global
->
object
);
}
static
void
...
...
@@ -849,12 +847,14 @@ wl_display_add_socket(struct wl_display *display, const char *name)
static
void
compositor_bind
(
struct
wl_client
*
client
,
struct
wl_object
*
global
,
uint32_t
version
)
struct
wl_object
*
global
,
uint32_t
version
,
uint32_t
id
)
{
struct
wl_compositor
*
compositor
=
container_of
(
global
,
struct
wl_compositor
,
resource
.
object
);
compositor
->
resource
.
client
=
client
;
compositor
->
resource
.
object
.
id
=
id
;
wl_resource_post_event
(
&
compositor
->
resource
,
WL_COMPOSITOR_TOKEN_VISUAL
,
&
compositor
->
argb_visual
.
object
,
...
...
src/wayland-server.h
View file @
e9088930
...
...
@@ -87,7 +87,7 @@ void wl_display_add_object(struct wl_display *display,
typedef
void
(
*
wl_global_bind_func_t
)(
struct
wl_client
*
client
,
struct
wl_object
*
global
,
uint32_t
version
);
uint32_t
version
,
uint32_t
id
);
int
wl_display_add_global
(
struct
wl_display
*
display
,
struct
wl_object
*
object
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment