New files
Tue May 2 17:12:54 2006 Søren Sandmann <sandmann@redhat.com> * src/c-window.[ch]: New files * src/c-screen.c: Move WindowInfo struct to new c-window.[ch] files. Delete various bits of obsolete, commented-out code.
This commit is contained in:
parent
451c990dd5
commit
411fd3db44
@ -1,3 +1,10 @@
|
|||||||
|
Tue May 2 17:12:54 2006 Søren Sandmann <sandmann@redhat.com>
|
||||||
|
|
||||||
|
* src/c-window.[ch]: New files
|
||||||
|
|
||||||
|
* src/c-screen.c: Move WindowInfo struct to new c-window.[ch]
|
||||||
|
files. Delete various bits of obsolete, commented-out code.
|
||||||
|
|
||||||
Fri Apr 28 12:53:23 2006 Søren Sandmann <sandmann@redhat.com>
|
Fri Apr 28 12:53:23 2006 Søren Sandmann <sandmann@redhat.com>
|
||||||
|
|
||||||
* src/core.c (get_window): New function.
|
* src/core.c (get_window): New function.
|
||||||
|
@ -18,6 +18,8 @@ metacity_SOURCES= \
|
|||||||
common.h \
|
common.h \
|
||||||
c-screen.c \
|
c-screen.c \
|
||||||
c-screen.h \
|
c-screen.h \
|
||||||
|
c-window.c \
|
||||||
|
c-window.h \
|
||||||
compositor.c \
|
compositor.c \
|
||||||
compositor.h \
|
compositor.h \
|
||||||
constraints.c \
|
constraints.c \
|
||||||
|
677
src/c-screen.c
677
src/c-screen.c
File diff suppressed because it is too large
Load Diff
@ -47,3 +47,5 @@ void meta_screen_info_set_explode (MetaScreenInfo *info,
|
|||||||
gdouble level);
|
gdouble level);
|
||||||
void meta_screen_info_hide_window (MetaScreenInfo *info,
|
void meta_screen_info_hide_window (MetaScreenInfo *info,
|
||||||
Window xwindow);
|
Window xwindow);
|
||||||
|
void meta_screen_info_unmap (MetaScreenInfo *info,
|
||||||
|
Window xwindow);
|
||||||
|
231
src/c-window.c
Normal file
231
src/c-window.c
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
* 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include <cm/ws.h>
|
||||||
|
#include <cm/wsint.h>
|
||||||
|
#include <cm/node.h>
|
||||||
|
#include <cm/drawable-node.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "c-window.h"
|
||||||
|
|
||||||
|
static GHashTable *windows_by_xid;
|
||||||
|
|
||||||
|
struct _MetaCompWindow
|
||||||
|
{
|
||||||
|
WsDrawable *drawable;
|
||||||
|
CmNode *node;
|
||||||
|
gboolean updates;
|
||||||
|
|
||||||
|
WsRectangle size;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
ensure_hash_table (void)
|
||||||
|
{
|
||||||
|
if (!windows_by_xid)
|
||||||
|
{
|
||||||
|
windows_by_xid = g_hash_table_new (
|
||||||
|
g_direct_hash, g_direct_equal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MetaCompWindow *
|
||||||
|
meta_comp_window_new (WsDrawable *drawable)
|
||||||
|
{
|
||||||
|
MetaCompWindow *window;
|
||||||
|
WsRectangle geometry;
|
||||||
|
|
||||||
|
ws_drawable_query_geometry (drawable, &geometry);
|
||||||
|
|
||||||
|
window = g_new0 (MetaCompWindow, 1);
|
||||||
|
|
||||||
|
window->drawable = g_object_ref (drawable);
|
||||||
|
window->node = CM_NODE (cm_drawable_node_new (drawable, &geometry));
|
||||||
|
window->updates = TRUE;
|
||||||
|
|
||||||
|
ensure_hash_table ();
|
||||||
|
|
||||||
|
g_hash_table_insert (windows_by_xid, (gpointer)WS_RESOURCE_XID (window->drawable), window);
|
||||||
|
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
|
MetaCompWindow *
|
||||||
|
meta_comp_window_lookup (Window xid)
|
||||||
|
{
|
||||||
|
MetaCompWindow *window;
|
||||||
|
|
||||||
|
ensure_hash_table ();
|
||||||
|
|
||||||
|
window = g_hash_table_lookup (windows_by_xid, (gpointer)xid);
|
||||||
|
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_comp_window_free (MetaCompWindow *window)
|
||||||
|
{
|
||||||
|
ensure_hash_table ();
|
||||||
|
|
||||||
|
g_hash_table_remove (windows_by_xid, WS_RESOURCE_XID (window->drawable));
|
||||||
|
g_object_unref (window->drawable);
|
||||||
|
g_object_unref (window->node);
|
||||||
|
g_free (window);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_comp_window_set_size (MetaCompWindow *comp_window,
|
||||||
|
WsRectangle *rect)
|
||||||
|
{
|
||||||
|
if (comp_window->updates)
|
||||||
|
{
|
||||||
|
WsWindow *window = WS_WINDOW (comp_window->drawable);
|
||||||
|
WsDisplay *display = WS_RESOURCE (window)->display;
|
||||||
|
CmDrawableNode *dnode = CM_DRAWABLE_NODE (comp_window->node);
|
||||||
|
WsRegion *shape;
|
||||||
|
|
||||||
|
ws_display_begin_error_trap (display);
|
||||||
|
|
||||||
|
cm_drawable_node_set_geometry (dnode, rect);
|
||||||
|
shape = ws_window_get_output_shape (window);
|
||||||
|
cm_drawable_node_set_shape (dnode, shape);
|
||||||
|
ws_region_destroy (shape);
|
||||||
|
|
||||||
|
if (rect->width != comp_window->size.width ||
|
||||||
|
rect->height != comp_window->size.height)
|
||||||
|
{
|
||||||
|
cm_drawable_node_update_pixmap (dnode);
|
||||||
|
}
|
||||||
|
|
||||||
|
comp_window->size = *rect;
|
||||||
|
|
||||||
|
ws_display_end_error_trap (display);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
has_type (WsWindow *window, const char *check_type)
|
||||||
|
{
|
||||||
|
gchar **types = ws_window_get_property_atom_list (window, "_NET_WM_WINDOW_TYPE");
|
||||||
|
int i;
|
||||||
|
gboolean result;
|
||||||
|
|
||||||
|
if (!types)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
result = FALSE;
|
||||||
|
|
||||||
|
for (i = 0; types[i] != NULL; ++i)
|
||||||
|
{
|
||||||
|
gchar *type = types[i];
|
||||||
|
|
||||||
|
g_print ("type: %s\n", type);
|
||||||
|
|
||||||
|
if (strcmp (type, check_type) == 0)
|
||||||
|
{
|
||||||
|
result = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_strfreev (types);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_comp_window_refresh_attrs (MetaCompWindow *comp_window)
|
||||||
|
{
|
||||||
|
/* FIXME: this function should not exist - the real problem is
|
||||||
|
* probably in meta_screen_info_add_window() where it it called.
|
||||||
|
*/
|
||||||
|
|
||||||
|
double alpha = 1.0;
|
||||||
|
CmDrawableNode *node = CM_DRAWABLE_NODE (comp_window->node);
|
||||||
|
|
||||||
|
if (ws_window_query_mapped (WS_WINDOW (comp_window->drawable)))
|
||||||
|
{
|
||||||
|
WsWindow *window = WS_WINDOW (comp_window->drawable);
|
||||||
|
|
||||||
|
cm_drawable_node_unset_patch (CM_DRAWABLE_NODE (node));
|
||||||
|
|
||||||
|
if (has_type (window, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"))
|
||||||
|
{
|
||||||
|
alpha = 0.3;
|
||||||
|
}
|
||||||
|
else if (has_type (window, "_NET_WM_WINDOW_TYPE_POPUP_MENU"))
|
||||||
|
{
|
||||||
|
alpha = 0.9;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alpha = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cm_drawable_node_set_alpha (node, alpha);
|
||||||
|
cm_drawable_node_set_viewable (node, TRUE);
|
||||||
|
cm_drawable_node_update_pixmap (node);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cm_drawable_node_set_viewable (node, FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_comp_window_set_updates (MetaCompWindow *comp_window,
|
||||||
|
gboolean updates)
|
||||||
|
{
|
||||||
|
CmDrawableNode *node = CM_DRAWABLE_NODE (comp_window->node);
|
||||||
|
|
||||||
|
comp_window->updates = updates;
|
||||||
|
|
||||||
|
cm_drawable_node_set_updates (node, updates);
|
||||||
|
|
||||||
|
if (updates)
|
||||||
|
{
|
||||||
|
WsRectangle rect;
|
||||||
|
WsRegion *shape;
|
||||||
|
WsDisplay *display = WS_RESOURCE (node->drawable)->display;
|
||||||
|
|
||||||
|
ws_display_begin_error_trap (display);
|
||||||
|
ws_drawable_query_geometry (node->drawable, &rect);
|
||||||
|
cm_drawable_node_update_pixmap (node);
|
||||||
|
cm_drawable_node_set_geometry (node, &rect);
|
||||||
|
shape = ws_window_get_output_shape (WS_WINDOW (node->drawable));
|
||||||
|
cm_drawable_node_set_shape (node, shape);
|
||||||
|
ws_region_destroy (shape);
|
||||||
|
ws_display_end_error_trap (display);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CmNode *
|
||||||
|
meta_comp_window_get_node (MetaCompWindow *comp_window)
|
||||||
|
{
|
||||||
|
return comp_window->node;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
33
src/c-window.h
Normal file
33
src/c-window.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
* 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <cm/node.h>
|
||||||
|
|
||||||
|
typedef struct _MetaCompWindow MetaCompWindow;
|
||||||
|
|
||||||
|
MetaCompWindow *meta_comp_window_new (WsDrawable *drawable);
|
||||||
|
CmNode *meta_comp_window_get_node (MetaCompWindow *window);
|
||||||
|
MetaCompWindow *meta_comp_window_lookup (Window xwindow);
|
||||||
|
void meta_comp_window_free (MetaCompWindow *window);
|
||||||
|
void meta_comp_window_set_size (MetaCompWindow *window,
|
||||||
|
WsRectangle *size);
|
||||||
|
|
||||||
|
void meta_comp_window_refresh_attrs (MetaCompWindow *comp_window);
|
||||||
|
void meta_comp_window_set_updates (MetaCompWindow *comp_window,
|
||||||
|
gboolean updates);
|
162
src/compositor.c
162
src/compositor.c
@ -90,7 +90,7 @@ handle_error (Display *dpy, XErrorEvent *ev, gpointer data)
|
|||||||
{
|
{
|
||||||
WsDisplay *display = data;
|
WsDisplay *display = data;
|
||||||
|
|
||||||
ws_display_process_error (display, ev);
|
ws_display_process_xerror (display, ev);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -181,25 +181,6 @@ meta_compositor_unref (MetaCompositor *compositor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
||||||
static void
|
|
||||||
draw_windows (MetaScreen *screen,
|
|
||||||
GList *list)
|
|
||||||
{
|
|
||||||
CmNode *node;
|
|
||||||
|
|
||||||
if (!list)
|
|
||||||
return;
|
|
||||||
|
|
||||||
node = list->data;
|
|
||||||
|
|
||||||
draw_windows (screen, list->next);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
g_print ("rendering: %p\n", node);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cm_node_render (node, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
process_configure_notify (MetaCompositor *compositor,
|
process_configure_notify (MetaCompositor *compositor,
|
||||||
@ -510,149 +491,8 @@ meta_compositor_process_event (MetaCompositor *compositor,
|
|||||||
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
||||||
static void
|
|
||||||
wavy (double time,
|
|
||||||
double in_x, double in_y,
|
|
||||||
double *out_x, double *out_y,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
static int m;
|
|
||||||
time = time * 5;
|
|
||||||
double dx = 0.0025 * sin (time + 35 * in_y);
|
|
||||||
double dy = 0.0025 * cos (time + 35 * in_x);
|
|
||||||
|
|
||||||
*out_x = in_x + dx;
|
|
||||||
*out_y = in_y + dy;
|
|
||||||
|
|
||||||
m++;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GTimer *timer;
|
static GTimer *timer;
|
||||||
|
|
||||||
#if 0
|
|
||||||
static gboolean
|
|
||||||
update (gpointer data)
|
|
||||||
{
|
|
||||||
MetaScreen *screen = data;
|
|
||||||
ScreenInfo *scr_info = screen->compositor_data;
|
|
||||||
WsWindow *gl_window = scr_info->glw;
|
|
||||||
gdouble angle;
|
|
||||||
|
|
||||||
glViewport (0, 0, screen->rect.width, screen->rect.height);
|
|
||||||
|
|
||||||
if (!timer)
|
|
||||||
timer = g_timer_new ();
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
g_print ("rotation: %f\n", 360 * g_timer_elapsed (timer, NULL));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
angle = g_timer_elapsed (timer, NULL) * 90;
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
angle = 180.0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cm_rotation_set_rotation (screen->display->compositor->rotation,
|
|
||||||
angle,
|
|
||||||
0.0, 1.0, 0.0);
|
|
||||||
|
|
||||||
glClearColor (0.0, 0.0, 0.0, 0.0);
|
|
||||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
glDisable (GL_TEXTURE_2D);
|
|
||||||
glDisable (GL_DEPTH_TEST);
|
|
||||||
ws_window_raise (gl_window);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
glMatrixMode (GL_MODELVIEW);
|
|
||||||
|
|
||||||
glLoadIdentity();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
glTranslatef (-1.0, -1.0, 0.0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
glMatrixMode (GL_PROJECTION);
|
|
||||||
glLoadIdentity();
|
|
||||||
gluPerspective( 45.0f, 1.0, 0.1f, 10.0f );
|
|
||||||
|
|
||||||
glMatrixMode (GL_MODELVIEW);
|
|
||||||
glLoadIdentity();
|
|
||||||
glTranslatef (0, 0, -3);
|
|
||||||
|
|
||||||
glEnable (GL_DEPTH_TEST);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
draw_windows (screen, scr_info->compositor_nodes);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* FIXME: we should probably grab the server around the raise/swap
|
|
||||||
*/
|
|
||||||
|
|
||||||
CmState *state = cm_state_new ();
|
|
||||||
|
|
||||||
cm_state_disable_depth_buffer_update (state);
|
|
||||||
|
|
||||||
cm_node_render (CM_NODE (screen->display->compositor->stacker), state);
|
|
||||||
|
|
||||||
cm_state_enable_depth_buffer_update (state);
|
|
||||||
|
|
||||||
g_object_unref (state);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
ws_display_grab (ws_drawable_get_display ((WsDrawable *)gl_window));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ws_window_gl_swap_buffers (gl_window);
|
|
||||||
glFinish();
|
|
||||||
|
|
||||||
update_frame_counter ();
|
|
||||||
|
|
||||||
scr_info->idle_id = 0;
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static void
|
|
||||||
queue_repaint (CmDrawableNode *node, gpointer data)
|
|
||||||
{
|
|
||||||
MetaScreen *screen = data;
|
|
||||||
ScreenInfo *scr_info = screen->compositor_data;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
g_print ("metacity queueing repaint for %p\n", node);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!scr_info)
|
|
||||||
{
|
|
||||||
/* compositor has been turned off */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!scr_info->idle_id)
|
|
||||||
{
|
|
||||||
scr_info->idle_id = g_idle_add (update, screen);
|
|
||||||
#if 0
|
|
||||||
g_print ("done\n");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
g_print ("one was queued already\n");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
||||||
static void
|
static void
|
||||||
dump_stacking_order (GList *nodes)
|
dump_stacking_order (GList *nodes)
|
||||||
|
Loading…
Reference in New Issue
Block a user