mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
...
This commit is contained in:
parent
b46ab7cab3
commit
f14221e842
@ -186,6 +186,11 @@ meta_display_open (const char *name)
|
||||
display->atom_net_client_list = atoms[28];
|
||||
display->atom_net_client_list_stacking = atoms[29];
|
||||
|
||||
/* Offscreen unmapped window used for _NET_SUPPORTING_WM_CHECK,
|
||||
* created in screen_new
|
||||
*/
|
||||
display->leader_window = None;
|
||||
|
||||
screens = NULL;
|
||||
i = 0;
|
||||
while (i < ScreenCount (xdisplay))
|
||||
@ -225,13 +230,6 @@ meta_display_open (const char *name)
|
||||
display->last_button_num = 0;
|
||||
display->is_double_click = FALSE;
|
||||
|
||||
/* Offscreen unmapped window used for _NET_SUPPORTING_WM_CHECK
|
||||
*/
|
||||
display->leader_window =
|
||||
XCreateSimpleWindow (display->xdisplay,
|
||||
((MetaScreen*)display->screens->data)->xroot,
|
||||
-100, -100, 1, 1, 0, 0, 0);
|
||||
|
||||
set_string_hint (display,
|
||||
display->leader_window,
|
||||
display->atom_net_supporting_wm_check,
|
||||
@ -303,6 +301,7 @@ meta_display_close (MetaDisplay *display)
|
||||
*/
|
||||
g_hash_table_destroy (display->window_ids);
|
||||
|
||||
if (display->leader_window != None)
|
||||
XDestroyWindow (display->xdisplay, display->leader_window);
|
||||
|
||||
meta_event_queue_free (display->events);
|
||||
@ -721,6 +720,61 @@ event_get_modified_window (MetaDisplay *display,
|
||||
}
|
||||
}
|
||||
|
||||
static const char*
|
||||
focus_detail (int d)
|
||||
{
|
||||
const char *detail = "(????)";
|
||||
switch (d)
|
||||
{
|
||||
case NotifyAncestor:
|
||||
detail = "NotifyAncestor";
|
||||
break;
|
||||
case NotifyDetailNone:
|
||||
detail = "NotifyDetailNone";
|
||||
break;
|
||||
case NotifyInferior:
|
||||
detail = "NotifyInferior";
|
||||
break;
|
||||
case NotifyNonlinear:
|
||||
detail = "NotifyNonlinear";
|
||||
break;
|
||||
case NotifyNonlinearVirtual:
|
||||
detail = "NotifyNonlinearVirtual";
|
||||
break;
|
||||
case NotifyPointer:
|
||||
detail = "NotifyPointer";
|
||||
break;
|
||||
case NotifyPointerRoot:
|
||||
detail = "NotifyPointerRoot";
|
||||
break;
|
||||
case NotifyVirtual:
|
||||
detail = "NotifyVirtual";
|
||||
break;
|
||||
}
|
||||
|
||||
return detail;
|
||||
}
|
||||
|
||||
static const char*
|
||||
focus_mode (int m)
|
||||
{
|
||||
const char *mode = "(????)";
|
||||
switch (m)
|
||||
{
|
||||
case NotifyNormal:
|
||||
mode = "NotifyNormal";
|
||||
break;
|
||||
case NotifyGrab:
|
||||
mode = "NotifyGrab";
|
||||
break;
|
||||
case NotifyUngrab:
|
||||
mode = "NotifyUngrab";
|
||||
break;
|
||||
}
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_spew_event (MetaDisplay *display,
|
||||
XEvent *event)
|
||||
@ -773,9 +827,15 @@ meta_spew_event (MetaDisplay *display,
|
||||
break;
|
||||
case FocusIn:
|
||||
name = "FocusIn";
|
||||
extra = g_strdup_printf ("detail: %s mode: %s\n",
|
||||
focus_detail (event->xfocus.detail),
|
||||
focus_mode (event->xfocus.mode));
|
||||
break;
|
||||
case FocusOut:
|
||||
name = "FocusOut";
|
||||
extra = g_strdup_printf ("detail: %s mode: %s\n",
|
||||
focus_detail (event->xfocus.detail),
|
||||
focus_mode (event->xfocus.mode));
|
||||
break;
|
||||
case KeymapNotify:
|
||||
name = "KeymapNotify";
|
||||
|
11
src/screen.c
11
src/screen.c
@ -47,6 +47,8 @@ set_wm_check_hint (MetaScreen *screen)
|
||||
{
|
||||
unsigned long data[1];
|
||||
|
||||
g_return_val_if_fail (screen->display->leader_window != None, 0);
|
||||
|
||||
data[0] = screen->display->leader_window;
|
||||
|
||||
XChangeProperty (screen->display->xdisplay, screen->xroot,
|
||||
@ -59,7 +61,7 @@ set_wm_check_hint (MetaScreen *screen)
|
||||
static int
|
||||
set_supported_hint (MetaScreen *screen)
|
||||
{
|
||||
#define N_SUPPORTED 17
|
||||
#define N_SUPPORTED 19
|
||||
Atom atoms[N_SUPPORTED];
|
||||
|
||||
atoms[0] = screen->display->atom_net_wm_name;
|
||||
@ -79,6 +81,8 @@ set_supported_hint (MetaScreen *screen)
|
||||
atoms[14] = screen->display->atom_net_wm_window_type_dialog;
|
||||
atoms[15] = screen->display->atom_net_wm_window_type_normal;
|
||||
atoms[16] = screen->display->atom_net_wm_state_modal;
|
||||
atoms[17] = screen->display->atom_net_client_list;
|
||||
atoms[18] = screen->display->atom_net_client_list_stacking;
|
||||
|
||||
XChangeProperty (screen->display->xdisplay, screen->xroot,
|
||||
screen->display->atom_net_wm_supported,
|
||||
@ -153,6 +157,11 @@ meta_screen_new (MetaDisplay *display,
|
||||
|
||||
screen->showing_tooltip = FALSE;
|
||||
|
||||
if (display->leader_window == None)
|
||||
display->leader_window = XCreateSimpleWindow (display->xdisplay,
|
||||
screen->xroot,
|
||||
-100, -100, 1, 1, 0, 0, 0);
|
||||
|
||||
set_supported_hint (screen);
|
||||
|
||||
set_wm_check_hint (screen);
|
||||
|
@ -55,6 +55,8 @@ struct _MetaScreen
|
||||
* root window)
|
||||
*/
|
||||
PangoContext *pango_context;
|
||||
|
||||
MetaStack *stack;
|
||||
};
|
||||
|
||||
MetaScreen* meta_screen_new (MetaDisplay *display,
|
||||
|
173
src/stack.c
173
src/stack.c
@ -22,6 +22,7 @@
|
||||
#include "stack.h"
|
||||
#include "window.h"
|
||||
#include "errors.h"
|
||||
#include "frame.h"
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
@ -166,6 +167,7 @@ meta_stack_remove (MetaStack *stack,
|
||||
op->add_order = -1;
|
||||
|
||||
/* Need to immediately remove from layer lists */
|
||||
g_assert (g_list_find (stack->layers[window->layer], window) != NULL);
|
||||
stack->layers[window->layer] =
|
||||
g_list_remove (stack->layers[window->layer], window);
|
||||
|
||||
@ -206,6 +208,7 @@ meta_stack_raise (MetaStack *stack,
|
||||
op = ensure_op (stack, window);
|
||||
op->raised = TRUE;
|
||||
op->lowered = FALSE;
|
||||
op->update_transient = TRUE;
|
||||
|
||||
meta_stack_sync_to_server (stack);
|
||||
}
|
||||
@ -219,6 +222,7 @@ meta_stack_lower (MetaStack *stack,
|
||||
op = ensure_op (stack, window);
|
||||
op->raised = FALSE;
|
||||
op->lowered = TRUE;
|
||||
op->update_transient = TRUE;
|
||||
|
||||
meta_stack_sync_to_server (stack);
|
||||
}
|
||||
@ -261,51 +265,91 @@ compute_layer (MetaWindow *window)
|
||||
window->desc, window->layer);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_transient_for (MetaWindow *transient,
|
||||
MetaWindow *parent)
|
||||
static GList*
|
||||
ensure_before (GList *list,
|
||||
gconstpointer before,
|
||||
gconstpointer value)
|
||||
{
|
||||
MetaWindow *w;
|
||||
/* ensure before is before value */
|
||||
GList *b_link;
|
||||
GList *v_link;
|
||||
GList *tmp;
|
||||
|
||||
w = transient;
|
||||
while (w != NULL)
|
||||
b_link = NULL;
|
||||
v_link = NULL;
|
||||
tmp = list;
|
||||
while (tmp != NULL)
|
||||
{
|
||||
if (w->xtransient_for == None)
|
||||
return FALSE;
|
||||
if (tmp->data == before)
|
||||
{
|
||||
if (v_link == NULL)
|
||||
return list; /* already before */
|
||||
|
||||
w = meta_display_lookup_x_window (w->display, w->xtransient_for);
|
||||
|
||||
if (w == transient)
|
||||
return FALSE; /* Cycle detected */
|
||||
else if (w == parent)
|
||||
return TRUE;
|
||||
b_link = tmp;
|
||||
}
|
||||
else if (tmp->data == value)
|
||||
{
|
||||
v_link = tmp;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
static int
|
||||
window_stack_cmp (MetaWindow *a,
|
||||
MetaWindow *b)
|
||||
{
|
||||
/* Less than means higher in stacking, i.e. at the
|
||||
* front of the list.
|
||||
*/
|
||||
/* We weren't already before if we got here */
|
||||
list = g_list_remove_link (list, b_link);
|
||||
|
||||
if (a->xtransient_for != None &&
|
||||
is_transient_for (a, b))
|
||||
if (v_link == list)
|
||||
{
|
||||
/* a is higher than b due to transient_for */
|
||||
return -1;
|
||||
}
|
||||
else if (b->xtransient_for != None &&
|
||||
is_transient_for (b, a))
|
||||
{
|
||||
/* b is higher than a due to transient_for */
|
||||
return 1;
|
||||
b_link->next = v_link;
|
||||
v_link->prev = b_link;
|
||||
list = b_link;
|
||||
}
|
||||
else
|
||||
return 0; /* leave things as-is */
|
||||
{
|
||||
b_link->prev = v_link->prev;
|
||||
b_link->prev->next = b_link;
|
||||
b_link->next = v_link;
|
||||
v_link->prev = b_link;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static GList*
|
||||
sort_window_list (GList *list)
|
||||
{
|
||||
GList *tmp;
|
||||
GList *copy;
|
||||
|
||||
/* This algorithm could stand to be a bit less
|
||||
* quadratic
|
||||
*/
|
||||
copy = g_list_copy (list);
|
||||
tmp = copy;
|
||||
while (tmp != NULL)
|
||||
{
|
||||
MetaWindow *w = tmp->data;
|
||||
|
||||
if (w->xtransient_for != None)
|
||||
{
|
||||
MetaWindow *parent;
|
||||
|
||||
parent =
|
||||
meta_display_lookup_x_window (w->display, w->xtransient_for);
|
||||
|
||||
if (parent)
|
||||
{
|
||||
meta_verbose ("Stacking %s above %s due to transiency\n",
|
||||
w->desc, parent->desc);
|
||||
list = ensure_before (list, w, parent);
|
||||
}
|
||||
}
|
||||
|
||||
tmp = tmp->next;
|
||||
}
|
||||
g_list_free (copy);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -321,6 +365,7 @@ meta_stack_sync_to_server (MetaStack *stack)
|
||||
int i, j;
|
||||
int old_size;
|
||||
GArray *stacked;
|
||||
GArray *root_children_stacked;
|
||||
|
||||
/* Bail out if frozen */
|
||||
if (stack->freeze_count > 0)
|
||||
@ -445,6 +490,14 @@ meta_stack_sync_to_server (MetaStack *stack)
|
||||
|
||||
old_layer = op->window->layer;
|
||||
|
||||
if (op->add_order >= 0)
|
||||
{
|
||||
/* need to add to a layer */
|
||||
stack->layers[op->window->layer] =
|
||||
g_list_prepend (stack->layers[op->window->layer],
|
||||
op->window);
|
||||
}
|
||||
|
||||
if (op->update_layer)
|
||||
{
|
||||
compute_layer (op->window);
|
||||
@ -486,6 +539,8 @@ meta_stack_sync_to_server (MetaStack *stack)
|
||||
stack->layers[op->window->layer] =
|
||||
g_list_prepend (stack->layers[op->window->layer],
|
||||
op->window);
|
||||
|
||||
needs_sort[op->window->layer] = TRUE;
|
||||
}
|
||||
else if (op->lowered)
|
||||
{
|
||||
@ -496,9 +551,13 @@ meta_stack_sync_to_server (MetaStack *stack)
|
||||
stack->layers[op->window->layer] =
|
||||
g_list_append (stack->layers[op->window->layer],
|
||||
op->window);
|
||||
|
||||
needs_sort[op->window->layer] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (op->window)
|
||||
op->window->stack_op = NULL;
|
||||
g_free (op);
|
||||
|
||||
tmp = tmp->next;
|
||||
@ -508,32 +567,22 @@ meta_stack_sync_to_server (MetaStack *stack)
|
||||
stack->pending = NULL;
|
||||
stack->n_added = 0;
|
||||
|
||||
/* Sort the layer lists */
|
||||
i = 0;
|
||||
while (i < META_LAYER_LAST)
|
||||
{
|
||||
if (needs_sort[i])
|
||||
{
|
||||
stack->layers[i] =
|
||||
g_list_sort (stack->layers[i],
|
||||
(GCompareFunc) window_stack_cmp);
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
/* Create stacked xwindow array */
|
||||
/* Create stacked xwindow arrays */
|
||||
stacked = g_array_new (FALSE, FALSE, sizeof (Window));
|
||||
root_children_stacked = g_array_new (FALSE, FALSE, sizeof (Window));
|
||||
i = 0;
|
||||
while (i < META_LAYER_LAST)
|
||||
{
|
||||
/* Sort each layer... */
|
||||
if (needs_sort[i])
|
||||
{
|
||||
stack->layers[i] =
|
||||
g_list_sort (stack->layers[i],
|
||||
(GCompareFunc) window_stack_cmp);
|
||||
meta_verbose ("Sorting layer %d\n", i);
|
||||
stack->layers[i] = sort_window_list (stack->layers[i]);
|
||||
}
|
||||
|
||||
/* ... then append it */
|
||||
meta_verbose ("Layer %d: ", i);
|
||||
meta_push_no_msg_prefix ();
|
||||
tmp = stack->layers[i];
|
||||
while (tmp != NULL)
|
||||
{
|
||||
@ -541,9 +590,19 @@ meta_stack_sync_to_server (MetaStack *stack)
|
||||
|
||||
g_array_append_val (stacked, w->xwindow);
|
||||
|
||||
if (w->frame)
|
||||
g_array_append_val (root_children_stacked, w->frame->xwindow);
|
||||
else
|
||||
g_array_append_val (root_children_stacked, w->xwindow);
|
||||
|
||||
meta_verbose ("%s ", w->desc);
|
||||
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
meta_verbose ("\n");
|
||||
meta_pop_no_msg_prefix ();
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
@ -554,10 +613,13 @@ meta_stack_sync_to_server (MetaStack *stack)
|
||||
|
||||
/* Sync to server */
|
||||
|
||||
meta_verbose ("Restacking %d windows\n",
|
||||
root_children_stacked->len);
|
||||
|
||||
meta_error_trap_push (stack->screen->display);
|
||||
XRestackWindows (stack->screen->display->xdisplay,
|
||||
(Window *) stacked->data,
|
||||
stacked->len);
|
||||
(Window *) root_children_stacked->data,
|
||||
root_children_stacked->len);
|
||||
meta_error_trap_pop (stack->screen->display);
|
||||
/* on error, a window was destroyed; it should eventually
|
||||
* get removed from the stacking list when we unmanage it
|
||||
@ -569,19 +631,20 @@ meta_stack_sync_to_server (MetaStack *stack)
|
||||
XChangeProperty (stack->screen->display->xdisplay,
|
||||
stack->screen->xroot,
|
||||
stack->screen->display->atom_net_client_list,
|
||||
XA_ATOM,
|
||||
XA_WINDOW,
|
||||
32, PropModeReplace,
|
||||
stack->windows->data,
|
||||
stack->windows->len);
|
||||
XChangeProperty (stack->screen->display->xdisplay,
|
||||
stack->screen->xroot,
|
||||
stack->screen->display->atom_net_client_list_stacking,
|
||||
XA_ATOM,
|
||||
XA_WINDOW,
|
||||
32, PropModeReplace,
|
||||
stacked->data,
|
||||
stacked->len);
|
||||
|
||||
g_array_free (stacked, TRUE);
|
||||
g_array_free (root_children_stacked, TRUE);
|
||||
|
||||
/* That was scary... */
|
||||
}
|
||||
|
20
src/util.c
20
src/util.c
@ -29,6 +29,7 @@
|
||||
static gboolean is_verbose = FALSE;
|
||||
static gboolean is_debugging = FALSE;
|
||||
static gboolean is_syncing = FALSE;
|
||||
static int no_prefix = 0;
|
||||
|
||||
gboolean
|
||||
meta_is_verbose (void)
|
||||
@ -95,6 +96,7 @@ meta_debug_spew (const char *format, ...)
|
||||
str = g_strdup_vprintf (format, args);
|
||||
va_end (args);
|
||||
|
||||
if (no_prefix == 0)
|
||||
fputs ("Window manager: ", stderr);
|
||||
fputs (str, stderr);
|
||||
|
||||
@ -116,6 +118,7 @@ meta_verbose (const char *format, ...)
|
||||
str = g_strdup_vprintf (format, args);
|
||||
va_end (args);
|
||||
|
||||
if (no_prefix == 0)
|
||||
fputs ("Window manager: ", stderr);
|
||||
fputs (str, stderr);
|
||||
|
||||
@ -134,6 +137,7 @@ meta_bug (const char *format, ...)
|
||||
str = g_strdup_vprintf (format, args);
|
||||
va_end (args);
|
||||
|
||||
if (no_prefix == 0)
|
||||
fputs ("Bug in window manager: ", stderr);
|
||||
fputs (str, stderr);
|
||||
|
||||
@ -155,6 +159,7 @@ meta_warning (const char *format, ...)
|
||||
str = g_strdup_vprintf (format, args);
|
||||
va_end (args);
|
||||
|
||||
if (no_prefix == 0)
|
||||
fputs ("Window manager: ", stderr);
|
||||
fputs (str, stderr);
|
||||
|
||||
@ -173,6 +178,7 @@ meta_fatal (const char *format, ...)
|
||||
str = g_strdup_vprintf (format, args);
|
||||
va_end (args);
|
||||
|
||||
if (no_prefix == 0)
|
||||
fputs ("Window manager: ", stderr);
|
||||
fputs (str, stderr);
|
||||
|
||||
@ -180,3 +186,17 @@ meta_fatal (const char *format, ...)
|
||||
|
||||
meta_exit (META_EXIT_ERROR);
|
||||
}
|
||||
|
||||
void
|
||||
meta_push_no_msg_prefix (void)
|
||||
{
|
||||
++no_prefix;
|
||||
}
|
||||
|
||||
void
|
||||
meta_pop_no_msg_prefix (void)
|
||||
{
|
||||
g_return_if_fail (no_prefix > 0);
|
||||
|
||||
--no_prefix;
|
||||
}
|
||||
|
@ -53,6 +53,9 @@ void meta_warning (const char *format,
|
||||
void meta_fatal (const char *format,
|
||||
...) G_GNUC_PRINTF (1, 2);
|
||||
|
||||
void meta_push_no_msg_prefix (void);
|
||||
void meta_pop_no_msg_prefix (void);
|
||||
|
||||
/* FIXME */
|
||||
#include <config.h>
|
||||
#define _(x) x
|
||||
|
18
src/window.c
18
src/window.c
@ -781,25 +781,25 @@ meta_window_focus (MetaWindow *window,
|
||||
meta_verbose ("Setting input focus to window %s, input: %d take_focus: %d\n",
|
||||
window->desc, window->input, window->take_focus);
|
||||
|
||||
meta_error_trap_push (window->display);
|
||||
|
||||
if (window->input)
|
||||
{
|
||||
meta_error_trap_push (window->display);
|
||||
XSetInputFocus (window->display->xdisplay,
|
||||
window->xwindow,
|
||||
RevertToPointerRoot,
|
||||
timestamp);
|
||||
}
|
||||
|
||||
if (window->take_focus)
|
||||
{
|
||||
meta_window_send_icccm_message (window,
|
||||
window->display->atom_wm_take_focus,
|
||||
timestamp);
|
||||
}
|
||||
else
|
||||
{
|
||||
XSetInputFocus (window->display->xdisplay,
|
||||
window->xwindow,
|
||||
RevertToParent,
|
||||
timestamp);
|
||||
}
|
||||
|
||||
meta_error_trap_pop (window->display);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_change_workspace (MetaWindow *window,
|
||||
|
Loading…
Reference in New Issue
Block a user