window: Store the outputs that the window is on

Using the surface enter/leave events track which outputs the window is on and
store those in a "window_output_list" on the window.

To create this list we define a struct window_output that is the list
relationship between the window and the output.
Rob Bradford 13 years ago committed by Kristian Høgsberg
parent f6f9069138
commit 7507b570c6
  1. 53
      clients/window.c

@ -124,10 +124,16 @@ enum {
TYPE_MENU,
TYPE_CUSTOM
};
struct window_output {
struct output *output;
struct wl_list link;
};
struct window {
struct display *display;
struct window *parent;
struct wl_list window_output_list;
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;
struct wl_region *input_region;
@ -948,6 +954,8 @@ window_destroy(struct window *window)
{
struct display *display = window->display;
struct input *input;
struct window_output *window_output;
struct window_output *window_output_tmp;
if (window->redraw_scheduled)
wl_list_remove(&window->redraw_task.link);
@ -962,6 +970,11 @@ window_destroy(struct window *window)
input->focus_widget = NULL;
}
wl_list_for_each_safe(window_output, window_output_tmp,
&window->window_output_list, link) {
free (window_output);
}
if (window->input_region)
wl_region_destroy(window->input_region);
if (window->opaque_region)
@ -2621,14 +2634,48 @@ window_damage(struct window *window, int32_t x, int32_t y,
static void
surface_enter(void *data,
struct wl_surface *wl_surface, struct wl_output *output)
struct wl_surface *wl_surface, struct wl_output *wl_output)
{
struct window *window = data;
struct output *output;
struct output *output_found = NULL;
struct window_output *window_output;
wl_list_for_each(output, &window->display->output_list, link) {
if (output->output == wl_output) {
output_found = output;
break;
}
}
if (!output_found)
return;
window_output = malloc (sizeof *window_output);
window_output->output = output_found;
wl_list_insert (&window->window_output_list, &window_output->link);
}
static void
surface_leave(void *data,
struct wl_surface *wl_surface, struct wl_output *output)
{
struct window *window = data;
struct window_output *window_output;
struct window_output *window_output_found = NULL;
wl_list_for_each(window_output, &window->window_output_list, link) {
if (window_output->output->output == output) {
window_output_found = window_output;
break;
}
}
if (window_output_found) {
wl_list_remove(&window_output_found->link);
free(window_output_found);
}
}
static const struct wl_surface_listener surface_listener = {
@ -2687,6 +2734,8 @@ window_create_internal(struct display *display, struct window *parent)
&shell_surface_listener, window);
}
wl_list_init (&window->window_output_list);
return window;
}

Loading…
Cancel
Save