Use accessor functions instead direct access.

GTK+ 2.20 is now the required version

Still missing:
GTK_MENU_SHELL ()->have_xgrab

https://bugzilla.gnome.org/show_bug.cgi?id=595496
This commit is contained in:
Javier Jardón 2010-04-11 20:30:44 +02:00 committed by Florian Müllner
parent 092cc47afc
commit 9e123695d0
16 changed files with 288 additions and 169 deletions

View File

@ -124,7 +124,7 @@ if test "x$GCC" = "xyes"; then
fi
changequote([,])dnl
MUTTER_PC_MODULES='gtk+-2.0 >= 2.10.0 pango >= 1.2.0'
MUTTER_PC_MODULES='gtk+-2.0 >= 2.20 pango >= 1.2.0'
AC_ARG_ENABLE(gconf,
AC_HELP_STRING([--disable-gconf],
@ -184,8 +184,8 @@ AM_GLIB_GNU_GETTEXT
# GRegex requires Glib-2.14.0
PKG_CHECK_MODULES(ALL, glib-2.0 >= 2.14.0)
# gtk_window_set_icon_name requires gtk2+-2.6.0
PKG_CHECK_MODULES(MUTTER_MESSAGE, gtk+-2.0 >= 2.6.0)
PKG_CHECK_MODULES(MUTTER_WINDOW_DEMO, gtk+-2.0 >= 2.6.0)
PKG_CHECK_MODULES(MUTTER_MESSAGE, gtk+-2.0 >= 2.20)
PKG_CHECK_MODULES(MUTTER_WINDOW_DEMO, gtk+-2.0 >= 2.20)
# Unconditionally use this dir to avoid a circular dep with gnomecc
GNOME_KEYBINDINGS_KEYSDIR="${datadir}/gnome-control-center/keybindings"

View File

@ -76,14 +76,17 @@ get_pixbuf (void)
static gboolean
regrab_idle (GtkWidget *image)
{
GtkAllocation allocation;
GdkPixbuf *magnified;
if (image->allocation.width != last_grab_allocation.width ||
image->allocation.height != last_grab_allocation.height)
gtk_widget_get_allocation (image, &allocation);
if (allocation.width != last_grab_allocation.width ||
allocation.height != last_grab_allocation.height)
{
last_grab_width = rint (image->allocation.width / width_factor);
last_grab_height = rint (image->allocation.height / height_factor);
last_grab_allocation = image->allocation;
last_grab_width = rint (allocation.width / width_factor);
last_grab_height = rint (allocation.height / height_factor);
last_grab_allocation = allocation;
magnified = get_pixbuf ();
@ -224,6 +227,8 @@ mouse_press (GtkWidget *invisible,
static void
begin_area_grab (void)
{
GdkWindow *window;
if (grab_widget == NULL)
{
grab_widget = gtk_invisible_new ();
@ -234,7 +239,9 @@ begin_area_grab (void)
gtk_widget_show (grab_widget);
}
if (gdk_keyboard_grab (grab_widget->window,
window = gtk_widget_get_window (grab_widget);
if (gdk_keyboard_grab (window,
FALSE,
gtk_get_current_event_time ()) != GDK_GRAB_SUCCESS)
{
@ -242,7 +249,7 @@ begin_area_grab (void)
return;
}
if (gdk_pointer_grab (grab_widget->window,
if (gdk_pointer_grab (window,
FALSE,
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK,
NULL,

View File

@ -62,19 +62,22 @@ static void
on_realize_set_struts (GtkWindow *window,
gpointer data)
{
GtkWidget *widget;
int left;
int right;
int top;
int bottom;
g_return_if_fail (GTK_WIDGET_REALIZED (window));
widget = GTK_WIDGET (window);
g_return_if_fail (gtk_widget_get_realized (widget));
left = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "meta-strut-left"));
right = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "meta-strut-right"));
top = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "meta-strut-top"));
bottom = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "meta-strut-bottom"));
set_gdk_window_struts (GTK_WIDGET (window)->window,
set_gdk_window_struts (gtk_widget_get_window (widget),
left, right, top, bottom);
}
@ -85,6 +88,10 @@ set_gtk_window_struts (GtkWidget *window,
int top,
int bottom)
{
GtkWidget *widget;
widget = GTK_WIDGET (window);
g_object_set_data (G_OBJECT (window), "meta-strut-left",
GINT_TO_POINTER (left));
g_object_set_data (G_OBJECT (window), "meta-strut-right",
@ -93,18 +100,18 @@ set_gtk_window_struts (GtkWidget *window,
GINT_TO_POINTER (top));
g_object_set_data (G_OBJECT (window), "meta-strut-bottom",
GINT_TO_POINTER (bottom));
g_signal_handlers_disconnect_by_func (G_OBJECT (window),
on_realize_set_struts,
NULL);
g_signal_connect_after (G_OBJECT (window),
"realize",
G_CALLBACK (on_realize_set_struts),
NULL);
if (GTK_WIDGET_REALIZED (window))
set_gdk_window_struts (GTK_WIDGET (window)->window,
if (gtk_widget_get_realized (widget))
set_gdk_window_struts (gtk_widget_get_window (widget),
left, right, top, bottom);
}
@ -129,15 +136,18 @@ static void
on_realize_set_type (GtkWindow *window,
gpointer data)
{
GtkWidget *widget;
const char *type;
g_return_if_fail (GTK_WIDGET_REALIZED (window));
widget = GTK_WIDGET (window);
g_return_if_fail (gtk_widget_get_realized (widget));
type = g_object_get_data (G_OBJECT (window), "meta-window-type");
g_return_if_fail (type != NULL);
set_gdk_window_type (GTK_WIDGET (window)->window,
set_gdk_window_type (gtk_widget_get_window (widget),
type);
}
@ -145,6 +155,10 @@ static void
set_gtk_window_type (GtkWindow *window,
const char *type)
{
GtkWidget *widget;
widget = GTK_WIDGET (window);
g_object_set_data (G_OBJECT (window), "meta-window-type", (char*) type);
g_signal_handlers_disconnect_by_func (G_OBJECT (window),
@ -156,8 +170,8 @@ set_gtk_window_type (GtkWindow *window,
G_CALLBACK (on_realize_set_type),
NULL);
if (GTK_WIDGET_REALIZED (window))
set_gdk_window_type (GTK_WIDGET (window)->window,
if (gtk_widget_get_realized (widget))
set_gdk_window_type (gtk_widget_get_window (widget),
type);
}
@ -171,14 +185,22 @@ static void
on_realize_set_border_only (GtkWindow *window,
gpointer data)
{
g_return_if_fail (GTK_WIDGET_REALIZED (window));
GtkWidget *widget;
widget = GTK_WIDGET (window);
g_return_if_fail (gtk_widget_get_realized (widget));
set_gdk_window_border_only (GTK_WIDGET (window)->window);
set_gdk_window_border_only (gtk_widget_get_window (widget));
}
static void
set_gtk_window_border_only (GtkWindow *window)
{
GtkWidget *widget;
widget = GTK_WIDGET (window);
g_signal_handlers_disconnect_by_func (G_OBJECT (window),
on_realize_set_border_only,
NULL);
@ -188,8 +210,8 @@ set_gtk_window_border_only (GtkWindow *window)
G_CALLBACK (on_realize_set_border_only),
NULL);
if (GTK_WIDGET_REALIZED (window))
set_gdk_window_border_only (GTK_WIDGET (window)->window);
if (gtk_widget_get_realized (widget))
set_gdk_window_border_only (gtk_widget_get_window (widget));
}
int

View File

@ -77,6 +77,7 @@ draw_window (GtkWidget *widget,
int icon_x, icon_y, icon_w, icon_h;
gboolean is_active;
GdkColor *color;
GtkStyle *style;
is_active = win->is_active;
@ -84,10 +85,11 @@ draw_window (GtkWidget *widget,
cairo_rectangle (cr, winrect->x, winrect->y, winrect->width, winrect->height);
cairo_clip (cr);
style = gtk_widget_get_style (widget);
if (is_active)
color = &widget->style->light[state];
color = &style->light[state];
else
color = &widget->style->bg[state];
color = &style->bg[state];
cairo_set_source_rgb (cr,
color->red / 65535.,
color->green / 65535.,
@ -141,11 +143,11 @@ draw_window (GtkWidget *widget,
cairo_paint (cr);
cairo_restore (cr);
}
if (is_active)
color = &widget->style->fg[state];
color = &style->fg[state];
else
color = &widget->style->fg[state];
color = &style->fg[state];
cairo_set_source_rgb (cr,
color->red / 65535.,
@ -177,6 +179,7 @@ wnck_draw_workspace (GtkWidget *widget,
int i;
GdkRectangle workspace_rect;
GtkStateType state;
GtkStyle *style;
workspace_rect.x = x;
workspace_rect.y = y;
@ -189,11 +192,13 @@ wnck_draw_workspace (GtkWidget *widget,
state = GTK_STATE_PRELIGHT;
else
state = GTK_STATE_NORMAL;
style = gtk_widget_get_style (widget);
if (workspace_background)
{
gdk_draw_pixbuf (drawable,
GTK_WIDGET (widget)->style->dark_gc[state],
style->dark_gc[state],
workspace_background,
0, 0,
x, y,
@ -205,8 +210,8 @@ wnck_draw_workspace (GtkWidget *widget,
{
cairo_t *cr;
cr = gdk_cairo_create (widget->window);
gdk_cairo_set_source_color (cr, &widget->style->dark[state]);
cr = gdk_cairo_create (gtk_widget_get_window (widget));
gdk_cairo_set_source_color (cr, &style->dark[state]);
cairo_rectangle (cr, x, y, width, height);
cairo_fill (cr);
cairo_destroy (cr);

View File

@ -53,7 +53,8 @@ static int screen_bottom_edge = 0;
static gint
expose_handler (GtkTooltips *tooltips)
{
gtk_paint_flat_box (tip->style, tip->window,
gtk_paint_flat_box (gtk_widget_get_style (tip),
gtk_widget_get_window (tip),
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
NULL, tip, "tooltip",
0, 0, -1, -1);

View File

@ -133,6 +133,24 @@ meta_frames_get_type (void)
return frames_type;
}
static GObject *
meta_frames_constructor (GType gtype,
guint n_properties,
GObjectConstructParam *properties)
{
GObject *object;
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (parent_class);
object = gobject_class->constructor (gtype, n_properties, properties);
g_object_set (object,
"type", GTK_WINDOW_POPUP,
NULL);
return object;
}
static void
meta_frames_class_init (MetaFramesClass *class)
{
@ -146,6 +164,7 @@ meta_frames_class_init (MetaFramesClass *class)
parent_class = g_type_class_peek_parent (class);
gobject_class->constructor = meta_frames_constructor;
gobject_class->finalize = meta_frames_finalize;
object_class->destroy = meta_frames_destroy;
@ -203,8 +222,6 @@ prefs_changed_callback (MetaPreference pref,
static void
meta_frames_init (MetaFrames *frames)
{
GTK_WINDOW (frames)->type = GTK_WINDOW_POPUP;
frames->text_heights = g_hash_table_new (NULL, NULL);
frames->frames = g_hash_table_new (unsigned_long_hash, unsigned_long_equal);
@ -459,10 +476,10 @@ meta_frames_ensure_layout (MetaFrames *frames,
MetaFrameFlags flags;
MetaFrameType type;
MetaFrameStyle *style;
g_return_if_fail (GTK_WIDGET_REALIZED (frames));
widget = GTK_WIDGET (frames);
g_return_if_fail (gtk_widget_get_realized (widget));
meta_core_get (gdk_display, frame->xwindow,
META_CORE_GET_FRAME_FLAGS, &flags,

View File

@ -386,6 +386,7 @@ meta_window_menu_new (MetaFrames *frames,
Display *display;
Window xroot;
GdkScreen *screen;
GdkWindow *window;
GtkWidget *submenu;
int j;
@ -398,9 +399,10 @@ meta_window_menu_new (MetaFrames *frames,
meta_verbose ("Creating %d-workspace menu current space %lu\n",
n_workspaces, active_workspace);
display = gdk_x11_drawable_get_xdisplay (GTK_WIDGET (frames)->window);
window = gtk_widget_get_window (GTK_WIDGET (frames));
display = gdk_x11_drawable_get_xdisplay (window);
screen = gdk_drawable_get_screen (GTK_WIDGET (frames)->window);
screen = gdk_drawable_get_screen (window);
xroot = GDK_DRAWABLE_XID (gdk_screen_get_root_window (screen));
submenu = gtk_menu_new ();

View File

@ -262,52 +262,61 @@ meta_accel_label_expose_event (GtkWidget *widget,
GtkMisc *misc = GTK_MISC (accel_label);
PangoLayout *layout;
if (GTK_WIDGET_DRAWABLE (accel_label))
if (gtk_widget_is_drawable (GTK_WIDGET (accel_label)))
{
GtkAllocation allocation;
GtkRequisition requisition;
int ac_width;
gtk_widget_get_allocation (widget, &allocation);
gtk_widget_get_requisition (widget, &requisition);
ac_width = meta_accel_label_get_accel_width (accel_label);
if (widget->allocation.width >= widget->requisition.width + ac_width)
if (allocation.width >= requisition.width + ac_width)
{
GtkTextDirection direction = gtk_widget_get_direction (widget);
gint x;
gint y;
gfloat xalign, yalign;
gint x, y;
gint xpad, ypad;
gtk_misc_get_padding (misc, &xpad, &ypad);
gtk_misc_get_alignment (misc, &xalign, &yalign);
if (direction == GTK_TEXT_DIR_RTL)
{
widget->allocation.x += ac_width;
allocation.x += ac_width;
}
widget->allocation.width -= ac_width;
allocation.width -= ac_width;
gtk_widget_set_allocation (widget, &allocation);
if (GTK_WIDGET_CLASS (parent_class)->expose_event)
GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
if (direction == GTK_TEXT_DIR_RTL)
{
widget->allocation.x -= ac_width;
allocation.x -= ac_width;
}
widget->allocation.width += ac_width;
allocation.width += ac_width;
gtk_widget_set_allocation (widget, &allocation);
if (direction == GTK_TEXT_DIR_RTL)
{
x = widget->allocation.x + misc->xpad;
x = allocation.x + xpad;
}
else
{
x = widget->allocation.x + widget->allocation.width - misc->xpad - ac_width;
x = allocation.x + allocation.width - xpad - ac_width;
}
y = (widget->allocation.y * (1.0 - misc->yalign) +
(widget->allocation.y + widget->allocation.height -
(widget->requisition.height - misc->ypad * 2)) *
misc->yalign) + 1.5;
y = (allocation.y * (1.0 - yalign) +
(allocation.y + allocation.height -
(requisition.height - ypad * 2)) * yalign) + 1.5;
layout = gtk_widget_create_pango_layout (widget, accel_label->accel_string);
gtk_paint_layout (widget->style,
widget->window,
GTK_WIDGET_STATE (widget),
gtk_paint_layout (gtk_widget_get_style (widget),
gtk_widget_get_window (widget),
gtk_widget_get_state (widget),
FALSE,
&event->area,
widget,

View File

@ -85,8 +85,8 @@ static void
meta_preview_init (MetaPreview *preview)
{
int i;
GTK_WIDGET_SET_FLAGS (preview, GTK_NO_WINDOW);
gtk_widget_set_has_window (GTK_WIDGET (preview), FALSE);
i = 0;
while (i < MAX_BUTTONS_PER_CORNER)
@ -216,6 +216,7 @@ meta_preview_expose (GtkWidget *widget,
GdkEventExpose *event)
{
MetaPreview *preview;
GtkAllocation allocation;
int border_width;
int client_width;
int client_height;
@ -234,10 +235,11 @@ meta_preview_expose (GtkWidget *widget,
ensure_info (preview);
border_width = GTK_CONTAINER (widget)->border_width;
client_width = widget->allocation.width - preview->left_width - preview->right_width - border_width * 2;
client_height = widget->allocation.height - preview->top_height - preview->bottom_height - border_width * 2;
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
gtk_widget_get_allocation (widget, &allocation);
client_width = allocation.width - preview->left_width - preview->right_width - border_width * 2;
client_height = allocation.height - preview->top_height - preview->bottom_height - border_width * 2;
if (client_width < 0)
client_width = 1;
@ -246,14 +248,12 @@ meta_preview_expose (GtkWidget *widget,
if (preview->theme)
{
border_width = GTK_CONTAINER (widget)->border_width;
meta_theme_draw_frame (preview->theme,
widget,
widget->window,
gtk_widget_get_window (widget),
&event->area,
widget->allocation.x + border_width,
widget->allocation.y + border_width,
allocation.x + border_width,
allocation.y + border_width,
preview->type,
preview->flags,
client_width, client_height,
@ -274,6 +274,8 @@ meta_preview_size_request (GtkWidget *widget,
GtkRequisition *req)
{
MetaPreview *preview;
GtkWidget *child;
guint border_width;
preview = META_PREVIEW (widget);
@ -281,13 +283,13 @@ meta_preview_size_request (GtkWidget *widget,
req->width = preview->left_width + preview->right_width;
req->height = preview->top_height + preview->bottom_height;
if (GTK_BIN (preview)->child &&
GTK_WIDGET_VISIBLE (GTK_BIN (preview)->child))
child = gtk_bin_get_child (GTK_BIN (preview));
if (child && gtk_widget_get_visible (child))
{
GtkRequisition child_requisition;
gtk_widget_size_request (GTK_BIN (preview)->child, &child_requisition);
gtk_widget_size_request (child, &child_requisition);
req->width += child_requisition.width;
req->height += child_requisition.height;
@ -300,8 +302,9 @@ meta_preview_size_request (GtkWidget *widget,
req->height += NO_CHILD_HEIGHT;
}
req->width += GTK_CONTAINER (widget)->border_width * 2;
req->height += GTK_CONTAINER (widget)->border_width * 2;
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
req->width += border_width * 2;
req->height += border_width * 2;
}
static void
@ -309,27 +312,29 @@ meta_preview_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
MetaPreview *preview;
int border_width;
GtkAllocation child_allocation;
GtkAllocation widget_allocation, child_allocation;
GtkWidget *child;
guint border_width;
preview = META_PREVIEW (widget);
ensure_info (preview);
widget->allocation = *allocation;
border_width = GTK_CONTAINER (widget)->border_width;
if (GTK_BIN (widget)->child &&
GTK_WIDGET_VISIBLE (GTK_BIN (widget)->child))
gtk_widget_set_allocation (widget, allocation);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
child = gtk_bin_get_child (GTK_BIN (widget));
if (child && gtk_widget_get_visible (child))
{
child_allocation.x = widget->allocation.x + border_width + preview->left_width;
child_allocation.y = widget->allocation.y + border_width + preview->top_height;
gtk_widget_get_allocation (widget, &widget_allocation);
child_allocation.x = widget_allocation.x + border_width + preview->left_width;
child_allocation.y = widget_allocation.y + border_width + preview->top_height;
child_allocation.width = MAX (1, widget->allocation.width - border_width * 2 - preview->left_width - preview->right_width);
child_allocation.height = MAX (1, widget->allocation.height - border_width * 2 - preview->top_height - preview->bottom_height);
child_allocation.width = MAX (1, widget_allocation.width - border_width * 2 - preview->left_width - preview->right_width);
child_allocation.height = MAX (1, widget_allocation.height - border_width * 2 - preview->top_height - preview->bottom_height);
gtk_widget_size_allocate (GTK_BIN (widget)->child, &child_allocation);
gtk_widget_size_allocate (child, &child_allocation);
}
}

View File

@ -123,10 +123,10 @@ update_size_window (MetaResizePopup *popup)
x = popup->rect.x + (popup->rect.width - width) / 2;
y = popup->rect.y + (popup->rect.height - height) / 2;
if (GTK_WIDGET_REALIZED (popup->size_window))
if (gtk_widget_get_realized (popup->size_window))
{
/* using move_resize to avoid jumpiness */
gdk_window_move_resize (popup->size_window->window,
gdk_window_move_resize (gtk_widget_get_window (popup->size_window),
x, y,
width, height);
}
@ -145,8 +145,8 @@ sync_showing (MetaResizePopup *popup)
if (popup->size_window)
gtk_widget_show (popup->size_window);
if (popup->size_window && GTK_WIDGET_REALIZED (popup->size_window))
gdk_window_raise (popup->size_window->window);
if (popup->size_window && gtk_widget_get_realized (popup->size_window))
gdk_window_raise (gtk_widget_get_window (popup->size_window));
}
else
{

View File

@ -77,7 +77,9 @@ outline_window_expose (GtkWidget *widget,
gpointer data)
{
MetaTabPopup *popup;
TabEntry *te;
TabEntry *te;
GtkStyle *style;
GdkWindow *window;
popup = data;
@ -85,16 +87,18 @@ outline_window_expose (GtkWidget *widget,
return FALSE;
te = popup->current_selected_entry;
window = gtk_widget_get_window (widget);
style = gtk_widget_get_style (widget);
gdk_draw_rectangle (widget->window,
widget->style->white_gc,
gdk_draw_rectangle (window,
style->white_gc,
FALSE,
0, 0,
te->rect.width - 1,
te->rect.height - 1);
gdk_draw_rectangle (widget->window,
widget->style->white_gc,
gdk_draw_rectangle (window,
style->white_gc,
FALSE,
te->inner_rect.x - 1, te->inner_rect.y - 1,
te->inner_rect.width + 1,
@ -439,7 +443,7 @@ meta_ui_tab_popup_set_showing (MetaTabPopup *popup,
}
else
{
if (GTK_WIDGET_VISIBLE (popup->window))
if (gtk_widget_get_visible (popup->window))
{
meta_verbose ("Hiding tab popup window\n");
gtk_widget_hide (popup->window);
@ -455,6 +459,7 @@ display_entry (MetaTabPopup *popup,
GdkRectangle rect;
GdkRegion *region;
GdkRegion *inner_region;
GdkWindow *window;
if (popup->current_selected_entry)
@ -474,27 +479,29 @@ display_entry (MetaTabPopup *popup,
if (popup->outline)
{
window = gtk_widget_get_window (popup->outline_window);
/* Do stuff behind gtk's back */
gdk_window_hide (popup->outline_window->window);
gdk_window_hide (window);
meta_core_increment_event_serial (gdk_display);
rect = te->rect;
rect.x = 0;
rect.y = 0;
gdk_window_move_resize (popup->outline_window->window,
gdk_window_move_resize (window,
te->rect.x, te->rect.y,
te->rect.width, te->rect.height);
gdk_window_set_background (popup->outline_window->window,
&popup->outline_window->style->black);
gdk_window_set_background (window,
&gtk_widget_get_style (popup->outline_window)->black);
region = gdk_region_rectangle (&rect);
inner_region = gdk_region_rectangle (&te->inner_rect);
gdk_region_subtract (region, inner_region);
gdk_region_destroy (inner_region);
gdk_window_shape_combine_region (popup->outline_window->window,
gdk_window_shape_combine_region (window,
region,
0, 0);
@ -505,8 +512,8 @@ display_entry (MetaTabPopup *popup,
* we manually set the window as mapped and then manually map it
* with gdk functions.
*/
GTK_WIDGET_SET_FLAGS (popup->outline_window, GTK_MAPPED);
gdk_window_show_unraised (popup->outline_window->window);
gtk_widget_set_mapped (popup->outline_window, TRUE);
gdk_window_show_unraised (window);
}
/* Must be before we handle an expose for the outline window */
@ -691,32 +698,46 @@ meta_select_image_expose_event (GtkWidget *widget,
{
if (META_SELECT_IMAGE (widget)->selected)
{
int x, y, w, h;
GtkAllocation allocation;
GtkMisc *misc;
GtkRequisition requisition;
GtkStyle *style;
GtkStateType state;
GdkWindow *window;
int x, y, w, h;
gint xpad, ypad;
gfloat xalign, yalign;
misc = GTK_MISC (widget);
gtk_widget_get_allocation (widget, &allocation);
gtk_widget_get_requisition (widget, &requisition);
gtk_misc_get_alignment (misc, &xalign, &yalign);
gtk_misc_get_padding (misc, &xpad, &ypad);
x = (widget->allocation.x * (1.0 - misc->xalign) +
(widget->allocation.x + widget->allocation.width
- (widget->requisition.width - misc->xpad * 2)) *
misc->xalign) + 0.5;
y = (widget->allocation.y * (1.0 - misc->yalign) +
(widget->allocation.y + widget->allocation.height
- (widget->requisition.height - misc->ypad * 2)) *
misc->yalign) + 0.5;
x = (allocation.x * (1.0 - xalign) +
(allocation.x + allocation.width
- (requisition.width - xpad * 2)) * xalign) + 0.5;
y = (allocation.y * (1.0 - yalign) +
(allocation.y + allocation.height
- (requisition.height - ypad * 2)) * yalign) + 0.5;
x -= INSIDE_SELECT_RECT + 1;
y -= INSIDE_SELECT_RECT + 1;
w = widget->requisition.width - OUTSIDE_SELECT_RECT * 2 - 1;
h = widget->requisition.height - OUTSIDE_SELECT_RECT * 2 - 1;
w = requisition.width - OUTSIDE_SELECT_RECT * 2 - 1;
h = requisition.height - OUTSIDE_SELECT_RECT * 2 - 1;
gdk_draw_rectangle (widget->window,
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
window = gtk_widget_get_window (widget);
style = gtk_widget_get_style (widget);
state = gtk_widget_get_state (widget);
gdk_draw_rectangle (window,
style->fg_gc[state],
FALSE,
x, y, w, h);
gdk_draw_rectangle (widget->window,
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
gdk_draw_rectangle (window,
style->fg_gc[state],
FALSE,
x - 1, y - 1, w + 2, h + 2);
@ -879,6 +900,9 @@ meta_select_workspace_expose_event (GtkWidget *widget,
{
MetaWorkspace *workspace;
WnckWindowDisplayInfo *windows;
GtkAllocation allocation;
GtkStyle *style;
GdkWindow *window;
int i, n_windows;
GList *tmp, *list;
@ -917,12 +941,15 @@ meta_select_workspace_expose_event (GtkWidget *widget,
g_list_free (list);
window = gtk_widget_get_window (widget);
gtk_widget_get_allocation (widget, &allocation);
wnck_draw_workspace (widget,
widget->window,
window,
SELECT_OUTLINE_WIDTH,
SELECT_OUTLINE_WIDTH,
widget->allocation.width - SELECT_OUTLINE_WIDTH * 2,
widget->allocation.height - SELECT_OUTLINE_WIDTH * 2,
allocation.width - SELECT_OUTLINE_WIDTH * 2,
allocation.height - SELECT_OUTLINE_WIDTH * 2,
workspace->screen->rect.width,
workspace->screen->rect.height,
NULL,
@ -934,16 +961,18 @@ meta_select_workspace_expose_event (GtkWidget *widget,
if (META_SELECT_WORKSPACE (widget)->selected)
{
style = gtk_widget_get_style (widget);
i = SELECT_OUTLINE_WIDTH - 1;
while (i >= 0)
{
gdk_draw_rectangle (widget->window,
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
gdk_draw_rectangle (window,
style->fg_gc[gtk_widget_get_state (widget)],
FALSE,
i,
i,
widget->allocation.width - i * 2 - 1,
widget->allocation.height - i * 2 - 1);
allocation.width - i * 2 - 1,
allocation.height - i * 2 - 1);
--i;
}

View File

@ -267,11 +267,16 @@ expose_callback (GtkWidget *widget,
gpointer data)
{
RenderGradientFunc func = data;
GtkAllocation allocation;
GtkStyle *style;
(* func) (widget->window,
widget->style->fg_gc[widget->state],
widget->allocation.width,
widget->allocation.height);
style = gtk_widget_get_style (widget);
gtk_widget_get_allocation (widget, &allocation);
(* func) (gtk_widget_get_window (widget),
style->fg_gc[gtk_widget_get_state (widget)],
allocation.width,
allocation.height);
return TRUE;
}

View File

@ -766,6 +766,7 @@ benchmark_summary (void)
int
main (int argc, char **argv)
{
GtkStyle *style;
GtkWidget *window;
GtkWidget *collection;
GError *err;
@ -842,26 +843,28 @@ main (int argc, char **argv)
G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_realize (window);
g_assert (window->style);
g_assert (window->style->font_desc);
style = gtk_widget_get_style (window);
g_assert (style);
g_assert (style->font_desc);
notebook = gtk_notebook_new ();
gtk_container_add (GTK_CONTAINER (window), notebook);
collection = preview_collection (FONT_SIZE_NORMAL,
window->style->font_desc);
style->font_desc);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
collection,
gtk_label_new (_("Normal Title Font")));
collection = preview_collection (FONT_SIZE_SMALL,
window->style->font_desc);
style->font_desc);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
collection,
gtk_label_new (_("Small Title Font")));
collection = preview_collection (FONT_SIZE_LARGE,
window->style->font_desc);
style->font_desc);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
collection,
gtk_label_new (_("Large Title Font")));
@ -912,7 +915,7 @@ get_flags (GtkWidget *widget)
static int
get_text_height (GtkWidget *widget)
{
return meta_pango_font_desc_get_text_height (widget->style->font_desc,
return meta_pango_font_desc_get_text_height (gtk_widget_get_style (widget)->font_desc,
gtk_widget_get_pango_context (widget));
}
@ -993,7 +996,7 @@ run_theme_benchmark (void)
/* Creating the pixmap in the loop is right, since
* GDK does the same with its double buffering.
*/
pixmap = gdk_pixmap_new (widget->window,
pixmap = gdk_pixmap_new (gtk_widget_get_window (widget),
client_width + left_width + right_width,
client_height + top_height + bottom_height,
-1);

View File

@ -1360,9 +1360,13 @@ meta_color_spec_render (MetaColorSpec *spec,
GtkWidget *widget,
GdkColor *color)
{
GtkStyle *style;
style = gtk_widget_get_style (widget);
g_return_if_fail (spec != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (widget->style != NULL);
g_return_if_fail (style != NULL);
switch (spec->type)
{
@ -1374,28 +1378,28 @@ meta_color_spec_render (MetaColorSpec *spec,
switch (spec->data.gtk.component)
{
case META_GTK_COLOR_BG:
*color = widget->style->bg[spec->data.gtk.state];
*color = style->bg[spec->data.gtk.state];
break;
case META_GTK_COLOR_FG:
*color = widget->style->fg[spec->data.gtk.state];
*color = style->fg[spec->data.gtk.state];
break;
case META_GTK_COLOR_BASE:
*color = widget->style->base[spec->data.gtk.state];
*color = style->base[spec->data.gtk.state];
break;
case META_GTK_COLOR_TEXT:
*color = widget->style->text[spec->data.gtk.state];
*color = style->text[spec->data.gtk.state];
break;
case META_GTK_COLOR_LIGHT:
*color = widget->style->light[spec->data.gtk.state];
*color = style->light[spec->data.gtk.state];
break;
case META_GTK_COLOR_DARK:
*color = widget->style->dark[spec->data.gtk.state];
*color = style->dark[spec->data.gtk.state];
break;
case META_GTK_COLOR_MID:
*color = widget->style->mid[spec->data.gtk.state];
*color = style->mid[spec->data.gtk.state];
break;
case META_GTK_COLOR_TEXT_AA:
*color = widget->style->text_aa[spec->data.gtk.state];
*color = style->text_aa[spec->data.gtk.state];
break;
case META_GTK_COLOR_LAST:
g_assert_not_reached ();
@ -3907,7 +3911,7 @@ meta_draw_op_draw (const MetaDrawOp *op,
const MetaDrawInfo *info,
MetaRectangle logical_region)
{
meta_draw_op_draw_with_style (op, widget->style, widget,
meta_draw_op_draw_with_style (op, gtk_widget_get_style (widget), widget,
drawable, clip, info, logical_region);
}
@ -4037,7 +4041,7 @@ meta_draw_op_list_draw (const MetaDrawOpList *op_list,
MetaRectangle rect)
{
meta_draw_op_list_draw_with_style (op_list, widget->style, widget,
meta_draw_op_list_draw_with_style (op_list, gtk_widget_get_style (widget), widget,
drawable, clip, info, rect);
}
@ -4609,7 +4613,7 @@ meta_frame_style_draw (MetaFrameStyle *style,
GdkPixbuf *mini_icon,
GdkPixbuf *icon)
{
meta_frame_style_draw_with_style (style, widget->style, widget,
meta_frame_style_draw_with_style (style, gtk_widget_get_style (widget), widget,
drawable, x_offset, y_offset,
clip, fgeom, client_width, client_height,
title_layout, text_height,
@ -5234,7 +5238,7 @@ meta_theme_draw_frame (MetaTheme *theme,
GdkPixbuf *mini_icon,
GdkPixbuf *icon)
{
meta_theme_draw_frame_with_style (theme, widget->style, widget,
meta_theme_draw_frame_with_style (theme, gtk_widget_get_style (widget), widget,
drawable, clip, x_offset, y_offset, type,flags,
client_width, client_height,
title_layout, text_height,
@ -5628,9 +5632,9 @@ meta_gtk_widget_get_font_desc (GtkWidget *widget,
{
PangoFontDescription *font_desc;
g_return_val_if_fail (GTK_WIDGET_REALIZED (widget), NULL);
g_return_val_if_fail (gtk_widget_get_realized (widget), NULL);
font_desc = pango_font_description_copy (widget->style->font_desc);
font_desc = pango_font_description_copy (gtk_widget_get_style (widget)->font_desc);
if (override)
pango_font_description_merge (font_desc, override, TRUE);

View File

@ -80,7 +80,7 @@ meta_area_class_init (MetaAreaClass *class)
static void
meta_area_init (MetaArea *area)
{
GTK_WIDGET_SET_FLAGS (area, GTK_NO_WINDOW);
gtk_widget_set_has_window (GTK_WIDGET (area), FALSE);
}
GtkWidget*
@ -111,28 +111,34 @@ meta_area_expose (GtkWidget *widget,
GdkEventExpose *event)
{
MetaArea *area;
GtkAllocation allocation;
GtkMisc *misc;
GtkRequisition requisition;
gfloat xalign, yalign;
gint x, y;
gfloat xalign;
gint xpad, ypad;
g_return_val_if_fail (META_IS_AREA (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
if (GTK_WIDGET_DRAWABLE (widget))
if (gtk_widget_is_drawable (widget))
{
area = META_AREA (widget);
misc = GTK_MISC (widget);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
xalign = misc->xalign;
else
xalign = 1.0 - misc->xalign;
gtk_widget_get_allocation (widget, &allocation);
gtk_widget_get_requisition (widget, &requisition);
gtk_misc_get_alignment (misc, &xalign, &yalign);
gtk_misc_get_padding (misc, &xpad, &ypad);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
xalign = 1.0 - xalign;
x = floor (widget->allocation.x + misc->xpad
+ ((widget->allocation.width - widget->requisition.width) * xalign)
x = floor (allocation.x + xpad
+ ((allocation.width - requisition.width) * xalign)
+ 0.5);
y = floor (widget->allocation.y + misc->ypad
+ ((widget->allocation.height - widget->requisition.height) * misc->yalign)
y = floor (allocation.y + ypad
+ ((allocation.height - requisition.height) * yalign)
+ 0.5);
if (area->expose_func)

View File

@ -379,7 +379,7 @@ meta_image_window_new (Display *xdisplay,
gtk_window_set_screen (GTK_WINDOW (iw->window), gscreen);
gtk_widget_realize (iw->window);
iw->pixmap = gdk_pixmap_new (iw->window->window,
iw->pixmap = gdk_pixmap_new (gtk_widget_get_window (iw->window),
max_width, max_height,
-1);
@ -417,13 +417,15 @@ meta_image_window_set (MetaImageWindow *iw,
int x,
int y)
{
GdkWindow *window;
/* We use a back pixmap to avoid having to handle exposes, because
* it's really too slow for large clients being minimized, etc.
* and this way flicker is genuinely zero.
*/
gdk_draw_pixbuf (iw->pixmap,
iw->window->style->black_gc,
gtk_widget_get_style (iw->window)->black_gc,
pixbuf,
0, 0,
0, 0,
@ -432,16 +434,18 @@ meta_image_window_set (MetaImageWindow *iw,
GDK_RGB_DITHER_NORMAL,
0, 0);
gdk_window_set_back_pixmap (iw->window->window,
window = gtk_widget_get_window (iw->window);
gdk_window_set_back_pixmap (window,
iw->pixmap,
FALSE);
gdk_window_move_resize (iw->window->window,
gdk_window_move_resize (window,
x, y,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf));
gdk_window_clear (iw->window->window);
gdk_window_clear (window);
}
static GdkColormap*