[PATCH] weston_wm: Implement _NET_ACTIVE_WINDOW

Bryce Harrington bryce at osg.samsung.com
Tue Sep 22 14:52:16 PDT 2015


On Tue, Sep 22, 2015 at 12:29:46AM +0200, Benoit Gschwind wrote:
> ---
>  xwayland/window-manager.c | 21 +++++++++++++++++++++
>  xwayland/xwayland.h       |  2 ++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
> index f9544d8..254bd45 100644
> --- a/xwayland/window-manager.c
> +++ b/xwayland/window-manager.c
> @@ -163,6 +163,9 @@ static struct weston_wm_window *
>  get_wm_window(struct weston_surface *surface);
>  
>  static void
> +weston_wm_set_net_active_window(struct weston_wm *wm, xcb_window_t window);
> +
> +static void
>  weston_wm_window_schedule_repaint(struct weston_wm_window *window);
>  
>  static void
> @@ -782,6 +785,12 @@ weston_wm_window_activate(struct wl_listener *listener, void *data)
>  		window = get_wm_window(surface);
>  	}
>  
> +	if(window) {

I think wayland code style has a space after keywords, so: "if (window) {"

> +		weston_wm_set_net_active_window(wm, window->id);
> +	} else {
> +		weston_wm_set_net_active_window(wm, XCB_WINDOW_NONE);
> +	}
> +
>  	weston_wm_send_focus_window(wm, window);
>  
>  	if (wm->focus_window) {
> @@ -1985,6 +1994,13 @@ weston_wm_handle_event(int fd, uint32_t mask, void *data)
>  }
>  
>  static void
> +weston_wm_set_net_active_window(struct weston_wm *wm, xcb_window_t window) {
> +	xcb_change_property(wm->conn, XCB_PROP_MODE_REPLACE,
> +			wm->screen->root, wm->atom.net_active_window,
> +			wm->atom.window, 32, 1, &window);
> +}
> +
> +static void
>  weston_wm_get_visual_and_colormap(struct weston_wm *wm)
>  {
>  	xcb_depth_iterator_t d_iter;
> @@ -2060,6 +2076,7 @@ weston_wm_get_resources(struct weston_wm *wm)
>  		{ "_NET_SUPPORTING_WM_CHECK",
>  					F(atom.net_supporting_wm_check) },
>  		{ "_NET_SUPPORTED",     F(atom.net_supported) },
> +		{ "_NET_ACTIVE_WINDOW",     F(atom.net_active_window) },

whitespace seems off in the 2nd column.  Probably doesn't matter though,
looks like we've got an inconsistent mix of tabs and spaces here anyway.

>  		{ "_MOTIF_WM_HINTS",	F(atom.motif_wm_hints) },
>  		{ "CLIPBOARD",		F(atom.clipboard) },
>  		{ "CLIPBOARD_MANAGER",	F(atom.clipboard_manager) },
> @@ -2073,6 +2090,7 @@ weston_wm_get_resources(struct weston_wm *wm)
>  		{ "COMPOUND_TEXT",	F(atom.compound_text) },
>  		{ "TEXT",		F(atom.text) },
>  		{ "STRING",		F(atom.string) },
> +		{ "WINDOW",		F(atom.window) },
>  		{ "text/plain;charset=utf-8",	F(atom.text_plain_utf8) },
>  		{ "text/plain",		F(atom.text_plain) },
>  		{ "XdndSelection",	F(atom.xdnd_selection) },
> @@ -2265,6 +2283,7 @@ weston_wm_create(struct weston_xserver *wxs, int fd)
>  	supported[2] = wm->atom.net_wm_state_fullscreen;
>  	supported[3] = wm->atom.net_wm_state_maximized_vert;
>  	supported[4] = wm->atom.net_wm_state_maximized_horz;
> +	supported[5] = wm->atom.net_active_window;

Uh oh:

        xcb_atom_t supported[5];

need to bump the bounds up on that array.

>  	xcb_change_property(wm->conn,
>  			    XCB_PROP_MODE_REPLACE,
>  			    wm->screen->root,
> @@ -2273,6 +2292,8 @@ weston_wm_create(struct weston_xserver *wxs, int fd)
>  			    32, /* format */
>  			    ARRAY_LENGTH(supported), supported);
>  
> +	weston_wm_set_net_active_window(wm, XCB_WINDOW_NONE);
> +
>  	weston_wm_selection_init(wm);
>  
>  	weston_wm_dnd_init(wm);
> diff --git a/xwayland/xwayland.h b/xwayland/xwayland.h
> index 7f4c5b1..bace079 100644
> --- a/xwayland/xwayland.h
> +++ b/xwayland/xwayland.h
> @@ -129,6 +129,7 @@ struct weston_wm {
>  		xcb_atom_t		 net_wm_moveresize;
>  		xcb_atom_t		 net_supporting_wm_check;
>  		xcb_atom_t		 net_supported;
> +		xcb_atom_t		 net_active_window;
>  		xcb_atom_t		 motif_wm_hints;
>  		xcb_atom_t		 clipboard;
>  		xcb_atom_t		 clipboard_manager;
> @@ -141,6 +142,7 @@ struct weston_wm {
>  		xcb_atom_t		 compound_text;
>  		xcb_atom_t		 text;
>  		xcb_atom_t		 string;
> +		xcb_atom_t		 window;
>  		xcb_atom_t		 text_plain_utf8;
>  		xcb_atom_t		 text_plain;
>  		xcb_atom_t		 xdnd_selection;

Bryce




More information about the wayland-devel mailing list