Move delete / kill to be a vfunc

This commit is contained in:
Jasper St. Pierre 2014-03-20 15:07:44 -04:00
parent 57359da9b4
commit 9debd2fb0d
4 changed files with 75 additions and 49 deletions

View File

@ -143,31 +143,7 @@ void
meta_window_delete (MetaWindow *window,
guint32 timestamp)
{
if (window->client_type == META_WINDOW_CLIENT_TYPE_X11)
{
meta_error_trap_push (window->display);
if (window->delete_window)
{
meta_topic (META_DEBUG_WINDOW_OPS,
"Deleting %s with delete_window request\n",
window->desc);
meta_window_send_icccm_message (window,
window->display->atom_WM_DELETE_WINDOW,
timestamp);
}
else
{
meta_topic (META_DEBUG_WINDOW_OPS,
"Deleting %s with explicit kill\n",
window->desc);
XKillClient (window->display->xdisplay, window->xwindow);
}
meta_error_trap_pop (window->display);
}
else
{
meta_wayland_surface_delete (window->surface);
}
META_WINDOW_GET_CLASS (window)->delete (window, timestamp);
meta_window_check_alive (window, timestamp);
@ -200,33 +176,10 @@ meta_window_delete (MetaWindow *window,
}
}
void
meta_window_kill (MetaWindow *window)
{
meta_topic (META_DEBUG_WINDOW_OPS,
"Killing %s brutally\n",
window->desc);
if (!meta_window_is_remote (window) &&
window->net_wm_pid > 0)
{
meta_topic (META_DEBUG_WINDOW_OPS,
"Killing %s with kill()\n",
window->desc);
if (kill (window->net_wm_pid, 9) < 0)
meta_topic (META_DEBUG_WINDOW_OPS,
"Failed to signal %s: %s\n",
window->desc, strerror (errno));
}
meta_topic (META_DEBUG_WINDOW_OPS,
"Disconnecting %s with XKillClient()\n",
window->desc);
meta_error_trap_push (window->display);
XKillClient (window->display->xdisplay, window->xwindow);
meta_error_trap_pop (window->display);
META_WINDOW_GET_CLASS (window)->kill (window);
}
void

View File

@ -471,6 +471,9 @@ struct _MetaWindowClass
void (*manage) (MetaWindow *window);
void (*unmanage) (MetaWindow *window);
void (*delete) (MetaWindow *window,
guint32 timestamp);
void (*kill) (MetaWindow *window);
void (*move_resize_internal) (MetaWindow *window,
int gravity,
MetaRectangle requested_rect,

View File

@ -75,6 +75,19 @@ meta_window_wayland_unmanage (MetaWindow *window)
meta_display_unregister_wayland_window (window->display, window);
}
static void
meta_window_wayland_delete (MetaWindow *window,
guint32 timestamp)
{
meta_wayland_surface_delete (window->surface);
}
static void
meta_window_wayland_kill (MetaWindow *window)
{
/* TODO */
}
static void
meta_window_wayland_move_resize_internal (MetaWindow *window,
int gravity,
@ -176,5 +189,7 @@ meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
window_class->manage = meta_window_wayland_manage;
window_class->unmanage = meta_window_wayland_unmanage;
window_class->delete = meta_window_wayland_delete;
window_class->kill = meta_window_wayland_kill;
window_class->move_resize_internal = meta_window_wayland_move_resize_internal;
}

View File

@ -322,6 +322,59 @@ meta_window_x11_unmanage (MetaWindow *window)
meta_error_trap_pop (window->display);
}
static void
meta_window_x11_delete (MetaWindow *window,
guint32 timestamp)
{
meta_error_trap_push (window->display);
if (window->delete_window)
{
meta_topic (META_DEBUG_WINDOW_OPS,
"Deleting %s with delete_window request\n",
window->desc);
meta_window_send_icccm_message (window,
window->display->atom_WM_DELETE_WINDOW,
timestamp);
}
else
{
meta_topic (META_DEBUG_WINDOW_OPS,
"Deleting %s with explicit kill\n",
window->desc);
XKillClient (window->display->xdisplay, window->xwindow);
}
meta_error_trap_pop (window->display);
}
static void
meta_window_x11_kill (MetaWindow *window)
{
meta_topic (META_DEBUG_WINDOW_OPS,
"Killing %s brutally\n",
window->desc);
if (!meta_window_is_remote (window) &&
window->net_wm_pid > 0)
{
meta_topic (META_DEBUG_WINDOW_OPS,
"Killing %s with kill()\n",
window->desc);
if (kill (window->net_wm_pid, 9) < 0)
meta_topic (META_DEBUG_WINDOW_OPS,
"Failed to signal %s: %s\n",
window->desc, strerror (errno));
}
meta_topic (META_DEBUG_WINDOW_OPS,
"Disconnecting %s with XKillClient()\n",
window->desc);
meta_error_trap_push (window->display);
XKillClient (window->display->xdisplay, window->xwindow);
meta_error_trap_pop (window->display);
}
static void
update_net_frame_extents (MetaWindow *window)
{
@ -744,6 +797,8 @@ meta_window_x11_class_init (MetaWindowX11Class *klass)
window_class->manage = meta_window_x11_manage;
window_class->unmanage = meta_window_x11_unmanage;
window_class->delete = meta_window_x11_delete;
window_class->kill = meta_window_x11_kill;
window_class->move_resize_internal = meta_window_x11_move_resize_internal;
window_class->get_default_skip_hints = meta_window_x11_get_default_skip_hints;
}