Define global handler on display creation

Otherwise the initial announcement of interfaces gets lost.
dev
Tim Wiederhake 14 years ago committed by Kristian Høgsberg
parent 20798291ca
commit b4b67344f0
  1. 4
      clients/dnd.c
  2. 2
      clients/eventdemo.c
  3. 2
      clients/flower.c
  4. 2
      clients/gears.c
  5. 2
      clients/image.c
  6. 2
      clients/resizor.c
  7. 2
      clients/smoke.c
  8. 2
      clients/terminal.c
  9. 2
      clients/view.c
  10. 12
      clients/window.c
  11. 17
      clients/window.h

@ -679,14 +679,12 @@ main(int argc, char *argv[])
{ {
struct display *d; struct display *d;
d = display_create(&argc, &argv, option_entries); d = display_create(&argc, &argv, option_entries, global_handler);
if (d == NULL) { if (d == NULL) {
fprintf(stderr, "failed to create display: %m\n"); fprintf(stderr, "failed to create display: %m\n");
return -1; return -1;
} }
display_set_global_handler(d, global_handler);
dnd_create(d); dnd_create(d);
display_run(d); display_run(d);

@ -377,7 +377,7 @@ main(int argc, char *argv[])
struct eventdemo *e; struct eventdemo *e;
/* Connect to the display and have the arguments parsed */ /* Connect to the display and have the arguments parsed */
d = display_create(&argc, &argv, option_entries); d = display_create(&argc, &argv, option_entries, NULL);
if (d == NULL) { if (d == NULL) {
fprintf(stderr, "failed to create display: %m\n"); fprintf(stderr, "failed to create display: %m\n");
return -1; return -1;

@ -129,7 +129,7 @@ int main(int argc, char *argv[])
struct display *d; struct display *d;
struct timeval tv; struct timeval tv;
d = display_create(&argc, &argv, NULL); d = display_create(&argc, &argv, NULL, NULL);
if (d == NULL) { if (d == NULL) {
fprintf(stderr, "failed to create display: %m\n"); fprintf(stderr, "failed to create display: %m\n");
return -1; return -1;

@ -372,7 +372,7 @@ int main(int argc, char *argv[])
{ {
struct display *d; struct display *d;
d = display_create(&argc, &argv, NULL); d = display_create(&argc, &argv, NULL, NULL);
if (d == NULL) { if (d == NULL) {
fprintf(stderr, "failed to create display: %m\n"); fprintf(stderr, "failed to create display: %m\n");
return -1; return -1;

@ -244,7 +244,7 @@ main(int argc, char *argv[])
struct display *d; struct display *d;
int i; int i;
d = display_create(&argc, &argv, option_entries); d = display_create(&argc, &argv, option_entries, NULL);
if (d == NULL) { if (d == NULL) {
fprintf(stderr, "failed to create display: %m\n"); fprintf(stderr, "failed to create display: %m\n");
return -1; return -1;

@ -220,7 +220,7 @@ main(int argc, char *argv[])
{ {
struct display *d; struct display *d;
d = display_create(&argc, &argv, NULL); d = display_create(&argc, &argv, NULL, NULL);
if (d == NULL) { if (d == NULL) {
fprintf(stderr, "failed to create display: %m\n"); fprintf(stderr, "failed to create display: %m\n");
return -1; return -1;

@ -249,7 +249,7 @@ int main(int argc, char *argv[])
struct display *d; struct display *d;
int size; int size;
d = display_create(&argc, &argv, NULL); d = display_create(&argc, &argv, NULL, NULL);
if (d == NULL) { if (d == NULL) {
fprintf(stderr, "failed to create display: %m\n"); fprintf(stderr, "failed to create display: %m\n");
return -1; return -1;

@ -2382,7 +2382,7 @@ int main(int argc, char *argv[])
struct display *d; struct display *d;
struct terminal *terminal; struct terminal *terminal;
d = display_create(&argc, &argv, option_entries); d = display_create(&argc, &argv, option_entries, NULL);
if (d == NULL) { if (d == NULL) {
fprintf(stderr, "failed to create display: %m\n"); fprintf(stderr, "failed to create display: %m\n");
return -1; return -1;

@ -253,7 +253,7 @@ main(int argc, char *argv[])
struct display *d; struct display *d;
int i; int i;
d = display_create(&argc, &argv, option_entries); d = display_create(&argc, &argv, option_entries, NULL);
if (d == NULL) { if (d == NULL) {
fprintf(stderr, "failed to create display: %m\n"); fprintf(stderr, "failed to create display: %m\n");
return -1; return -1;

@ -1769,7 +1769,8 @@ init_egl(struct display *d)
} }
struct display * struct display *
display_create(int *argc, char **argv[], const GOptionEntry *option_entries) display_create(int *argc, char **argv[], const GOptionEntry *option_entries,
display_global_handler_t handler)
{ {
struct display *d; struct display *d;
GOptionContext *context; GOptionContext *context;
@ -1802,6 +1803,8 @@ display_create(int *argc, char **argv[], const GOptionEntry *option_entries)
memset(d, 0, sizeof *d); memset(d, 0, sizeof *d);
d->global_handler = handler;
d->display = wl_display_connect(NULL); d->display = wl_display_connect(NULL);
if (d->display == NULL) { if (d->display == NULL) {
fprintf(stderr, "failed to create display: %m\n"); fprintf(stderr, "failed to create display: %m\n");
@ -1906,10 +1909,3 @@ display_run(struct display *d)
{ {
g_main_loop_run(d->loop); g_main_loop_run(d->loop);
} }
void
display_set_global_handler(struct display *display,
display_global_handler_t handler)
{
display->global_handler = handler;
}

@ -40,8 +40,14 @@ struct rectangle {
struct display; struct display;
struct input; struct input;
typedef void (*display_global_handler_t)(struct display *display,
const char *interface,
uint32_t id,
uint32_t version);
struct display * struct display *
display_create(int *argc, char **argv[], const GOptionEntry *option_entries); display_create(int *argc, char **argv[], const GOptionEntry *option_entries,
display_global_handler_t handler);
struct wl_display * struct wl_display *
display_get_display(struct display *display); display_get_display(struct display *display);
@ -134,11 +140,6 @@ typedef int (*window_motion_handler_t)(struct window *window,
int32_t x, int32_t y, int32_t x, int32_t y,
int32_t sx, int32_t sy, void *data); int32_t sx, int32_t sy, void *data);
typedef void (*display_global_handler_t)(struct display *display,
const char *interface,
uint32_t id,
uint32_t version);
struct window * struct window *
window_create(struct display *display, int32_t width, int32_t height); window_create(struct display *display, int32_t width, int32_t height);
struct window * struct window *
@ -234,10 +235,6 @@ window_set_title(struct window *window, const char *title);
const char * const char *
window_get_title(struct window *window); window_get_title(struct window *window);
void
display_set_global_handler(struct display *display,
display_global_handler_t handler);
struct wl_drag * struct wl_drag *
window_create_drag(struct window *window); window_create_drag(struct window *window);

Loading…
Cancel
Save