This commit is contained in:
rhp 2001-06-11 05:47:51 +00:00
parent d46d6830b5
commit 99f53856f6
11 changed files with 251 additions and 47 deletions

View File

@ -589,7 +589,7 @@ event_queue_callback (MetaEventQueue *queue,
xwc.height = event->xconfigurerequest.height; xwc.height = event->xconfigurerequest.height;
xwc.border_width = event->xconfigurerequest.border_width; xwc.border_width = event->xconfigurerequest.border_width;
meta_verbose ("Configuring withdrawn window to %d,%d %dx%d border %d\n", meta_verbose ("Configuring withdrawn window to %d,%d %dx%d border %d (some values may not be in mask)\n",
xwc.x, xwc.y, xwc.width, xwc.height, xwc.border_width); xwc.x, xwc.y, xwc.width, xwc.height, xwc.border_width);
XConfigureWindow (display->xdisplay, event->xconfigurerequest.window, XConfigureWindow (display->xdisplay, event->xconfigurerequest.window,
xwcm, &xwc); xwcm, &xwc);
@ -897,14 +897,24 @@ meta_spew_event (MetaDisplay *display,
break; break;
case ConfigureRequest: case ConfigureRequest:
name = "ConfigureRequest"; name = "ConfigureRequest";
extra = g_strdup_printf ("parent: 0x%lx window: 0x%lx x: %d y: %d w: %d h: %d border: %d", extra = g_strdup_printf ("parent: 0x%lx window: 0x%lx x: %d %sy: %d %sw: %d %sh: %d %sborder: %d %s",
event->xconfigurerequest.parent, event->xconfigurerequest.parent,
event->xconfigurerequest.window, event->xconfigurerequest.window,
event->xconfigurerequest.x, event->xconfigurerequest.x,
event->xconfigurerequest.value_mask &
CWX ? "" : "(unset) ",
event->xconfigurerequest.y, event->xconfigurerequest.y,
event->xconfigurerequest.value_mask &
CWY ? "" : "(unset) ",
event->xconfigurerequest.width, event->xconfigurerequest.width,
event->xconfigurerequest.value_mask &
CWWidth ? "" : "(unset) ",
event->xconfigurerequest.height, event->xconfigurerequest.height,
event->xconfigurerequest.border_width); event->xconfigurerequest.value_mask &
CWHeight ? "" : "(unset) ",
event->xconfigurerequest.border_width,
event->xconfigurerequest.value_mask &
CWBorderWidth ? "" : "(unset)");
break; break;
case GravityNotify: case GravityNotify:
name = "GravityNotify"; name = "GravityNotify";

View File

@ -76,6 +76,8 @@ struct _MetaDisplay
Atom atom_net_wm_state_modal; Atom atom_net_wm_state_modal;
Atom atom_net_client_list; Atom atom_net_client_list;
Atom atom_net_client_list_stacking; Atom atom_net_client_list_stacking;
Atom atom_net_wm_state_skip_taskbar;
Atom atom_net_wm_state_skip_pager;
/* This is the actual window from focus events, /* This is the actual window from focus events,
* not the one we last set * not the one we last set

View File

@ -250,10 +250,13 @@ meta_window_ensure_frame (MetaWindow *window)
* we don't want to take that as a withdraw * we don't want to take that as a withdraw
*/ */
window->unmaps_pending += 1; window->unmaps_pending += 1;
window->rect.x = 0;
window->rect.y = 0;
XReparentWindow (window->display->xdisplay, XReparentWindow (window->display->xdisplay,
window->xwindow, window->xwindow,
frame->xwindow, frame->xwindow,
0, 0); window->rect.x,
window->rect.y);
meta_error_trap_pop (window->display); meta_error_trap_pop (window->display);
/* stick frame to the window */ /* stick frame to the window */

View File

@ -25,6 +25,11 @@
#include "errors.h" #include "errors.h"
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
static MetaExitCode meta_exit_code = META_EXIT_SUCCESS; static MetaExitCode meta_exit_code = META_EXIT_SUCCESS;
static GMainLoop *meta_main_loop = NULL; static GMainLoop *meta_main_loop = NULL;
@ -32,6 +37,15 @@ static GMainLoop *meta_main_loop = NULL;
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
struct sigaction act;
sigset_t empty_mask;
sigemptyset (&empty_mask);
act.sa_handler = SIG_IGN;
act.sa_mask = empty_mask;
act.sa_flags = 0;
sigaction (SIGPIPE, &act, 0);
g_set_prgname (PACKAGE); g_set_prgname (PACKAGE);
meta_main_loop = g_main_loop_new (NULL, FALSE); meta_main_loop = g_main_loop_new (NULL, FALSE);

View File

@ -13,15 +13,19 @@ if test -z "$CLIENTS"; then
CLIENTS=0 CLIENTS=0
fi fi
Xnest :1 -scrns $SCREENS -geometry 640x480 -bw 15 & if test -z "$ONLY_WM"; then
usleep 50000 Xnest :1 -scrns $SCREENS -geometry 640x480 -bw 15 &
usleep 50000
if test $CLIENTS != 0; then if test $CLIENTS != 0; then
for I in `seq 1 $CLIENTS`; do for I in `seq 1 $CLIENTS`; do
DISPLAY=:1 xterm -geometry 25x15 & DISPLAY=:1 xterm -geometry 25x15 &
done done
fi
DISPLAY=:1 xsetroot -solid royalblue3
fi fi
DISPLAY=:1 xsetroot -solid royalblue3 if test -z "$ONLY_SETUP"; then
METACITY_UISLAVE_DIR=./uislave DISPLAY=:1 unst libtool --mode=execute $DEBUG ./metacity METACITY_UISLAVE_DIR=./uislave DISPLAY=:1 unst libtool --mode=execute $DEBUG ./metacity
killall Xnest fi

View File

@ -61,7 +61,7 @@ set_wm_check_hint (MetaScreen *screen)
static int static int
set_supported_hint (MetaScreen *screen) set_supported_hint (MetaScreen *screen)
{ {
#define N_SUPPORTED 19 #define N_SUPPORTED 21
Atom atoms[N_SUPPORTED]; Atom atoms[N_SUPPORTED];
atoms[0] = screen->display->atom_net_wm_name; atoms[0] = screen->display->atom_net_wm_name;
@ -83,6 +83,8 @@ set_supported_hint (MetaScreen *screen)
atoms[16] = screen->display->atom_net_wm_state_modal; atoms[16] = screen->display->atom_net_wm_state_modal;
atoms[17] = screen->display->atom_net_client_list; atoms[17] = screen->display->atom_net_client_list;
atoms[18] = screen->display->atom_net_client_list_stacking; atoms[18] = screen->display->atom_net_client_list_stacking;
atoms[19] = screen->display->atom_net_wm_state_skip_taskbar;
atoms[20] = screen->display->atom_net_wm_state_skip_pager;
XChangeProperty (screen->display->xdisplay, screen->xroot, XChangeProperty (screen->display->xdisplay, screen->xroot,
screen->display->atom_net_wm_supported, screen->display->atom_net_wm_supported,
@ -244,7 +246,7 @@ meta_screen_manage_all_windows (MetaScreen *screen)
i = 0; i = 0;
while (i < n_children) while (i < n_children)
{ {
meta_window_new (screen->display, children[i]); meta_window_new (screen->display, children[i], TRUE);
++i; ++i;
} }

View File

@ -60,6 +60,7 @@ meta_stack_new (MetaScreen *screen)
} }
stack->pending = NULL; stack->pending = NULL;
stack->freeze_count = 0; stack->freeze_count = 0;
stack->n_added = 0;
return stack; return stack;
} }
@ -124,6 +125,8 @@ meta_stack_add (MetaStack *stack,
{ {
MetaStackOp *op; MetaStackOp *op;
meta_verbose ("Adding window %s to the stack\n", window->desc);
op = ensure_op (stack, window); op = ensure_op (stack, window);
if (op->add_order >= 0) if (op->add_order >= 0)
@ -149,6 +152,8 @@ meta_stack_remove (MetaStack *stack,
{ {
MetaStackOp *op; MetaStackOp *op;
meta_verbose ("Removing window %s from the stack\n", window->desc);
op = ensure_op (stack, window); op = ensure_op (stack, window);
if (op->add_order >= 0) if (op->add_order >= 0)

View File

@ -56,7 +56,7 @@ meta_ui_slave_new (const char *display_name,
reset_vals (uislave); reset_vals (uislave);
/* This may fail; all UISlave functions become no-ops /* This may fail; all UISlave functions become no-ops
* if uislave->child_pids == 0, and metacity just runs * if uislave->disabled, and metacity just runs
* with no UI features other than window borders. * with no UI features other than window borders.
*/ */
respawn_child (uislave); respawn_child (uislave);
@ -86,6 +86,7 @@ meta_ui_slave_disable (MetaUISlave *uislave)
*/ */
kill_child (uislave); kill_child (uislave);
uislave->no_respawn = TRUE; uislave->no_respawn = TRUE;
meta_warning ("UI slave disabled, no tooltips or window menus will work\n");
} }
static void static void
@ -105,21 +106,36 @@ respawn_child (MetaUISlave *uislave)
{ {
GError *error; GError *error;
const char *uislavedir; const char *uislavedir;
char *argv[] = { "./metacity-uislave", NULL }; char *argv[] = { NULL, NULL, NULL, NULL, NULL };
char *envp[2] = { NULL, NULL }; char *envp[2] = { NULL, NULL };
int child_pid, inpipe, outpipe, errpipe; int child_pid, inpipe, outpipe, errpipe;
char *path;
if (uislave->no_respawn) if (uislave->no_respawn)
return; return;
if (uislave->child_pid != 0)
return;
uislavedir = g_getenv ("METACITY_UISLAVE_DIR"); uislavedir = g_getenv ("METACITY_UISLAVE_DIR");
if (uislavedir == NULL) if (uislavedir == NULL)
uislavedir = METACITY_LIBEXECDIR; uislavedir = METACITY_LIBEXECDIR;
envp[0] = g_strconcat ("DISPLAY=", uislave->display_name, NULL); envp[0] = g_strconcat ("DISPLAY=", uislave->display_name, NULL);
path = g_strconcat (uislavedir, "/", "metacity-uislave", NULL);
#if 0
argv[0] = "/usr/bin/strace";
argv[1] = "-o";
argv[2] = "uislave-strace.log";
#endif
argv[0] = path;
meta_verbose ("Launching UI slave in dir %s display %s\n",
uislavedir, envp[0]);
error = NULL; error = NULL;
if (g_spawn_async_with_pipes (uislavedir, if (g_spawn_async_with_pipes (NULL,
argv, argv,
envp, envp,
/* flags */ /* flags */
@ -156,6 +172,7 @@ respawn_child (MetaUISlave *uislave)
} }
g_free (envp[0]); g_free (envp[0]);
g_free (path);
} }
static gboolean static gboolean
@ -168,14 +185,35 @@ error_callback (GIOChannel *source,
MetaUISlave *uislave; MetaUISlave *uislave;
char buf[1024]; char buf[1024];
int n; int n;
static int logfile = -1;
if (meta_is_debugging () && logfile < 0)
{
const char *dir;
char *str;
dir = g_get_home_dir ();
str = g_strconcat (dir, "/", "metacity-uislave.log", NULL);
logfile = open (str, O_TRUNC | O_CREAT, 0644);
if (logfile < 0)
meta_warning ("Failed to open uislave log file %s\n", str);
else
meta_verbose ("Opened uislave log file %s\n", str);
g_free (str);
}
if (logfile < 0)
logfile = 2;
uislave = data; uislave = data;
/* Classic loop from Stevens */
n = read (uislave->err_pipe, buf, BUFSIZE); n = read (uislave->err_pipe, buf, BUFSIZE);
if (n > 0) if (n > 0)
{ {
if (write (2, buf, n) != n) if (write (logfile, buf, n) != n)
; /* error, but printing a message to stderr will hardly help. */ ; /* error, but printing a message to stderr will hardly help. */
} }
else if (n < 0) else if (n < 0)
@ -271,6 +309,11 @@ send_message (MetaUISlave *uislave, MetaMessage *message)
static int serial = 0; static int serial = 0;
MetaMessageFooter *footer; MetaMessageFooter *footer;
if (uislave->no_respawn)
return;
respawn_child (uislave);
message->header.serial = serial; message->header.serial = serial;
footer = META_MESSAGE_FOOTER (message); footer = META_MESSAGE_FOOTER (message);
@ -279,12 +322,18 @@ send_message (MetaUISlave *uislave, MetaMessage *message)
if (write_bytes (uislave->in_pipe, if (write_bytes (uislave->in_pipe,
META_MESSAGE_ESCAPE, META_MESSAGE_ESCAPE_LEN) < 0) META_MESSAGE_ESCAPE, META_MESSAGE_ESCAPE_LEN) < 0)
{
meta_warning ("Failed to write escape sequence: %s\n", meta_warning ("Failed to write escape sequence: %s\n",
g_strerror (errno)); g_strerror (errno));
kill_child (uislave);
}
if (write_bytes (uislave->in_pipe, if (write_bytes (uislave->in_pipe,
message, message->header.length) < 0) message, message->header.length) < 0)
{
meta_warning ("Failed to write message: %s\n", meta_warning ("Failed to write message: %s\n",
g_strerror (errno)); g_strerror (errno));
kill_child (uislave);
}
} }
void void

View File

@ -30,6 +30,29 @@ static gboolean is_verbose = FALSE;
static gboolean is_debugging = FALSE; static gboolean is_debugging = FALSE;
static gboolean is_syncing = FALSE; static gboolean is_syncing = FALSE;
static int no_prefix = 0; static int no_prefix = 0;
static FILE* logfile = NULL;
static void
ensure_logfile (void)
{
if (logfile == NULL)
{
const char *dir;
char *str;
dir = g_get_home_dir ();
str = g_strconcat (dir, "/", "metacity.log", NULL);
logfile = fopen (str, "w");
if (logfile == NULL)
meta_warning ("Failed to open log file %s\n", str);
else
meta_verbose ("Opened log file %s\n", str);
g_free (str);
}
}
gboolean gboolean
meta_is_verbose (void) meta_is_verbose (void)
@ -40,6 +63,9 @@ meta_is_verbose (void)
void void
meta_set_verbose (gboolean setting) meta_set_verbose (gboolean setting)
{ {
if (setting)
ensure_logfile ();
is_verbose = setting; is_verbose = setting;
} }
@ -52,10 +78,12 @@ meta_is_debugging (void)
void void
meta_set_debugging (gboolean setting) meta_set_debugging (gboolean setting)
{ {
if (setting)
ensure_logfile ();
is_debugging = setting; is_debugging = setting;
} }
gboolean gboolean
meta_is_syncing (void) meta_is_syncing (void)
{ {
@ -86,6 +114,7 @@ meta_debug_spew (const char *format, ...)
{ {
va_list args; va_list args;
gchar *str; gchar *str;
FILE *out;
g_return_if_fail (format != NULL); g_return_if_fail (format != NULL);
@ -96,9 +125,11 @@ meta_debug_spew (const char *format, ...)
str = g_strdup_vprintf (format, args); str = g_strdup_vprintf (format, args);
va_end (args); va_end (args);
out = logfile ? logfile : stderr;
if (no_prefix == 0) if (no_prefix == 0)
fputs ("Window manager: ", stderr); fputs ("Window manager: ", out);
fputs (str, stderr); fputs (str, out);
g_free (str); g_free (str);
} }
@ -108,6 +139,7 @@ meta_verbose (const char *format, ...)
{ {
va_list args; va_list args;
gchar *str; gchar *str;
FILE *out;
g_return_if_fail (format != NULL); g_return_if_fail (format != NULL);
@ -118,9 +150,11 @@ meta_verbose (const char *format, ...)
str = g_strdup_vprintf (format, args); str = g_strdup_vprintf (format, args);
va_end (args); va_end (args);
out = logfile ? logfile : stderr;
if (no_prefix == 0) if (no_prefix == 0)
fputs ("Window manager: ", stderr); fputs ("Window manager: ", out);
fputs (str, stderr); fputs (str, out);
g_free (str); g_free (str);
} }
@ -130,6 +164,7 @@ meta_bug (const char *format, ...)
{ {
va_list args; va_list args;
gchar *str; gchar *str;
FILE *out;
g_return_if_fail (format != NULL); g_return_if_fail (format != NULL);
@ -137,9 +172,11 @@ meta_bug (const char *format, ...)
str = g_strdup_vprintf (format, args); str = g_strdup_vprintf (format, args);
va_end (args); va_end (args);
out = logfile ? logfile : stderr;
if (no_prefix == 0) if (no_prefix == 0)
fputs ("Bug in window manager: ", stderr); fputs ("Bug in window manager: ", out);
fputs (str, stderr); fputs (str, out);
g_free (str); g_free (str);
@ -152,6 +189,7 @@ meta_warning (const char *format, ...)
{ {
va_list args; va_list args;
gchar *str; gchar *str;
FILE *out;
g_return_if_fail (format != NULL); g_return_if_fail (format != NULL);
@ -159,9 +197,11 @@ meta_warning (const char *format, ...)
str = g_strdup_vprintf (format, args); str = g_strdup_vprintf (format, args);
va_end (args); va_end (args);
out = logfile ? logfile : stderr;
if (no_prefix == 0) if (no_prefix == 0)
fputs ("Window manager: ", stderr); fputs ("Window manager: ", out);
fputs (str, stderr); fputs (str, out);
g_free (str); g_free (str);
} }
@ -171,6 +211,7 @@ meta_fatal (const char *format, ...)
{ {
va_list args; va_list args;
gchar *str; gchar *str;
FILE *out;
g_return_if_fail (format != NULL); g_return_if_fail (format != NULL);
@ -178,9 +219,11 @@ meta_fatal (const char *format, ...)
str = g_strdup_vprintf (format, args); str = g_strdup_vprintf (format, args);
va_end (args); va_end (args);
out = logfile ? logfile : stderr;
if (no_prefix == 0) if (no_prefix == 0)
fputs ("Window manager: ", stderr); fputs ("Window manager: ", out);
fputs (str, stderr); fputs (str, out);
g_free (str); g_free (str);

View File

@ -76,7 +76,8 @@ static void meta_window_move_resize_internal (MetaWindow *window,
int h); int h);
MetaWindow* MetaWindow*
meta_window_new (MetaDisplay *display, Window xwindow) meta_window_new (MetaDisplay *display, Window xwindow,
gboolean must_be_viewable)
{ {
MetaWindow *window; MetaWindow *window;
XWindowAttributes attrs; XWindowAttributes attrs;
@ -107,6 +108,13 @@ meta_window_new (MetaDisplay *display, Window xwindow)
return NULL; return NULL;
} }
if (must_be_viewable && attrs.map_state != IsViewable)
{
meta_verbose ("Deciding not to manage unmapped or unviewable window 0x%lx\n", xwindow);
meta_display_ungrab (display);
return NULL;
}
meta_error_trap_push (display); meta_error_trap_push (display);
XAddToSaveSet (display->xdisplay, xwindow); XAddToSaveSet (display->xdisplay, xwindow);
@ -203,6 +211,8 @@ meta_window_new (MetaDisplay *display, Window xwindow)
window->has_maximize_func = TRUE; window->has_maximize_func = TRUE;
window->wm_state_modal = FALSE; window->wm_state_modal = FALSE;
window->wm_state_skip_taskbar = FALSE;
window->wm_state_skip_pager = FALSE;
window->res_class = NULL; window->res_class = NULL;
window->res_name = NULL; window->res_name = NULL;
@ -345,6 +355,23 @@ set_net_wm_state (MetaWindow *window)
{ {
int i; int i;
unsigned long data[10]; unsigned long data[10];
gboolean skip_pager;
gboolean skip_taskbar;
if (window->type == META_WINDOW_DESKTOP ||
window->type == META_WINDOW_DOCK ||
window->type == META_WINDOW_TOOLBAR ||
window->type == META_WINDOW_MENU)
skip_pager = TRUE;
else
skip_pager = FALSE;
if (window->type == META_WINDOW_DESKTOP ||
window->type == META_WINDOW_DOCK ||
window->type == META_WINDOW_MENU)
skip_taskbar = TRUE;
else
skip_taskbar = FALSE;
i = 0; i = 0;
if (window->shaded) if (window->shaded)
@ -357,6 +384,16 @@ set_net_wm_state (MetaWindow *window)
data[i] = window->display->atom_net_wm_state_modal; data[i] = window->display->atom_net_wm_state_modal;
++i; ++i;
} }
if (window->wm_state_skip_pager || skip_pager)
{
data[i] = window->display->atom_net_wm_state_skip_pager;
++i;
}
if (window->wm_state_skip_taskbar || skip_pager)
{
data[i] = window->display->atom_net_wm_state_skip_taskbar;
++i;
}
if (window->maximized) if (window->maximized)
{ {
data[i] = window->display->atom_net_wm_state_maximized_horz; data[i] = window->display->atom_net_wm_state_maximized_horz;
@ -1307,6 +1344,25 @@ meta_window_client_message (MetaWindow *window,
recalc_window_type (window); recalc_window_type (window);
meta_window_queue_move_resize (window); meta_window_queue_move_resize (window);
}
if (first == display->atom_net_wm_state_skip_pager ||
second == display->atom_net_wm_state_skip_pager)
{
window->wm_state_skip_pager =
(action == _NET_WM_STATE_ADD) ||
(action == _NET_WM_STATE_TOGGLE && !window->wm_state_skip_pager);
set_net_wm_state (window);
}
if (first == display->atom_net_wm_state_skip_taskbar ||
second == display->atom_net_wm_state_skip_taskbar)
{
window->wm_state_skip_taskbar =
(action == _NET_WM_STATE_ADD) ||
(action == _NET_WM_STATE_TOGGLE && !window->wm_state_skip_taskbar);
set_net_wm_state (window); set_net_wm_state (window);
} }
@ -2211,6 +2267,10 @@ update_net_wm_type (MetaWindow *window)
static void static void
recalc_window_type (MetaWindow *window) recalc_window_type (MetaWindow *window)
{ {
int old_type;
old_type = window->type;
if (window->type_atom != None) if (window->type_atom != None)
{ {
if (window->type_atom == window->display->atom_net_wm_window_type_desktop) if (window->type_atom == window->display->atom_net_wm_window_type_desktop)
@ -2241,8 +2301,13 @@ recalc_window_type (MetaWindow *window)
meta_verbose ("Calculated type %d for %s\n", window->type, window->desc); meta_verbose ("Calculated type %d for %s\n", window->type, window->desc);
if (old_type != window->type)
{
set_net_wm_state (window);
/* update stacking constraints */ /* update stacking constraints */
meta_stack_update_layer (window->screen->stack, window); meta_stack_update_layer (window->screen->stack, window);
}
} }
static void static void

View File

@ -109,6 +109,12 @@ struct _MetaWindow
/* Weird "_NET_WM_STATE_MODAL" flag */ /* Weird "_NET_WM_STATE_MODAL" flag */
guint wm_state_modal : 1; guint wm_state_modal : 1;
/* If these are TRUE, it just means a client explicitly
* toggled them on; we compute actual _NET_WM_STATE from
* window type usually
*/
guint wm_state_skip_taskbar : 1;
guint wm_state_skip_pager : 1;
/* this flag tracks receipt of focus_in focus_out and /* this flag tracks receipt of focus_in focus_out and
* determines whether we draw the focus * determines whether we draw the focus
@ -153,7 +159,8 @@ struct _MetaWindow
}; };
MetaWindow* meta_window_new (MetaDisplay *display, MetaWindow* meta_window_new (MetaDisplay *display,
Window xwindow); Window xwindow,
gboolean must_be_viewable);
void meta_window_free (MetaWindow *window); void meta_window_free (MetaWindow *window);
void meta_window_calc_showing (MetaWindow *window); void meta_window_calc_showing (MetaWindow *window);
void meta_window_queue_calc_showing (MetaWindow *window); void meta_window_queue_calc_showing (MetaWindow *window);