From f36ba88085160867791f73704fb023a165d29752 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 7 Jan 2002 03:26:09 +0000 Subject: [PATCH] put in attempted fix for the GTK 1.2 plug/socket screwup, now that my 2002-01-06 Havoc Pennington * src/window.c (meta_window_notify_focus): put in attempted fix for the GTK 1.2 plug/socket screwup, now that my fixed debug spew reveals what's actually happening. ;-) * src/gradient.c (meta_gradient_description_new): object to store gradient descriptions * src/window.c (meta_window_notify_focus): fix the debug spew that was confusing me * src/wm-tester/focus-window.c: add little program to focus a window ID --- ChangeLog | 15 ++++ src/gradient.c | 129 +++++++---------------------------- src/gradient.h | 20 ++++++ src/run-metacity.sh | 28 ++++++-- src/theme.h | 7 ++ src/window.c | 14 +++- src/wm-tester/Makefile.am | 8 ++- src/wm-tester/focus-window.c | 37 ++++++++++ 8 files changed, 144 insertions(+), 114 deletions(-) create mode 100644 src/wm-tester/focus-window.c diff --git a/ChangeLog b/ChangeLog index 4a36e016b..e8668196a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2002-01-06 Havoc Pennington + + * src/window.c (meta_window_notify_focus): put in attempted fix + for the GTK 1.2 plug/socket screwup, now that my fixed debug spew + reveals what's actually happening. ;-) + + * src/gradient.c (meta_gradient_description_new): object + to store gradient descriptions + + * src/window.c (meta_window_notify_focus): fix the debug spew + that was confusing me + + * src/wm-tester/focus-window.c: add little program to focus + a window ID + 2002-01-06 Havoc Pennington * src/theme.c (meta_theme_get_gradient): change to use spiffy diff --git a/src/gradient.c b/src/gradient.c index 61cb32bf1..2fcfc8bd0 100644 --- a/src/gradient.c +++ b/src/gradient.c @@ -736,118 +736,39 @@ meta_gradient_create_multi_diagonal (int width, int height, return pixbuf; } -#ifdef META_TEST_GRADIENTS -#include - -typedef void (* RenderGradientFunc) (GdkDrawable *drawable, - GdkGC *gc, - int width, - int height); - -static void -render_simple (GdkDrawable *drawable, - GdkGC *gc, - int width, int height, - MetaGradientType type) +MetaGradientDescription* +meta_gradient_description_new (MetaGradientType type, + const GdkColor *colors, + int n_colors) { - GdkPixbuf *pixbuf; - GdkColor from, to; + MetaGradientDescription *desc; - gdk_color_parse ("blue", &from); - gdk_color_parse ("green", &to); + desc = g_new (MetaGradientDescription, 1); - pixbuf = meta_gradient_create_simple (width, height, - &from, &to, - type); + desc->type = type; + desc->colors = g_new (GdkColor, n_colors); + desc->n_colors = n_colors; - gdk_pixbuf_render_to_drawable (pixbuf, - drawable, - gc, - 0, 0, - 0, 0, width, height, - GDK_RGB_DITHER_NORMAL, - 0, 0); - - g_object_unref (G_OBJECT (pixbuf)); -} - -static void -render_vertical_func (GdkDrawable *drawable, - GdkGC *gc, - int width, int height) -{ - render_simple (drawable, gc, width, height, META_GRADIENT_VERTICAL); -} - -static void -render_horizontal_func (GdkDrawable *drawable, - GdkGC *gc, - int width, int height) -{ - render_simple (drawable, gc, width, height, META_GRADIENT_HORIZONTAL); -} - -static void -render_diagonal_func (GdkDrawable *drawable, - GdkGC *gc, - int width, int height) -{ - render_simple (drawable, gc, width, height, META_GRADIENT_DIAGONAL); -} - -static gboolean -expose_callback (GtkWidget *widget, - GdkEventExpose *event, - gpointer data) -{ - RenderGradientFunc func = data; - - (* func) (widget->window, - widget->style->fg_gc[widget->state], - widget->allocation.width, - widget->allocation.height); - - return TRUE; -} - -static GtkWidget* -create_gradient_window (RenderGradientFunc func) -{ - GtkWidget *window; - GtkWidget *drawing_area; - - window = gtk_window_new (GTK_WINDOW_POPUP); - - drawing_area = gtk_drawing_area_new (); - - gtk_widget_set_size_request (drawing_area, 175, 175); - - g_signal_connect (G_OBJECT (drawing_area), - "expose_event", - G_CALLBACK (expose_callback), - func); - - gtk_container_add (GTK_CONTAINER (window), drawing_area); - - return window; + memcpy (desc->colors, colors, sizeof (GdkColor) * n_colors); + + return desc; } void -meta_gradient_test (void) +meta_gradient_description_free (MetaGradientDescription *desc) { - GtkWidget *window; - - window = create_gradient_window (render_vertical_func); - gtk_window_move (GTK_WINDOW (window), 0, 0); - gtk_widget_show_all (window); + g_return_if_fail (desc != NULL); - window = create_gradient_window (render_horizontal_func); - gtk_window_move (GTK_WINDOW (window), 0, 200); - gtk_widget_show_all (window); - - window = create_gradient_window (render_diagonal_func); - gtk_window_move (GTK_WINDOW (window), 200, 0); - gtk_widget_show_all (window); + g_free (desc->colors); + g_free (desc); } -#endif +GdkPixbuf* +meta_gradient_description_render (const MetaGradientDescription *desc, + int width, + int height) +{ + return meta_gradient_create_multi (width, height, + desc->colors, desc->n_colors, + desc->type); +} diff --git a/src/gradient.h b/src/gradient.h index 079150cac..4b14475bf 100644 --- a/src/gradient.h +++ b/src/gradient.h @@ -32,6 +32,26 @@ typedef enum META_GRADIENT_DIAGONAL } MetaGradientType; +typedef struct _MetaGradientDescription MetaGradientDescription; + +/* this doesn't support interwoven at the moment, since + * I don't know what interwoven is good for + */ +struct _MetaGradientDescription +{ + MetaGradientType type; + GdkColor *colors; + int n_colors; +}; + +MetaGradientDescription* meta_gradient_description_new (MetaGradientType type, + const GdkColor *colors, + int n_colors); +void meta_gradient_description_free (MetaGradientDescription *desc); +GdkPixbuf* meta_gradient_description_render (const MetaGradientDescription *desc, + int width, + int height); + GdkPixbuf* meta_gradient_create_simple (int width, int height, diff --git a/src/run-metacity.sh b/src/run-metacity.sh index 30d728084..e1485cea5 100755 --- a/src/run-metacity.sh +++ b/src/run-metacity.sh @@ -1,5 +1,13 @@ #! /bin/bash +if test -z "$XNEST_DISPLAY"; then + XNEST_DISPLAY=:1 +fi + +if test -z "$CLIENT_DISPLAY"; then + CLIENT_DISPLAY=:1 +fi + if test -z "$SCREENS"; then SCREENS=1 fi @@ -27,33 +35,41 @@ if test -n "$ICON_TEST"; then fi if test -z "$ONLY_WM"; then - Xnest -ac :1 -scrns $SCREENS -geometry 640x480 -bw 15 & + echo "Launching Xnest" + Xnest -ac $XNEST_DISPLAY -scrns $SCREENS -geometry 640x480 -bw 15 & ## usleep 800000 sleep 1 + if test -n "$XMON_DIR"; then + echo "Launching xmond" + $XMON_DIR/xmonui | $XMON_DIR/xmond -server $XNEST_DISPLAY & + sleep 1 + fi + + echo "Launching clients" if test -n "$TEST_CLIENT"; then - DISPLAY=:1 $TEST_CLIENT & + DISPLAY=$CLIENT_DISPLAY $TEST_CLIENT & fi if test $CLIENTS != 0; then for I in `seq 1 $CLIENTS`; do echo "Launching xterm $I" - DISPLAY=:1 xterm -geometry 25x15 & + DISPLAY=$CLIENT_DISPLAY xterm -geometry 25x15 & done fi if test $SM_CLIENTS != 0; then for I in `seq 1 $SM_CLIENTS`; do echo "Launching gnome-terminal $I" - DISPLAY=:1 gnome-terminal --geometry 25x15 & + DISPLAY=$CLIENT_DISPLAY gnome-terminal --geometry 25x15 & done fi usleep 50000 - DISPLAY=:1 xsetroot -solid royalblue3 + DISPLAY=$CLIENT_DISPLAY xsetroot -solid royalblue3 fi if test -z "$ONLY_SETUP"; then - METACITY_DEBUG_BUTTON_GRABS=1 METACITY_DISPLAY=:1 exec libtool --mode=execute $DEBUG ./metacity $OPTIONS + METACITY_DEBUG_BUTTON_GRABS=1 METACITY_DISPLAY=$CLIENT_DISPLAY exec libtool --mode=execute $DEBUG ./metacity $OPTIONS fi diff --git a/src/theme.h b/src/theme.h index 8a3cbae98..78a967506 100644 --- a/src/theme.h +++ b/src/theme.h @@ -28,7 +28,14 @@ /* theme.[hc] is basically responsible for drawing parts of the UI using * theme data */ +typedef struct _MetaFrameStyle MetaFrameStyle; +struct _MetaFrameStyle +{ + MetaGradientDescription *title_gradient; + + +}; GdkPixbuf* meta_theme_get_gradient (MetaGradientType type, const GdkColor *color_one, diff --git a/src/window.c b/src/window.c index ea59ee2c1..bd4b21907 100644 --- a/src/window.c +++ b/src/window.c @@ -2683,13 +2683,13 @@ meta_window_notify_focus (MetaWindow *window, event->type != UnmapNotify ? meta_focus_mode_to_string (event->xfocus.mode) : "n/a", event->type != UnmapNotify ? - meta_focus_detail_to_string (event->xfocus.mode) : "n/a"); + meta_focus_detail_to_string (event->xfocus.detail) : "n/a"); if ((event->type == FocusIn || event->type == FocusOut) && (event->xfocus.mode == NotifyGrab || event->xfocus.mode == NotifyUngrab || - /* From WindowMaker */ + /* From WindowMaker, ignore all funky pointer root events */ event->xfocus.detail > NotifyNonlinearVirtual)) { meta_topic (META_DEBUG_FOCUS, @@ -2720,6 +2720,16 @@ meta_window_notify_focus (MetaWindow *window, else if (event->type == FocusOut || event->type == UnmapNotify) { + if (event->type == FocusOut && + event->xfocus.detail == NotifyInferior) + { + /* This event means the client moved focus to a subwindow */ + meta_topic (META_DEBUG_FOCUS, + "Ignoring focus out on %s with NotifyInferior\n", + window->desc); + return TRUE; + } + if (window == window->display->focus_window) { meta_topic (META_DEBUG_FOCUS, diff --git a/src/wm-tester/Makefile.am b/src/wm-tester/Makefile.am index e6ec26736..8673127a1 100644 --- a/src/wm-tester/Makefile.am +++ b/src/wm-tester/Makefile.am @@ -7,7 +7,11 @@ wm_tester_SOURCES= \ test_gravity_SOURCES= \ test-gravity.c -noinst_PROGRAMS=wm-tester test-gravity +focus_window_SOURCES= \ + focus-window.c + +noinst_PROGRAMS=wm-tester test-gravity focus-window wm_tester_LDADD= @METACITY_LIBS@ -test_gravity_LDADD= @METACITY_LIBS@ \ No newline at end of file +test_gravity_LDADD= @METACITY_LIBS@ +focus_window_LDADD= @METACITY_LIBS@ \ No newline at end of file diff --git a/src/wm-tester/focus-window.c b/src/wm-tester/focus-window.c new file mode 100644 index 000000000..dc33bd25d --- /dev/null +++ b/src/wm-tester/focus-window.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include + +int main (int argc, char **argv) +{ + Display *d; + Window w; + const char *w_str; + char *end; + + if (argc != 2) + { + fprintf (stderr, "Usage: focus-window WINDOWID\n"); + exit (1); + } + + d = XOpenDisplay (NULL); + + w_str = argv[1]; + end = NULL; + + w = strtoul (w_str, &end, 16); + if (end == w_str) + { + fprintf (stderr, "Usage: focus-window WINDOWID\n"); + exit (1); + } + + printf ("Setting input focus to 0x%lx\n", w); + XSetInputFocus (d, w, RevertToPointerRoot, CurrentTime); + XFlush (d); + + return 0; +} +