Commit 1bb6f48b authored by Benjamin Otte's avatar Benjamin Otte
Browse files

gdk: Rename GdkWindowObject to GdkWindow

... and remove most of the casting that used to be necessary.
parent 7acb64f9
......@@ -1067,7 +1067,7 @@ gdk_device_grab (GdkDevice *device,
else
native = gdk_window_get_toplevel (window);
while (((GdkWindowObject *) native)->window_type == GDK_WINDOW_OFFSCREEN)
while (native->window_type == GDK_WINDOW_OFFSCREEN)
{
native = gdk_offscreen_window_get_embedder (native);
......@@ -1231,7 +1231,6 @@ _gdk_device_translate_window_coord (GdkDevice *device,
gdouble x_resolution, y_resolution;
gdouble device_aspect;
gint window_width, window_height;
GdkWindowObject *window_private;
priv = device->priv;
......@@ -1274,7 +1273,6 @@ _gdk_device_translate_window_coord (GdkDevice *device,
y_min = 0;
}
window_private = (GdkWindowObject *) window;
window_width = gdk_window_get_width (window);
window_height = gdk_window_get_height (window);
......@@ -1342,7 +1340,6 @@ _gdk_device_translate_screen_coord (GdkDevice *device,
GdkDevicePrivate *priv = device->priv;
GdkAxisInfo axis_info;
gdouble axis_width, scale, offset;
GdkWindowObject *window_private;
if (priv->mode != GDK_MODE_SCREEN)
return FALSE;
......@@ -1357,7 +1354,6 @@ _gdk_device_translate_screen_coord (GdkDevice *device,
return FALSE;
axis_width = axis_info.max_value - axis_info.min_value;
window_private = (GdkWindowObject *) window;
if (axis_info.use == GDK_AXIS_X)
{
......@@ -1366,7 +1362,7 @@ _gdk_device_translate_screen_coord (GdkDevice *device,
else
scale = 1;
offset = - window_root_x - window_private->abs_x;
offset = - window_root_x - window->abs_x;
}
else
{
......@@ -1375,7 +1371,7 @@ _gdk_device_translate_screen_coord (GdkDevice *device,
else
scale = 1;
offset = - window_root_y - window_private->abs_y;
offset = - window_root_y - window->abs_y;
}
if (axis_value)
......
......@@ -933,20 +933,17 @@ gdk_window_real_window_get_device_position (GdkDisplay *display,
gint *y,
GdkModifierType *mask)
{
GdkWindowObject *private;
gint tmpx, tmpy;
GdkModifierType tmp_mask;
gboolean normal_child;
private = (GdkWindowObject *) window;
normal_child = GDK_WINDOW_IMPL_GET_CLASS (private->impl)->get_device_state (window,
normal_child = GDK_WINDOW_IMPL_GET_CLASS (window->impl)->get_device_state (window,
device,
&tmpx, &tmpy,
&tmp_mask);
/* We got the coords on the impl, convert to the window */
tmpx -= private->abs_x;
tmpy -= private->abs_y;
tmpx -= window->abs_x;
tmpy -= window->abs_y;
if (x)
*x = tmpx;
......
......@@ -1435,7 +1435,7 @@ gdk_synthesize_window_state (GdkWindow *window,
temp_event.window_state.type = GDK_WINDOW_STATE;
temp_event.window_state.send_event = FALSE;
old = ((GdkWindowObject*) temp_event.window_state.window)->state;
old = temp_event.window_state.window->state;
temp_event.window_state.new_window_state = old;
temp_event.window_state.new_window_state |= set_flags;
......@@ -1450,7 +1450,7 @@ gdk_synthesize_window_state (GdkWindow *window,
* inconsistent state to the user.
*/
((GdkWindowObject*) window)->state = temp_event.window_state.new_window_state;
window->state = temp_event.window_state.new_window_state;
if (temp_event.window_state.changed_mask & GDK_WINDOW_STATE_WITHDRAWN)
_gdk_window_update_viewable (window);
......@@ -1460,7 +1460,7 @@ gdk_synthesize_window_state (GdkWindow *window,
* Non-toplevels do use the GDK_WINDOW_STATE_WITHDRAWN flag
* internally so we needed to update window->state.
*/
switch (((GdkWindowObject*) window)->window_type)
switch (window->window_type)
{
case GDK_WINDOW_TOPLEVEL:
case GDK_WINDOW_TEMP: /* ? */
......
......@@ -175,25 +175,20 @@ typedef struct
} GdkDeviceGrabInfo;
typedef struct _GdkInputWindow GdkInputWindow;
typedef struct _GdkWindowPaint GdkWindowPaint;
typedef void (* GdkDisplayPointerInfoForeach) (GdkDisplay *display,
GdkDevice *device,
GdkPointerWindowInfo *device_info,
gpointer user_data);
/* Private version of GdkWindowObject. The initial part of this strucuture
is public for historical reasons. Don't change that part */
typedef struct _GdkWindowPaint GdkWindowPaint;
#define GDK_WINDOW_OBJECT(object) ((GdkWindowObject *) GDK_WINDOW (object))
struct _GdkWindowObject
struct _GdkWindow
{
GdkDrawable parent_instance;
GdkDrawable *impl; /* window-system-specific delegate object */
GdkWindowObject *parent;
GdkWindow *parent;
GdkVisual *visual;
gpointer user_data;
......@@ -235,10 +230,10 @@ struct _GdkWindowObject
guint update_and_descendants_freeze_count;
/* The GdkWindowObject that has the impl, ref:ed if another window.
/* The GdkWindow that has the impl, ref:ed if another window.
* This ref is required to keep the wrapper of the impl window alive
* for as long as any GdkWindow references the impl. */
GdkWindowObject *impl_window;
GdkWindow *impl_window;
int abs_x, abs_y; /* Absolute offset in impl */
gint width, height;
guint32 clip_tag;
......@@ -269,8 +264,8 @@ struct _GdkWindowObject
GHashTable *device_events;
};
#define GDK_WINDOW_TYPE(d) (((GdkWindowObject*)(GDK_WINDOW (d)))->window_type)
#define GDK_WINDOW_DESTROYED(d) (((GdkWindowObject*)(GDK_WINDOW (d)))->destroyed)
#define GDK_WINDOW_TYPE(d) (((GDK_WINDOW (d)))->window_type)
#define GDK_WINDOW_DESTROYED(d) (GDK_WINDOW (d)->destroyed)
extern GdkEventFunc _gdk_event_func; /* Callback for events */
extern gpointer _gdk_event_data;
......@@ -406,7 +401,7 @@ gint _gdk_windowing_get_bits_for_depth (GdkDisplay *display,
gint depth);
#define GDK_WINDOW_IS_MAPPED(window) ((((GdkWindowObject*)window)->state & GDK_WINDOW_STATE_WITHDRAWN) == 0)
#define GDK_WINDOW_IS_MAPPED(window) (((window)->state & GDK_WINDOW_STATE_WITHDRAWN) == 0)
/* Called when gdk_window_destroy() is called on a foreign window
......
......@@ -90,10 +90,9 @@ gdk_offscreen_window_destroy (GdkWindow *window,
gboolean recursing,
gboolean foreign_destroy)
{
GdkWindowObject *private = GDK_WINDOW_OBJECT (window);
GdkOffscreenWindow *offscreen;
offscreen = GDK_OFFSCREEN_WINDOW (private->impl);
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
gdk_offscreen_window_set_embedder (window, NULL);
......@@ -106,11 +105,11 @@ get_surface (GdkOffscreenWindow *offscreen)
{
if (! offscreen->surface)
{
GdkWindowObject *private = (GdkWindowObject *) offscreen->wrapper;
GdkWindow *window = offscreen->wrapper;
g_signal_emit_by_name (private, "create-surface",
private->width,
private->height,
g_signal_emit_by_name (window, "create-surface",
window->width,
window->height,
&offscreen->surface);
}
......@@ -148,14 +147,13 @@ _gdk_offscreen_window_create_surface (GdkWindow *offscreen,
gint width,
gint height)
{
GdkWindowObject *private = (GdkWindowObject *) offscreen;
cairo_surface_t *similar;
cairo_surface_t *surface;
cairo_content_t content = CAIRO_CONTENT_COLOR;
g_return_val_if_fail (GDK_IS_OFFSCREEN_WINDOW (private->impl), NULL);
g_return_val_if_fail (GDK_IS_OFFSCREEN_WINDOW (offscreen->impl), NULL);
similar = _gdk_window_ref_cairo_surface ((GdkWindow *)private->parent);
similar = _gdk_window_ref_cairo_surface (offscreen->parent);
if (gdk_window_get_visual (offscreen) ==
gdk_screen_get_rgba_visual (gdk_window_get_screen (offscreen)))
......@@ -175,7 +173,6 @@ _gdk_offscreen_window_new (GdkWindow *window,
GdkWindowAttr *attributes,
gint attributes_mask)
{
GdkWindowObject *private;
GdkOffscreenWindow *offscreen;
g_return_if_fail (attributes != NULL);
......@@ -183,13 +180,11 @@ _gdk_offscreen_window_new (GdkWindow *window,
if (attributes->wclass != GDK_INPUT_OUTPUT)
return; /* Can't support input only offscreens */
private = (GdkWindowObject *)window;
if (private->parent != NULL && GDK_WINDOW_DESTROYED (private->parent))
if (window->parent != NULL && GDK_WINDOW_DESTROYED (window->parent))
return;
private->impl = g_object_new (GDK_TYPE_OFFSCREEN_WINDOW, NULL);
offscreen = GDK_OFFSCREEN_WINDOW (private->impl);
window->impl = g_object_new (GDK_TYPE_OFFSCREEN_WINDOW, NULL);
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
offscreen->wrapper = window;
}
......@@ -199,15 +194,13 @@ gdk_offscreen_window_reparent (GdkWindow *window,
gint x,
gint y)
{
GdkWindowObject *private = (GdkWindowObject *)window;
GdkWindowObject *new_parent_private = (GdkWindowObject *)new_parent;
GdkWindowObject *old_parent;
GdkWindow *old_parent;
gboolean was_mapped;
if (new_parent)
{
/* No input-output children of input-only windows */
if (new_parent_private->input_only && !private->input_only)
if (new_parent->input_only && !window->input_only)
return FALSE;
/* Don't create loops in hierarchy */
......@@ -219,20 +212,20 @@ gdk_offscreen_window_reparent (GdkWindow *window,
gdk_window_hide (window);
if (private->parent)
private->parent->children = g_list_remove (private->parent->children, window);
if (window->parent)
window->parent->children = g_list_remove (window->parent->children, window);
old_parent = private->parent;
private->parent = new_parent_private;
private->x = x;
private->y = y;
old_parent = window->parent;
window->parent = new_parent;
window->x = x;
window->y = y;
if (new_parent_private)
private->parent->children = g_list_prepend (private->parent->children, window);
if (new_parent)
window->parent->children = g_list_prepend (window->parent->children, window);
_gdk_synthesize_crossing_events_for_geometry_change (window);
if (old_parent)
_gdk_synthesize_crossing_events_for_geometry_change (GDK_WINDOW (old_parent));
_gdk_synthesize_crossing_events_for_geometry_change (old_parent);
return was_mapped;
}
......@@ -242,11 +235,7 @@ from_embedder (GdkWindow *window,
double embedder_x, double embedder_y,
double *offscreen_x, double *offscreen_y)
{
GdkWindowObject *private;
private = (GdkWindowObject *)window;
g_signal_emit_by_name (private->impl_window,
g_signal_emit_by_name (window->impl_window,
"from-embedder",
embedder_x, embedder_y,
offscreen_x, offscreen_y,
......@@ -258,11 +247,7 @@ to_embedder (GdkWindow *window,
double offscreen_x, double offscreen_y,
double *embedder_x, double *embedder_y)
{
GdkWindowObject *private;
private = (GdkWindowObject *)window;
g_signal_emit_by_name (private->impl_window,
g_signal_emit_by_name (window->impl_window,
"to-embedder",
offscreen_x, offscreen_y,
embedder_x, embedder_y,
......@@ -276,14 +261,13 @@ gdk_offscreen_window_get_root_coords (GdkWindow *window,
gint *root_x,
gint *root_y)
{
GdkWindowObject *private = GDK_WINDOW_OBJECT (window);
GdkOffscreenWindow *offscreen;
int tmpx, tmpy;
tmpx = x;
tmpy = y;
offscreen = GDK_OFFSCREEN_WINDOW (private->impl);
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
if (offscreen->embedder)
{
double dx, dy;
......@@ -313,7 +297,6 @@ gdk_offscreen_window_get_device_state (GdkWindow *window,
gint *y,
GdkModifierType *mask)
{
GdkWindowObject *private = GDK_WINDOW_OBJECT (window);
GdkOffscreenWindow *offscreen;
int tmpx, tmpy;
double dtmpx, dtmpy;
......@@ -323,7 +306,7 @@ gdk_offscreen_window_get_device_state (GdkWindow *window,
tmpy = 0;
tmpmask = 0;
offscreen = GDK_OFFSCREEN_WINDOW (private->impl);
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
if (offscreen->embedder != NULL)
{
gdk_window_get_device_position (offscreen->embedder, device, &tmpx, &tmpy, &tmpmask);
......@@ -356,15 +339,14 @@ gdk_offscreen_window_get_device_state (GdkWindow *window,
cairo_surface_t *
gdk_offscreen_window_get_surface (GdkWindow *window)
{
GdkWindowObject *private = (GdkWindowObject *)window;
GdkOffscreenWindow *offscreen;
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
if (!GDK_IS_OFFSCREEN_WINDOW (private->impl))
if (!GDK_IS_OFFSCREEN_WINDOW (window->impl))
return NULL;
offscreen = GDK_OFFSCREEN_WINDOW (private->impl);
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
return get_surface (offscreen);
}
......@@ -391,33 +373,32 @@ gdk_offscreen_window_move_resize_internal (GdkWindow *window,
gint height,
gboolean send_expose_events)
{
GdkWindowObject *private = (GdkWindowObject *)window;
GdkOffscreenWindow *offscreen;
gint dx, dy, dw, dh;
offscreen = GDK_OFFSCREEN_WINDOW (private->impl);
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
if (width < 1)
width = 1;
if (height < 1)
height = 1;
if (private->destroyed)
if (window->destroyed)
return;
dx = x - private->x;
dy = y - private->y;
dw = width - private->width;
dh = height - private->height;
dx = x - window->x;
dy = y - window->y;
dw = width - window->width;
dh = height - window->height;
private->x = x;
private->y = y;
window->x = x;
window->y = y;
if (private->width != width ||
private->height != height)
if (window->width != width ||
window->height != height)
{
private->width = width;
private->height = height;
window->width = width;
window->height = height;
if (offscreen->surface)
{
......@@ -438,7 +419,7 @@ gdk_offscreen_window_move_resize_internal (GdkWindow *window,
}
}
if (GDK_WINDOW_IS_MAPPED (private))
if (GDK_WINDOW_IS_MAPPED (window))
{
// TODO: Only invalidate new area, i.e. for larger windows
gdk_window_invalidate_rect (window, NULL, TRUE);
......@@ -454,22 +435,21 @@ gdk_offscreen_window_move_resize (GdkWindow *window,
gint width,
gint height)
{
GdkWindowObject *private = (GdkWindowObject *)window;
GdkOffscreenWindow *offscreen;
offscreen = GDK_OFFSCREEN_WINDOW (private->impl);
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
if (!with_move)
{
x = private->x;
y = private->y;
x = window->x;
y = window->y;
}
if (width < 0)
width = private->width;
width = window->width;
if (height < 0)
height = private->height;
height = window->height;
gdk_offscreen_window_move_resize_internal (window, x, y,
width, height,
......@@ -480,8 +460,7 @@ static void
gdk_offscreen_window_show (GdkWindow *window,
gboolean already_mapped)
{
GdkWindowObject *private = (GdkWindowObject *)window;
GdkRectangle area = { 0, 0, private->width, private->height };
GdkRectangle area = { 0, 0, window->width, window->height };
gdk_window_invalidate_rect (window, &area, FALSE);
}
......@@ -490,14 +469,12 @@ gdk_offscreen_window_show (GdkWindow *window,
static void
gdk_offscreen_window_hide (GdkWindow *window)
{
GdkWindowObject *private;
GdkOffscreenWindow *offscreen;
GdkDisplay *display;
g_return_if_fail (window != NULL);
private = (GdkWindowObject*) window;
offscreen = GDK_OFFSCREEN_WINDOW (private->impl);
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
/* May need to break grabs on children */
display = gdk_window_get_display (window);
......@@ -575,22 +552,18 @@ gdk_offscreen_window_get_geometry (GdkWindow *window,
gint *height,
gint *depth)
{
GdkWindowObject *private = (GdkWindowObject *)window;
g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
if (!GDK_WINDOW_DESTROYED (window))
{
if (x)
*x = private->x;
*x = window->x;
if (y)
*y = private->y;
*y = window->y;
if (width)
*width = private->width;
*width = window->width;
if (height)
*height = private->height;
*height = window->height;
if (depth)
*depth = private->depth;
*depth = window->depth;
}
}
......@@ -607,7 +580,7 @@ gdk_offscreen_window_translate (GdkWindow *window,
gint dx,
gint dy)
{
GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (((GdkWindowObject *) window)->impl);
GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
if (offscreen->surface)
{
......@@ -667,26 +640,25 @@ void
gdk_offscreen_window_set_embedder (GdkWindow *window,
GdkWindow *embedder)
{
GdkWindowObject *private = (GdkWindowObject *)window;
GdkOffscreenWindow *offscreen;
g_return_if_fail (GDK_IS_WINDOW (window));
if (!GDK_IS_OFFSCREEN_WINDOW (private->impl))
if (!GDK_IS_OFFSCREEN_WINDOW (window->impl))
return;
offscreen = GDK_OFFSCREEN_WINDOW (private->impl);
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
if (embedder)
{
g_object_ref (embedder);
GDK_WINDOW_OBJECT (embedder)->num_offscreen_children++;
embedder->num_offscreen_children++;
}
if (offscreen->embedder)
{
g_object_unref (offscreen->embedder);
GDK_WINDOW_OBJECT (offscreen->embedder)->num_offscreen_children--;
offscreen->embedder->num_offscreen_children--;
}
offscreen->embedder = embedder;
......@@ -706,15 +678,14 @@ gdk_offscreen_window_set_embedder (GdkWindow *window,
GdkWindow *
gdk_offscreen_window_get_embedder (GdkWindow *window)
{
GdkWindowObject *private = (GdkWindowObject *)window;
GdkOffscreenWindow *offscreen;
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
if (!GDK_IS_OFFSCREEN_WINDOW (private->impl))
if (!GDK_IS_OFFSCREEN_WINDOW (window->impl))
return NULL;
offscreen = GDK_OFFSCREEN_WINDOW (private->impl);
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
return offscreen->embedder;
}
......
This diff is collapsed.
......@@ -21,6 +21,7 @@
#include "gdkdevice-core.h"
#include "gdkinternals.h"
#include "gdkwindow.h"
#include "gdkprivate-x11.h"
#include "gdkx.h"
......@@ -104,14 +105,12 @@ impl_coord_in_window (GdkWindow *window,
int impl_x,
int impl_y)
{
GdkWindowObject *priv = (GdkWindowObject *) window;
if (impl_x < priv->abs_x ||
impl_x > priv->abs_x + priv->width)
if (impl_x < window->abs_x ||
impl_x > window->abs_x + window->width)
return FALSE;
if (impl_y < priv->abs_y ||
impl_y > priv->abs_y + priv->height)
if (impl_y < window->abs_y ||
impl_y > window->abs_y + window->height)
return FALSE;
return TRUE;
......@@ -125,7 +124,6 @@ gdk_device_core_get_history (GdkDevice *device,
GdkTimeCoord ***events,
gint *n_events)
{
GdkWindowObject *priv;
XTimeCoord *xcoords;
GdkTimeCoord **coords;
GdkWindow *impl_window;
......@@ -139,7 +137,6 @@ gdk_device_core_get_history (GdkDevice *device,
if (!xcoords)
return FALSE;
priv = (GdkWindowObject *) window;
coords = _gdk_device_allocate_history (device, tmp_n_events);
for (i = 0, j = 0; i < tmp_n_events; i++)
......@@ -147,8 +144,8 @@ gdk_device_core_get_history (GdkDevice *device,
if (impl_coord_in_window (window, xcoords[i].x, xcoords[i].y))
{
coords[j]->time = xcoords[i].time;
coords[j]->axes[0] = xcoords[i].x - priv->abs_x;
coords[j]->axes[1] = xcoords[i].y - priv->abs_y;
coords[j]->axes[0] = xcoords[i].x - window->abs_x;
coords[j]->axes[1] = xcoords[i].y - window->abs_y;
j++;
}
}
......@@ -428,7 +425,7 @@ gdk_device_core_window_at_position (GdkDevice *device,
if (get_toplevel && last != root &&
(window = gdk_window_lookup_for_display (display, last)) != NULL &&
GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
window->window_type != GDK_WINDOW_FOREIGN)
{
xwindow = last;
break;
......
......@@ -415,7 +415,6 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator,
{
GdkDeviceManagerCore *device_manager;
GdkWindow *window;
GdkWindowObject *window_private;
GdkWindowImplX11 *window_impl = NULL;
gboolean return_val;
GdkToplevelX11 *toplevel = NULL;
......@@ -425,7 +424,6 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator,
return_val = FALSE;
window = get_event_window (translator, xevent);
window_private = (GdkWindowObject *) window;