new function

2003-11-20  Havoc Pennington  <hp@redhat.com>

	* src/window.c (meta_window_new_with_attrs): new function

	* src/display.c, src/screen.c: create the compositor and feed
	windows and events to it
This commit is contained in:
Havoc Pennington 2003-11-21 02:32:05 +00:00 committed by Havoc Pennington
parent 24d8655188
commit d538690bd4
9 changed files with 188 additions and 60 deletions

View File

@ -1,3 +1,10 @@
2003-11-20 Havoc Pennington <hp@redhat.com>
* src/window.c (meta_window_new_with_attrs): new function
* src/display.c, src/screen.c: create the compositor and feed
windows and events to it
2003-11-20 Havoc Pennington <hp@redhat.com> 2003-11-20 Havoc Pennington <hp@redhat.com>
* src/window.c (meta_window_notify_focus): revert the change here * src/window.c (meta_window_notify_focus): revert the change here

View File

@ -197,8 +197,8 @@ fi
if test x$have_xcomposite = xyes; then if test x$have_xcomposite = xyes; then
echo "Building with CompositeExt" echo "Building with CompositeExt"
METACITY_PC_MODULES="$METACITY_PC_MODULES xcomposite >= $XCOMPOSITE_VERSION xfixes xrender" METACITY_PC_MODULES="$METACITY_PC_MODULES xcomposite >= $XCOMPOSITE_VERSION xfixes xrender xdamage"
AC_DEFINE(HAVE_XCOMPOSITEENSIONS, , [Building with compositing manager support]) AC_DEFINE(HAVE_COMPOSITE_EXTENSIONS, , [Building with compositing manager support])
else else
echo "Building without compositing manager" echo "Building without compositing manager"
fi fi

View File

@ -180,10 +180,45 @@ meta_compositor_add_window (MetaCompositor *compositor,
XWindowAttributes *attrs) XWindowAttributes *attrs)
{ {
#ifdef HAVE_COMPOSITE_EXTENSIONS #ifdef HAVE_COMPOSITE_EXTENSIONS
g_print ("compositor adding window 0x%lx\n", xwindow);
if (!compositor->enabled) if (!compositor->enabled)
return; /* no extension */ return; /* no extension */
#endif /* HAVE_COMPOSITE_EXTENSIONS */
}
void
meta_compositor_remove_window (MetaCompositor *compositor,
Window xwindow)
{
#ifdef HAVE_COMPOSITE_EXTENSIONS
g_print ("compositor removing window 0x%lx\n", xwindow);
if (!compositor->enabled)
return; /* no extension */
#endif /* HAVE_COMPOSITE_EXTENSIONS */
}
void
meta_compositor_manage_screen (MetaCompositor *compositor,
MetaScreen *screen)
{
#ifdef HAVE_COMPOSITE_EXTENSIONS
if (!compositor->enabled)
return; /* no extension */
#endif /* HAVE_COMPOSITE_EXTENSIONS */
}
void
meta_compositor_unmanage_screen (MetaCompositor *compositor,
MetaScreen *screen)
{
#ifdef HAVE_COMPOSITE_EXTENSIONS
if (!compositor->enabled)
return; /* no extension */
#endif /* HAVE_COMPOSITE_EXTENSIONS */ #endif /* HAVE_COMPOSITE_EXTENSIONS */
} }
@ -191,9 +226,3 @@ meta_compositor_add_window (MetaCompositor *compositor,

View File

@ -25,8 +25,6 @@
#include "util.h" #include "util.h"
#include "display.h" #include "display.h"
typedef struct MetaCompositor MetaCompositor;
MetaCompositor* meta_compositor_new (MetaDisplay *display); MetaCompositor* meta_compositor_new (MetaDisplay *display);
void meta_compositor_unref (MetaCompositor *compositor); void meta_compositor_unref (MetaCompositor *compositor);
void meta_compositor_process_event (MetaCompositor *compositor, void meta_compositor_process_event (MetaCompositor *compositor,
@ -35,6 +33,13 @@ void meta_compositor_process_event (MetaCompositor *compositor,
void meta_compositor_add_window (MetaCompositor *compositor, void meta_compositor_add_window (MetaCompositor *compositor,
Window xwindow, Window xwindow,
XWindowAttributes *attrs); XWindowAttributes *attrs);
void meta_compositor_remove_window (MetaCompositor *compositor,
Window xwindow);
void meta_compositor_manage_screen (MetaCompositor *compositor,
MetaScreen *screen);
void meta_compositor_unmanage_screen (MetaCompositor *compositor,
MetaScreen *screen);
#endif /* META_COMPOSITOR_H */ #endif /* META_COMPOSITOR_H */

View File

@ -36,6 +36,7 @@
#include "workspace.h" #include "workspace.h"
#include "bell.h" #include "bell.h"
#include "effects.h" #include "effects.h"
#include "compositor.h"
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/cursorfont.h> #include <X11/cursorfont.h>
#ifdef HAVE_SOLARIS_XINERAMA #ifdef HAVE_SOLARIS_XINERAMA
@ -530,6 +531,8 @@ meta_display_open (const char *name)
#else /* HAVE_SHAPE */ #else /* HAVE_SHAPE */
meta_verbose ("Not compiled with Shape support\n"); meta_verbose ("Not compiled with Shape support\n");
#endif /* !HAVE_SHAPE */ #endif /* !HAVE_SHAPE */
display->compositor = meta_compositor_new (display);
screens = NULL; screens = NULL;
@ -750,6 +753,8 @@ meta_display_close (MetaDisplay *display)
all_displays = g_slist_remove (all_displays, display); all_displays = g_slist_remove (all_displays, display);
meta_display_shutdown_keys (display); meta_display_shutdown_keys (display);
meta_compositor_unref (display->compositor);
g_free (display); g_free (display);
@ -1652,6 +1657,9 @@ event_callback (XEvent *event,
} }
break; break;
case UnmapNotify: case UnmapNotify:
meta_compositor_remove_window (display->compositor,
modified);
if (window) if (window)
{ {
if (display->grab_op != META_GRAB_OP_NONE && if (display->grab_op != META_GRAB_OP_NONE &&
@ -1687,6 +1695,29 @@ event_callback (XEvent *event,
} }
break; break;
case MapNotify: case MapNotify:
{
/* If a window becomes viewable, then we need to
* add it to the compositor
*/
XWindowAttributes attrs;
meta_error_trap_push_with_return (display);
XGetWindowAttributes (display->xdisplay,
modified, &attrs);
if (meta_error_trap_pop_with_return (display, TRUE) != Success)
{
meta_verbose ("Failed to get attributes for window 0x%lx\n",
modified);
}
else
{
if (attrs.map_state == IsViewable)
meta_compositor_add_window (display->compositor,
modified, &attrs);
}
}
break; break;
case MapRequest: case MapRequest:
if (window == NULL) if (window == NULL)

View File

@ -53,6 +53,7 @@ struct _MetaRectangle
int height; int height;
}; };
typedef struct MetaCompositor MetaCompositor;
typedef struct _MetaDisplay MetaDisplay; typedef struct _MetaDisplay MetaDisplay;
typedef struct _MetaFrame MetaFrame; typedef struct _MetaFrame MetaFrame;
typedef struct _MetaKeyBinding MetaKeyBinding; typedef struct _MetaKeyBinding MetaKeyBinding;
@ -293,6 +294,9 @@ struct _MetaDisplay
/* Managed by group-props.c */ /* Managed by group-props.c */
MetaGroupPropHooks *group_prop_hooks; MetaGroupPropHooks *group_prop_hooks;
/* Managed by compositor.c */
MetaCompositor *compositor;
#ifdef HAVE_STARTUP_NOTIFICATION #ifdef HAVE_STARTUP_NOTIFICATION
SnDisplay *sn_display; SnDisplay *sn_display;

View File

@ -34,6 +34,7 @@
#include "keybindings.h" #include "keybindings.h"
#include "stack.h" #include "stack.h"
#include "xprops.h" #include "xprops.h"
#include "compositor.h"
#ifdef HAVE_SOLARIS_XINERAMA #ifdef HAVE_SOLARIS_XINERAMA
#include <X11/extensions/xinerama.h> #include <X11/extensions/xinerama.h>
@ -654,9 +655,12 @@ meta_screen_new (MetaDisplay *display,
if (space != NULL) if (space != NULL)
meta_workspace_activate (space); meta_workspace_activate (space);
} }
meta_compositor_manage_screen (screen->display->compositor,
screen);
meta_verbose ("Added screen %d ('%s') root 0x%lx\n", meta_verbose ("Added screen %d ('%s') root 0x%lx\n",
screen->number, screen->screen_name, screen->xroot); screen->number, screen->screen_name, screen->xroot);
return screen; return screen;
} }
@ -672,6 +676,9 @@ meta_screen_free (MetaScreen *screen)
meta_display_grab (display); meta_display_grab (display);
meta_compositor_unmanage_screen (screen->display->compositor,
screen);
meta_display_unmanage_windows_for_screen (display, screen); meta_display_unmanage_windows_for_screen (display, screen);
meta_prefs_remove_listener (prefs_changed_callback, screen); meta_prefs_remove_listener (prefs_changed_callback, screen);
@ -749,7 +756,27 @@ 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], TRUE); XWindowAttributes attrs;
meta_error_trap_push_with_return (screen->display);
XGetWindowAttributes (screen->display->xdisplay,
children[i], &attrs);
if (meta_error_trap_pop_with_return (screen->display, TRUE) != Success)
{
meta_verbose ("Failed to get attributes for window 0x%lx\n",
children[i]);
}
else
{
meta_window_new_with_attrs (screen->display, children[i], TRUE,
&attrs);
if (attrs.map_state == IsViewable)
meta_compositor_add_window (screen->display->compositor,
children[i], &attrs);
}
++i; ++i;
} }

View File

@ -172,8 +172,44 @@ meta_window_new (MetaDisplay *display,
Window xwindow, Window xwindow,
gboolean must_be_viewable) gboolean must_be_viewable)
{ {
MetaWindow *window;
XWindowAttributes attrs; XWindowAttributes attrs;
MetaWindow *window;
meta_display_grab (display);
meta_error_trap_push (display); /* Push a trap over all of window
* creation, to reduce XSync() calls
*/
meta_error_trap_push_with_return (display);
XGetWindowAttributes (display->xdisplay,
xwindow, &attrs);
if (meta_error_trap_pop_with_return (display, TRUE) != Success)
{
meta_verbose ("Failed to get attributes for window 0x%lx\n",
xwindow);
meta_error_trap_pop (display, TRUE);
meta_display_ungrab (display);
return NULL;
}
window = meta_window_new_with_attrs (display, xwindow,
must_be_viewable, &attrs);
meta_error_trap_pop (display, FALSE);
meta_display_ungrab (display);
return window;
}
MetaWindow*
meta_window_new_with_attrs (MetaDisplay *display,
Window xwindow,
gboolean must_be_viewable,
XWindowAttributes *attrs)
{
MetaWindow *window;
GSList *tmp; GSList *tmp;
MetaWorkspace *space; MetaWorkspace *space;
gulong existing_wm_state; gulong existing_wm_state;
@ -182,7 +218,8 @@ meta_window_new (MetaDisplay *display,
Atom initial_props[N_INITIAL_PROPS]; Atom initial_props[N_INITIAL_PROPS];
int i; int i;
gboolean has_shape; gboolean has_shape;
g_assert (attrs != NULL);
g_assert (N_INITIAL_PROPS == (int) G_N_ELEMENTS (initial_props)); g_assert (N_INITIAL_PROPS == (int) G_N_ELEMENTS (initial_props));
meta_verbose ("Attempting to manage 0x%lx\n", xwindow); meta_verbose ("Attempting to manage 0x%lx\n", xwindow);
@ -193,48 +230,32 @@ meta_window_new (MetaDisplay *display,
xwindow); xwindow);
return NULL; return NULL;
} }
if (attrs->override_redirect)
{
meta_verbose ("Deciding not to manage override_redirect window 0x%lx\n", xwindow);
return NULL;
}
/* Grab server */ /* Grab server */
meta_display_grab (display); meta_display_grab (display);
meta_error_trap_push (display); /* Push a trap over all of window meta_error_trap_push (display); /* Push a trap over all of window
* creation, to reduce XSync() calls * creation, to reduce XSync() calls
*/ */
meta_error_trap_push_with_return (display);
XGetWindowAttributes (display->xdisplay,
xwindow, &attrs);
if (meta_error_trap_pop_with_return (display, TRUE) != Success) meta_verbose ("must_be_viewable = %d attrs->map_state = %d (%s)\n",
{
meta_verbose ("Failed to get attributes for window 0x%lx\n",
xwindow);
meta_error_trap_pop (display, TRUE);
meta_display_ungrab (display);
return NULL;
}
if (attrs.override_redirect)
{
meta_verbose ("Deciding not to manage override_redirect window 0x%lx\n", xwindow);
meta_error_trap_pop (display, TRUE);
meta_display_ungrab (display);
return NULL;
}
meta_verbose ("must_be_viewable = %d attrs.map_state = %d (%s)\n",
must_be_viewable, must_be_viewable,
attrs.map_state, attrs->map_state,
(attrs.map_state == IsUnmapped) ? (attrs->map_state == IsUnmapped) ?
"IsUnmapped" : "IsUnmapped" :
(attrs.map_state == IsViewable) ? (attrs->map_state == IsViewable) ?
"IsViewable" : "IsViewable" :
(attrs.map_state == IsUnviewable) ? (attrs->map_state == IsUnviewable) ?
"IsUnviewable" : "IsUnviewable" :
"(unknown)"); "(unknown)");
existing_wm_state = WithdrawnState; existing_wm_state = WithdrawnState;
if (must_be_viewable && attrs.map_state != IsViewable) if (must_be_viewable && attrs->map_state != IsViewable)
{ {
/* Only manage if WM_STATE is IconicState or NormalState */ /* Only manage if WM_STATE is IconicState or NormalState */
gulong state; gulong state;
@ -293,11 +314,11 @@ meta_window_new (MetaDisplay *display,
#endif #endif
/* Get rid of any borders */ /* Get rid of any borders */
if (attrs.border_width != 0) if (attrs->border_width != 0)
XSetWindowBorderWidth (display->xdisplay, xwindow, 0); XSetWindowBorderWidth (display->xdisplay, xwindow, 0);
/* Get rid of weird gravities */ /* Get rid of weird gravities */
if (attrs.win_gravity != NorthWestGravity) if (attrs->win_gravity != NorthWestGravity)
{ {
XSetWindowAttributes set_attrs; XSetWindowAttributes set_attrs;
@ -318,7 +339,7 @@ meta_window_new (MetaDisplay *display,
return NULL; return NULL;
} }
g_assert (!attrs.override_redirect); g_assert (!attrs->override_redirect);
window = g_new (MetaWindow, 1); window = g_new (MetaWindow, 1);
@ -343,7 +364,7 @@ meta_window_new (MetaDisplay *display,
{ {
MetaScreen *scr = tmp->data; MetaScreen *scr = tmp->data;
if (scr->xroot == attrs.root) if (scr->xroot == attrs->root)
{ {
window->screen = tmp->data; window->screen = tmp->data;
break; break;
@ -367,17 +388,17 @@ meta_window_new (MetaDisplay *display,
window->has_shape = has_shape; window->has_shape = has_shape;
/* Remember this rect is the actual window size */ /* Remember this rect is the actual window size */
window->rect.x = attrs.x; window->rect.x = attrs->x;
window->rect.y = attrs.y; window->rect.y = attrs->y;
window->rect.width = attrs.width; window->rect.width = attrs->width;
window->rect.height = attrs.height; window->rect.height = attrs->height;
/* And border width, size_hints are the "request" */ /* And border width, size_hints are the "request" */
window->border_width = attrs.border_width; window->border_width = attrs->border_width;
window->size_hints.x = attrs.x; window->size_hints.x = attrs->x;
window->size_hints.y = attrs.y; window->size_hints.y = attrs->y;
window->size_hints.width = attrs.width; window->size_hints.width = attrs->width;
window->size_hints.height = attrs.height; window->size_hints.height = attrs->height;
/* initialize the remaining size_hints as if size_hints.flags were zero */ /* initialize the remaining size_hints as if size_hints.flags were zero */
meta_set_normal_hints (window, NULL); meta_set_normal_hints (window, NULL);
@ -385,9 +406,9 @@ meta_window_new (MetaDisplay *display,
window->saved_rect = window->rect; window->saved_rect = window->rect;
window->user_rect = window->rect; window->user_rect = window->rect;
window->depth = attrs.depth; window->depth = attrs->depth;
window->xvisual = attrs.visual; window->xvisual = attrs->visual;
window->colormap = attrs.colormap; window->colormap = attrs->colormap;
window->title = NULL; window->title = NULL;
window->icon_name = NULL; window->icon_name = NULL;
@ -410,7 +431,7 @@ meta_window_new (MetaDisplay *display,
window->initially_iconic = FALSE; window->initially_iconic = FALSE;
window->minimized = FALSE; window->minimized = FALSE;
window->iconic = FALSE; window->iconic = FALSE;
window->mapped = attrs.map_state != IsUnmapped; window->mapped = attrs->map_state != IsUnmapped;
/* if already mapped we don't want to do the placement thing */ /* if already mapped we don't want to do the placement thing */
window->placed = window->mapped; window->placed = window->mapped;
if (window->placed) if (window->placed)
@ -688,7 +709,7 @@ meta_window_new (MetaDisplay *display,
return window; return window;
} }
/* This function should only be called from the end of meta_window_new () */ /* This function should only be called from the end of meta_window_new_with_attrs () */
static void static void
meta_window_apply_session_info (MetaWindow *window, meta_window_apply_session_info (MetaWindow *window,
const MetaWindowSessionInfo *info) const MetaWindowSessionInfo *info)

View File

@ -311,6 +311,10 @@ struct _MetaWindow
MetaWindow* meta_window_new (MetaDisplay *display, MetaWindow* meta_window_new (MetaDisplay *display,
Window xwindow, Window xwindow,
gboolean must_be_viewable); gboolean must_be_viewable);
MetaWindow* meta_window_new_with_attrs (MetaDisplay *display,
Window xwindow,
gboolean must_be_viewable,
XWindowAttributes *attrs);
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);