mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
Fix compilation against latest GTK3 changes
With the newest changes to GTK3, some things were changed. This patch now uses the features introduced in gtk3-compat.h in previous patches. This patch also introduces a macro named USE_GTK3 that is used to differentiate between GTK3 and GTK2. Its main use is differenting between expose and draw handlers for GtkWidget subclasses. The draw vs expose handlers question is usually handled by using ifdefs at the beginning and end to set up/tear down a cairo_t and then use it. However, when the function is too different and too many ifdefs would be necessary, two versions of the function are written. This is currently the case for: - MetaAccelLabel - MetaFrames https://bugzilla.gnome.org/show_bug.cgi?id=630203
This commit is contained in:
parent
e75abacec6
commit
9f5d8d1a2a
@ -14,7 +14,34 @@
|
|||||||
|
|
||||||
#define gdk_visual_get_depth(v) GDK_VISUAL(v)->depth
|
#define gdk_visual_get_depth(v) GDK_VISUAL(v)->depth
|
||||||
|
|
||||||
#endif /*GTK_CHECK_VERSION */
|
#endif /* GTK_CHECK_VERSION (2, 21, 1) */
|
||||||
|
|
||||||
|
#if !GTK_CHECK_VERSION (2, 90, 8)
|
||||||
|
|
||||||
|
#define gdk_window_get_screen gdk_drawable_get_screen
|
||||||
|
#define gdk_pixbuf_get_from_window(dest, window, src_x, src_y, dest_x, dest_y, width, height) \
|
||||||
|
gdk_pixbuf_get_from_drawable(dest, window, NULL, src_x, src_y, dest_x, dest_y, width, height)
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
gdk_window_get_width (GdkWindow *window)
|
||||||
|
{
|
||||||
|
int width;
|
||||||
|
|
||||||
|
gdk_drawable_get_size (window, &width, NULL);
|
||||||
|
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
gdk_window_get_height (GdkWindow *window)
|
||||||
|
{
|
||||||
|
int height;
|
||||||
|
|
||||||
|
gdk_drawable_get_size (window, NULL, &height);
|
||||||
|
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
gdk_cairo_get_clip_rectangle (cairo_t *cr,
|
gdk_cairo_get_clip_rectangle (cairo_t *cr,
|
||||||
@ -43,6 +70,7 @@ gdk_cairo_get_clip_rectangle (cairo_t *cr,
|
|||||||
return clip_exists;
|
return clip_exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* GTK_CHECK_VERSION (2, 90, 8) */
|
||||||
|
|
||||||
/* Compatibility with old GDK key symbols */
|
/* Compatibility with old GDK key symbols */
|
||||||
#ifndef GDK_KEY_Escape
|
#ifndef GDK_KEY_Escape
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include "gdk-compat.h"
|
#include "gdk-compat.h"
|
||||||
|
|
||||||
|
#ifndef USE_GTK3
|
||||||
|
|
||||||
static const cairo_user_data_key_t context_key;
|
static const cairo_user_data_key_t context_key;
|
||||||
|
|
||||||
cairo_t *
|
cairo_t *
|
||||||
@ -172,3 +174,4 @@ meta_paint_flat_box (GtkStyle *style,
|
|||||||
x + dx, y + dy, width, height);
|
x + dx, y + dy, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* USE_GTK3 */
|
||||||
|
@ -24,6 +24,26 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#if GTK_CHECK_VERSION (2, 90, 8)
|
||||||
|
|
||||||
|
#define USE_GTK3 1
|
||||||
|
|
||||||
|
#define MetaPixmap cairo_surface_t
|
||||||
|
|
||||||
|
#define meta_pixmap_new(window, w, h) gdk_window_create_similar_surface (window, CAIRO_CONTENT_COLOR, w, h)
|
||||||
|
#define meta_pixmap_free(pixmap) cairo_surface_destroy (pixmap)
|
||||||
|
#define meta_pixmap_cairo_create(pixmap) cairo_create (pixmap)
|
||||||
|
#define meta_cairo_set_source_pixmap(cr, pixmap, x, y) cairo_set_source_surface (cr, pixmap, x, y)
|
||||||
|
|
||||||
|
#define meta_paint_vline gtk_paint_vline
|
||||||
|
#define meta_paint_box gtk_paint_box
|
||||||
|
#define meta_paint_arrow gtk_paint_arrow
|
||||||
|
#define meta_paint_flat_box gtk_paint_flat_box
|
||||||
|
|
||||||
|
#else /* GTK_VERSION < 2.90.8 */
|
||||||
|
|
||||||
|
#undef USE_GTK3
|
||||||
|
|
||||||
#define MetaPixmap GdkPixmap
|
#define MetaPixmap GdkPixmap
|
||||||
|
|
||||||
#define meta_pixmap_new(window, w, h) gdk_pixmap_new (window, w, h, -1)
|
#define meta_pixmap_new(window, w, h) gdk_pixmap_new (window, w, h, -1)
|
||||||
@ -75,4 +95,6 @@ void meta_paint_flat_box (GtkStyle *style,
|
|||||||
gint width,
|
gint width,
|
||||||
gint height);
|
gint height);
|
||||||
|
|
||||||
|
#endif /* GTK_VERSION < 2.90.8 */
|
||||||
|
|
||||||
#endif /* __GTK3_COMPAT_H__ */
|
#endif /* __GTK3_COMPAT_H__ */
|
||||||
|
@ -28,7 +28,8 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <gdk-compat.h>
|
|
||||||
|
#include "gdk-compat.h"
|
||||||
|
|
||||||
static GtkWidget *grab_widget = NULL;
|
static GtkWidget *grab_widget = NULL;
|
||||||
static GtkWidget *display_window = NULL;
|
static GtkWidget *display_window = NULL;
|
||||||
@ -53,10 +54,9 @@ get_pixbuf (void)
|
|||||||
last_grab_width, last_grab_height);
|
last_grab_width, last_grab_height);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
screenshot = gdk_pixbuf_get_from_drawable (NULL, gdk_get_default_root_window (),
|
screenshot = gdk_pixbuf_get_from_window (NULL, gdk_get_default_root_window (),
|
||||||
NULL,
|
last_grab_x, last_grab_y, 0, 0,
|
||||||
last_grab_x, last_grab_y, 0, 0,
|
last_grab_width, last_grab_height);
|
||||||
last_grab_width, last_grab_height);
|
|
||||||
|
|
||||||
if (screenshot == NULL)
|
if (screenshot == NULL)
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include "fixedtip.h"
|
#include "fixedtip.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
|
#include "gdk2-drawing-utils.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The floating rectangle. This is a GtkWindow, and it contains
|
* The floating rectangle. This is a GtkWindow, and it contains
|
||||||
* the "label" widget, below.
|
* the "label" widget, below.
|
||||||
@ -50,6 +52,22 @@ static int screen_right_edge = 0;
|
|||||||
*/
|
*/
|
||||||
static int screen_bottom_edge = 0;
|
static int screen_bottom_edge = 0;
|
||||||
|
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
static gboolean
|
||||||
|
draw_handler (GtkWidget *tooltips,
|
||||||
|
cairo_t *cr)
|
||||||
|
{
|
||||||
|
gtk_paint_flat_box (gtk_widget_get_style (tip),
|
||||||
|
cr,
|
||||||
|
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
|
||||||
|
tip, "tooltip",
|
||||||
|
0, 0,
|
||||||
|
gtk_widget_get_allocated_width (tooltips),
|
||||||
|
gtk_widget_get_allocated_height (tooltips));
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#else /* !USE_GTK3 */
|
||||||
static gint
|
static gint
|
||||||
expose_handler (GtkWidget *tooltips)
|
expose_handler (GtkWidget *tooltips)
|
||||||
{
|
{
|
||||||
@ -61,6 +79,7 @@ expose_handler (GtkWidget *tooltips)
|
|||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
#endif /* !USE_GTK3 */
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_fixed_tip_show (Display *xdisplay, int screen_number,
|
meta_fixed_tip_show (Display *xdisplay, int screen_number,
|
||||||
@ -94,8 +113,13 @@ meta_fixed_tip_show (Display *xdisplay, int screen_number,
|
|||||||
gtk_widget_set_name (tip, "gtk-tooltips");
|
gtk_widget_set_name (tip, "gtk-tooltips");
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (tip), 4);
|
gtk_container_set_border_width (GTK_CONTAINER (tip), 4);
|
||||||
|
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
g_signal_connect_swapped (tip, "draw",
|
||||||
|
G_CALLBACK (draw_handler), NULL);
|
||||||
|
#else
|
||||||
g_signal_connect_swapped (tip, "expose_event",
|
g_signal_connect_swapped (tip, "expose_event",
|
||||||
G_CALLBACK (expose_handler), NULL);
|
G_CALLBACK (expose_handler), NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
label = gtk_label_new (NULL);
|
label = gtk_label_new (NULL);
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
#include "gtk-compat.h"
|
#include "gtk-compat.h"
|
||||||
#include "gdk-compat.h"
|
#include "gdk-compat.h"
|
||||||
|
|
||||||
|
#include <cairo-xlib.h>
|
||||||
|
|
||||||
#ifdef HAVE_SHAPE
|
#ifdef HAVE_SHAPE
|
||||||
#include <X11/extensions/shape.h>
|
#include <X11/extensions/shape.h>
|
||||||
#endif
|
#endif
|
||||||
@ -64,8 +66,13 @@ static gboolean meta_frames_motion_notify_event (GtkWidget *widget,
|
|||||||
GdkEventMotion *event);
|
GdkEventMotion *event);
|
||||||
static gboolean meta_frames_destroy_event (GtkWidget *widget,
|
static gboolean meta_frames_destroy_event (GtkWidget *widget,
|
||||||
GdkEventAny *event);
|
GdkEventAny *event);
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
static gboolean meta_frames_draw (GtkWidget *widget,
|
||||||
|
cairo_t *cr);
|
||||||
|
#else
|
||||||
static gboolean meta_frames_expose_event (GtkWidget *widget,
|
static gboolean meta_frames_expose_event (GtkWidget *widget,
|
||||||
GdkEventExpose *event);
|
GdkEventExpose *event);
|
||||||
|
#endif
|
||||||
static gboolean meta_frames_enter_notify_event (GtkWidget *widget,
|
static gboolean meta_frames_enter_notify_event (GtkWidget *widget,
|
||||||
GdkEventCrossing *event);
|
GdkEventCrossing *event);
|
||||||
static gboolean meta_frames_leave_notify_event (GtkWidget *widget,
|
static gboolean meta_frames_leave_notify_event (GtkWidget *widget,
|
||||||
@ -148,7 +155,11 @@ meta_frames_class_init (MetaFramesClass *class)
|
|||||||
widget_class->map = meta_frames_map;
|
widget_class->map = meta_frames_map;
|
||||||
widget_class->unmap = meta_frames_unmap;
|
widget_class->unmap = meta_frames_unmap;
|
||||||
|
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
widget_class->draw = meta_frames_draw;
|
||||||
|
#else
|
||||||
widget_class->expose_event = meta_frames_expose_event;
|
widget_class->expose_event = meta_frames_expose_event;
|
||||||
|
#endif
|
||||||
widget_class->destroy_event = meta_frames_destroy_event;
|
widget_class->destroy_event = meta_frames_destroy_event;
|
||||||
widget_class->button_press_event = meta_frames_button_press_event;
|
widget_class->button_press_event = meta_frames_button_press_event;
|
||||||
widget_class->button_release_event = meta_frames_button_release_event;
|
widget_class->button_release_event = meta_frames_button_release_event;
|
||||||
@ -1016,7 +1027,8 @@ meta_frames_move_resize_frame (MetaFrames *frames,
|
|||||||
MetaUIFrame *frame = meta_frames_lookup_window (frames, xwindow);
|
MetaUIFrame *frame = meta_frames_lookup_window (frames, xwindow);
|
||||||
int old_width, old_height;
|
int old_width, old_height;
|
||||||
|
|
||||||
gdk_drawable_get_size (frame->window, &old_width, &old_height);
|
old_width = gdk_window_get_width (frame->window);
|
||||||
|
old_height = gdk_window_get_height (frame->window);
|
||||||
|
|
||||||
gdk_window_move_resize (frame->window, x, y, width, height);
|
gdk_window_move_resize (frame->window, x, y, width, height);
|
||||||
|
|
||||||
@ -2278,6 +2290,72 @@ cached_pixels_draw (CachedPixels *pixels,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
static gboolean
|
||||||
|
meta_frames_draw (GtkWidget *widget,
|
||||||
|
cairo_t *cr)
|
||||||
|
{
|
||||||
|
MetaUIFrame *frame;
|
||||||
|
MetaFrames *frames;
|
||||||
|
CachedPixels *pixels;
|
||||||
|
MetaRegion *region;
|
||||||
|
GdkRectangle *areas, clip;
|
||||||
|
int i, n_areas;
|
||||||
|
cairo_surface_t *target;
|
||||||
|
|
||||||
|
frames = META_FRAMES (widget);
|
||||||
|
target = cairo_get_target (cr);
|
||||||
|
gdk_cairo_get_clip_rectangle (cr, &clip);
|
||||||
|
|
||||||
|
g_assert (cairo_surface_get_type (target) == CAIRO_SURFACE_TYPE_XLIB);
|
||||||
|
frame = meta_frames_lookup_window (frames, cairo_xlib_surface_get_drawable (target));
|
||||||
|
if (frame == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (frames->expose_delay_count > 0)
|
||||||
|
{
|
||||||
|
/* Redraw this entire frame later */
|
||||||
|
frame->expose_delayed = TRUE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
populate_cache (frames, frame);
|
||||||
|
|
||||||
|
region = meta_region_new_from_rectangle (&clip);
|
||||||
|
|
||||||
|
pixels = get_cache (frames, frame);
|
||||||
|
|
||||||
|
cached_pixels_draw (pixels, cr, region);
|
||||||
|
|
||||||
|
clip_to_screen (region, frame);
|
||||||
|
subtract_client_area (region, frame);
|
||||||
|
|
||||||
|
meta_region_get_rectangles (region, &areas, &n_areas);
|
||||||
|
|
||||||
|
for (i = 0; i < n_areas; i++)
|
||||||
|
{
|
||||||
|
cairo_save (cr);
|
||||||
|
|
||||||
|
gdk_cairo_rectangle (cr, &areas[i]);
|
||||||
|
cairo_clip (cr);
|
||||||
|
|
||||||
|
cairo_push_group (cr);
|
||||||
|
|
||||||
|
meta_frames_paint (frames, frame, cr, 0, 0);
|
||||||
|
|
||||||
|
cairo_pop_group_to_source (cr);
|
||||||
|
cairo_paint (cr);
|
||||||
|
|
||||||
|
cairo_restore (cr);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (areas);
|
||||||
|
|
||||||
|
meta_region_destroy (region);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#else /* !USE_GTK3 */
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_frames_expose_event (GtkWidget *widget,
|
meta_frames_expose_event (GtkWidget *widget,
|
||||||
GdkEventExpose *event)
|
GdkEventExpose *event)
|
||||||
@ -2341,6 +2419,7 @@ meta_frames_expose_event (GtkWidget *widget,
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
#endif /* !USE_GTK3 */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_frames_paint (MetaFrames *frames,
|
meta_frames_paint (MetaFrames *frames,
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#include "metaaccellabel.h"
|
#include "metaaccellabel.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
|
#include "gdk-compat.h"
|
||||||
|
|
||||||
typedef struct _MenuItem MenuItem;
|
typedef struct _MenuItem MenuItem;
|
||||||
typedef struct _MenuData MenuData;
|
typedef struct _MenuData MenuData;
|
||||||
|
|
||||||
@ -403,7 +405,7 @@ meta_window_menu_new (MetaFrames *frames,
|
|||||||
window = gtk_widget_get_window (GTK_WIDGET (frames));
|
window = gtk_widget_get_window (GTK_WIDGET (frames));
|
||||||
display = gdk_x11_drawable_get_xdisplay (window);
|
display = gdk_x11_drawable_get_xdisplay (window);
|
||||||
|
|
||||||
screen = gdk_drawable_get_screen (window);
|
screen = gdk_window_get_screen (window);
|
||||||
xroot = GDK_DRAWABLE_XID (gdk_screen_get_root_window (screen));
|
xroot = GDK_DRAWABLE_XID (gdk_screen_get_root_window (screen));
|
||||||
|
|
||||||
submenu = gtk_menu_new ();
|
submenu = gtk_menu_new ();
|
||||||
|
@ -38,13 +38,19 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include "gtk-compat.h"
|
#include "gtk-compat.h"
|
||||||
|
#include "gdk2-drawing-utils.h"
|
||||||
|
|
||||||
static void meta_accel_label_destroy (GtkObject *object);
|
static void meta_accel_label_destroy (GtkObject *object);
|
||||||
static void meta_accel_label_finalize (GObject *object);
|
static void meta_accel_label_finalize (GObject *object);
|
||||||
static void meta_accel_label_size_request (GtkWidget *widget,
|
static void meta_accel_label_size_request (GtkWidget *widget,
|
||||||
GtkRequisition *requisition);
|
GtkRequisition *requisition);
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
static gboolean meta_accel_label_draw (GtkWidget *widget,
|
||||||
|
cairo_t *cr);
|
||||||
|
#else
|
||||||
static gboolean meta_accel_label_expose_event (GtkWidget *widget,
|
static gboolean meta_accel_label_expose_event (GtkWidget *widget,
|
||||||
GdkEventExpose *event);
|
GdkEventExpose *event);
|
||||||
|
#endif
|
||||||
|
|
||||||
static void meta_accel_label_update (MetaAccelLabel *accel_label);
|
static void meta_accel_label_update (MetaAccelLabel *accel_label);
|
||||||
static int meta_accel_label_get_accel_width (MetaAccelLabel *accel_label);
|
static int meta_accel_label_get_accel_width (MetaAccelLabel *accel_label);
|
||||||
@ -63,7 +69,11 @@ meta_accel_label_class_init (MetaAccelLabelClass *class)
|
|||||||
object_class->destroy = meta_accel_label_destroy;
|
object_class->destroy = meta_accel_label_destroy;
|
||||||
|
|
||||||
widget_class->size_request = meta_accel_label_size_request;
|
widget_class->size_request = meta_accel_label_size_request;
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
widget_class->draw = meta_accel_label_draw;
|
||||||
|
#else
|
||||||
widget_class->expose_event = meta_accel_label_expose_event;
|
widget_class->expose_event = meta_accel_label_expose_event;
|
||||||
|
#endif
|
||||||
|
|
||||||
class->signal_quote1 = g_strdup ("<:");
|
class->signal_quote1 = g_strdup ("<:");
|
||||||
class->signal_quote2 = g_strdup (":>");
|
class->signal_quote2 = g_strdup (":>");
|
||||||
@ -225,6 +235,94 @@ meta_accel_label_size_request (GtkWidget *widget,
|
|||||||
g_object_unref (G_OBJECT (layout));
|
g_object_unref (G_OBJECT (layout));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
/* Mostly taken from GTK3. */
|
||||||
|
static gboolean
|
||||||
|
meta_accel_label_draw (GtkWidget *widget,
|
||||||
|
cairo_t *cr)
|
||||||
|
{
|
||||||
|
MetaAccelLabel *accel_label = META_ACCEL_LABEL (widget);
|
||||||
|
GtkMisc *misc = GTK_MISC (accel_label);
|
||||||
|
GtkTextDirection direction;
|
||||||
|
int ac_width;
|
||||||
|
GtkAllocation allocation;
|
||||||
|
GtkRequisition requisition;
|
||||||
|
|
||||||
|
direction = gtk_widget_get_direction (widget);
|
||||||
|
ac_width = meta_accel_label_get_accel_width (accel_label);
|
||||||
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
gtk_widget_get_preferred_size (widget,
|
||||||
|
&requisition, NULL);
|
||||||
|
|
||||||
|
if (allocation.width >= requisition.width + ac_width)
|
||||||
|
{
|
||||||
|
PangoLayout *label_layout;
|
||||||
|
PangoLayout *accel_layout;
|
||||||
|
GtkLabel *label = GTK_LABEL (widget);
|
||||||
|
gint x, y, xpad, ypad;
|
||||||
|
gfloat xalign, yalign;
|
||||||
|
|
||||||
|
label_layout = gtk_label_get_layout (GTK_LABEL (accel_label));
|
||||||
|
gtk_misc_get_alignment (misc, &xalign, &yalign);
|
||||||
|
|
||||||
|
cairo_save (cr);
|
||||||
|
|
||||||
|
/* XXX: Mad hack: We modify the label's width so it renders
|
||||||
|
* properly in its draw function that we chain to. */
|
||||||
|
if (direction == GTK_TEXT_DIR_RTL)
|
||||||
|
cairo_translate (cr, ac_width, 0);
|
||||||
|
if (gtk_label_get_ellipsize (label))
|
||||||
|
pango_layout_set_width (label_layout,
|
||||||
|
pango_layout_get_width (label_layout)
|
||||||
|
- ac_width * PANGO_SCALE);
|
||||||
|
|
||||||
|
allocation.width -= ac_width;
|
||||||
|
gtk_widget_set_allocation (widget, &allocation);
|
||||||
|
if (GTK_WIDGET_CLASS (meta_accel_label_parent_class)->draw)
|
||||||
|
GTK_WIDGET_CLASS (meta_accel_label_parent_class)->draw (widget,
|
||||||
|
cr);
|
||||||
|
allocation.width += ac_width;
|
||||||
|
gtk_widget_set_allocation (widget, &allocation);
|
||||||
|
if (gtk_label_get_ellipsize (label))
|
||||||
|
pango_layout_set_width (label_layout,
|
||||||
|
pango_layout_get_width (label_layout)
|
||||||
|
+ ac_width * PANGO_SCALE);
|
||||||
|
|
||||||
|
cairo_restore (cr);
|
||||||
|
|
||||||
|
gtk_misc_get_padding (misc, &xpad, &ypad);
|
||||||
|
|
||||||
|
if (direction == GTK_TEXT_DIR_RTL)
|
||||||
|
x = xpad;
|
||||||
|
else
|
||||||
|
x = gtk_widget_get_allocated_width (widget) - xpad - ac_width;
|
||||||
|
|
||||||
|
gtk_label_get_layout_offsets (GTK_LABEL (accel_label), NULL, &y);
|
||||||
|
|
||||||
|
accel_layout = gtk_widget_create_pango_layout (widget, accel_label->accel_string);
|
||||||
|
|
||||||
|
y = (allocation.height - (requisition.height - ypad * 2)) * yalign + 1.5;
|
||||||
|
|
||||||
|
gtk_paint_layout (gtk_widget_get_style (widget),
|
||||||
|
cr,
|
||||||
|
gtk_widget_get_state (widget),
|
||||||
|
FALSE,
|
||||||
|
widget,
|
||||||
|
"accellabel",
|
||||||
|
x, y,
|
||||||
|
accel_layout);
|
||||||
|
|
||||||
|
g_object_unref (accel_layout);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (GTK_WIDGET_CLASS (meta_accel_label_parent_class)->draw)
|
||||||
|
GTK_WIDGET_CLASS (meta_accel_label_parent_class)->draw (widget, cr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#else /* !USE_GTK3 */
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_accel_label_expose_event (GtkWidget *widget,
|
meta_accel_label_expose_event (GtkWidget *widget,
|
||||||
GdkEventExpose *event)
|
GdkEventExpose *event)
|
||||||
@ -306,6 +404,7 @@ meta_accel_label_expose_event (GtkWidget *widget,
|
|||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
#endif /* !USE_GTK3 */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_accel_label_update (MetaAccelLabel *accel_label)
|
meta_accel_label_update (MetaAccelLabel *accel_label)
|
||||||
|
@ -34,8 +34,13 @@ static void meta_preview_size_request (GtkWidget *widget,
|
|||||||
GtkRequisition *req);
|
GtkRequisition *req);
|
||||||
static void meta_preview_size_allocate (GtkWidget *widget,
|
static void meta_preview_size_allocate (GtkWidget *widget,
|
||||||
GtkAllocation *allocation);
|
GtkAllocation *allocation);
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
static gboolean meta_preview_draw (GtkWidget *widget,
|
||||||
|
cairo_t *cr);
|
||||||
|
#else
|
||||||
static gboolean meta_preview_expose (GtkWidget *widget,
|
static gboolean meta_preview_expose (GtkWidget *widget,
|
||||||
GdkEventExpose *event);
|
GdkEventExpose *event);
|
||||||
|
#endif
|
||||||
static void meta_preview_finalize (GObject *object);
|
static void meta_preview_finalize (GObject *object);
|
||||||
|
|
||||||
G_DEFINE_TYPE (MetaPreview, meta_preview, GTK_TYPE_BIN);
|
G_DEFINE_TYPE (MetaPreview, meta_preview, GTK_TYPE_BIN);
|
||||||
@ -50,7 +55,11 @@ meta_preview_class_init (MetaPreviewClass *class)
|
|||||||
|
|
||||||
gobject_class->finalize = meta_preview_finalize;
|
gobject_class->finalize = meta_preview_finalize;
|
||||||
|
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
widget_class->draw = meta_preview_draw;
|
||||||
|
#else
|
||||||
widget_class->expose_event = meta_preview_expose;
|
widget_class->expose_event = meta_preview_expose;
|
||||||
|
#endif
|
||||||
widget_class->size_request = meta_preview_size_request;
|
widget_class->size_request = meta_preview_size_request;
|
||||||
widget_class->size_allocate = meta_preview_size_allocate;
|
widget_class->size_allocate = meta_preview_size_allocate;
|
||||||
}
|
}
|
||||||
@ -185,54 +194,61 @@ ensure_info (MetaPreview *preview)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
static gboolean
|
||||||
|
meta_preview_draw (GtkWidget *widget,
|
||||||
|
cairo_t *cr)
|
||||||
|
{
|
||||||
|
MetaPreview *preview = META_PREVIEW (widget);
|
||||||
|
GtkAllocation allocation;
|
||||||
|
|
||||||
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
#else
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_preview_expose (GtkWidget *widget,
|
meta_preview_expose (GtkWidget *widget,
|
||||||
GdkEventExpose *event)
|
GdkEventExpose *event)
|
||||||
{
|
{
|
||||||
MetaPreview *preview;
|
cairo_t *cr = meta_cairo_create (gtk_widget_get_window (widget));
|
||||||
|
MetaPreview *preview = META_PREVIEW (widget);
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
int border_width;
|
|
||||||
int client_width;
|
|
||||||
int client_height;
|
|
||||||
MetaButtonState button_states[META_BUTTON_TYPE_LAST] =
|
|
||||||
{
|
|
||||||
META_BUTTON_STATE_NORMAL,
|
|
||||||
META_BUTTON_STATE_NORMAL,
|
|
||||||
META_BUTTON_STATE_NORMAL,
|
|
||||||
META_BUTTON_STATE_NORMAL
|
|
||||||
};
|
|
||||||
|
|
||||||
g_return_val_if_fail (META_IS_PREVIEW (widget), FALSE);
|
|
||||||
g_return_val_if_fail (event != NULL, FALSE);
|
|
||||||
|
|
||||||
preview = META_PREVIEW (widget);
|
gdk_cairo_region (cr, event->region);
|
||||||
|
cairo_clip (cr);
|
||||||
ensure_info (preview);
|
|
||||||
|
|
||||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
client_width = allocation.width - preview->left_width - preview->right_width - border_width * 2;
|
cairo_translate (cr, allocation.x, allocation.y);
|
||||||
client_height = allocation.height - preview->top_height - preview->bottom_height - border_width * 2;
|
#endif
|
||||||
|
|
||||||
if (client_width < 0)
|
|
||||||
client_width = 1;
|
|
||||||
if (client_height < 0)
|
|
||||||
client_height = 1;
|
|
||||||
|
|
||||||
if (preview->theme)
|
if (preview->theme)
|
||||||
{
|
{
|
||||||
cairo_t *cr;
|
int border_width;
|
||||||
|
int client_width;
|
||||||
|
int client_height;
|
||||||
|
MetaButtonState button_states[META_BUTTON_TYPE_LAST] =
|
||||||
|
{
|
||||||
|
META_BUTTON_STATE_NORMAL,
|
||||||
|
META_BUTTON_STATE_NORMAL,
|
||||||
|
META_BUTTON_STATE_NORMAL,
|
||||||
|
META_BUTTON_STATE_NORMAL
|
||||||
|
};
|
||||||
|
|
||||||
|
ensure_info (preview);
|
||||||
|
|
||||||
cr = meta_cairo_create (gtk_widget_get_window (widget));
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
||||||
gdk_cairo_region (cr, event->region);
|
|
||||||
cairo_clip (cr);
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
if (client_height < 0)
|
||||||
|
client_height = 1;
|
||||||
|
|
||||||
meta_theme_draw_frame (preview->theme,
|
meta_theme_draw_frame (preview->theme,
|
||||||
widget,
|
widget,
|
||||||
cr,
|
cr,
|
||||||
allocation.x + border_width,
|
border_width,
|
||||||
allocation.y + border_width,
|
border_width,
|
||||||
preview->type,
|
preview->type,
|
||||||
preview->flags,
|
preview->flags,
|
||||||
client_width, client_height,
|
client_width, client_height,
|
||||||
@ -243,11 +259,17 @@ meta_preview_expose (GtkWidget *widget,
|
|||||||
meta_preview_get_mini_icon (),
|
meta_preview_get_mini_icon (),
|
||||||
meta_preview_get_icon ());
|
meta_preview_get_icon ());
|
||||||
|
|
||||||
cairo_destroy (cr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
/* draw child */
|
||||||
|
return GTK_WIDGET_CLASS (meta_preview_parent_class)->draw (widget, cr);
|
||||||
|
#else
|
||||||
|
cairo_destroy (cr);
|
||||||
|
|
||||||
/* draw child */
|
/* draw child */
|
||||||
return GTK_WIDGET_CLASS (meta_preview_parent_class)->expose_event (widget, event);
|
return GTK_WIDGET_CLASS (meta_preview_parent_class)->expose_event (widget, event);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "gtk-compat.h"
|
#include "gtk-compat.h"
|
||||||
|
#include "gdk2-drawing-utils.h"
|
||||||
|
|
||||||
#define OUTSIDE_SELECT_RECT 2
|
#define OUTSIDE_SELECT_RECT 2
|
||||||
#define INSIDE_SELECT_RECT 2
|
#define INSIDE_SELECT_RECT 2
|
||||||
@ -74,16 +75,24 @@ static GtkWidget* selectable_workspace_new (MetaWorkspace *workspace);
|
|||||||
static void select_workspace (GtkWidget *widget);
|
static void select_workspace (GtkWidget *widget);
|
||||||
static void unselect_workspace (GtkWidget *widget);
|
static void unselect_workspace (GtkWidget *widget);
|
||||||
|
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
static gboolean
|
||||||
|
outline_window_draw (GtkWidget *widget,
|
||||||
|
cairo_t *cr,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
#else /* !USE_GTK3 */
|
||||||
static gboolean
|
static gboolean
|
||||||
outline_window_expose (GtkWidget *widget,
|
outline_window_expose (GtkWidget *widget,
|
||||||
GdkEventExpose *event,
|
GdkEventExpose *event,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
cairo_t *cr = gdk_cairo_create (event->window);
|
||||||
|
#endif /* !USE_GTK3 */
|
||||||
|
|
||||||
MetaTabPopup *popup;
|
MetaTabPopup *popup;
|
||||||
TabEntry *te;
|
TabEntry *te;
|
||||||
GtkStyle *style;
|
GtkStyle *style;
|
||||||
GdkWindow *window;
|
|
||||||
cairo_t *cr;
|
|
||||||
|
|
||||||
popup = data;
|
popup = data;
|
||||||
|
|
||||||
@ -91,9 +100,7 @@ outline_window_expose (GtkWidget *widget,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
te = popup->current_selected_entry;
|
te = popup->current_selected_entry;
|
||||||
window = gtk_widget_get_window (widget);
|
|
||||||
style = gtk_widget_get_style (widget);
|
style = gtk_widget_get_style (widget);
|
||||||
cr = gdk_cairo_create (window);
|
|
||||||
|
|
||||||
cairo_set_line_width (cr, 1.0);
|
cairo_set_line_width (cr, 1.0);
|
||||||
gdk_cairo_set_source_color (cr, &style->white);
|
gdk_cairo_set_source_color (cr, &style->white);
|
||||||
@ -110,7 +117,9 @@ outline_window_expose (GtkWidget *widget,
|
|||||||
te->inner_rect.height + 1);
|
te->inner_rect.height + 1);
|
||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
|
|
||||||
|
#ifndef USE_GTK3
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
|
#endif
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -252,8 +261,13 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
|
|||||||
gtk_widget_set_app_paintable (popup->outline_window, TRUE);
|
gtk_widget_set_app_paintable (popup->outline_window, TRUE);
|
||||||
gtk_widget_realize (popup->outline_window);
|
gtk_widget_realize (popup->outline_window);
|
||||||
|
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
g_signal_connect (G_OBJECT (popup->outline_window), "draw",
|
||||||
|
G_CALLBACK (outline_window_draw), popup);
|
||||||
|
#else
|
||||||
g_signal_connect (G_OBJECT (popup->outline_window), "expose_event",
|
g_signal_connect (G_OBJECT (popup->outline_window), "expose_event",
|
||||||
G_CALLBACK (outline_window_expose), popup);
|
G_CALLBACK (outline_window_expose), popup);
|
||||||
|
#endif
|
||||||
|
|
||||||
popup->window = gtk_window_new (GTK_WINDOW_POPUP);
|
popup->window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||||
|
|
||||||
@ -659,8 +673,13 @@ unselect_image (GtkWidget *widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void meta_select_image_class_init (MetaSelectImageClass *klass);
|
static void meta_select_image_class_init (MetaSelectImageClass *klass);
|
||||||
|
#if USE_GTK3
|
||||||
|
static gboolean meta_select_image_draw (GtkWidget *widget,
|
||||||
|
cairo_t *cr);
|
||||||
|
#else
|
||||||
static gboolean meta_select_image_expose_event (GtkWidget *widget,
|
static gboolean meta_select_image_expose_event (GtkWidget *widget,
|
||||||
GdkEventExpose *event);
|
GdkEventExpose *event);
|
||||||
|
#endif
|
||||||
|
|
||||||
static GtkImageClass *parent_class;
|
static GtkImageClass *parent_class;
|
||||||
|
|
||||||
@ -699,16 +718,37 @@ meta_select_image_class_init (MetaSelectImageClass *klass)
|
|||||||
|
|
||||||
widget_class = GTK_WIDGET_CLASS (klass);
|
widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
|
||||||
|
#if USE_GTK3
|
||||||
|
widget_class->draw = meta_select_image_draw;
|
||||||
|
#else
|
||||||
widget_class->expose_event = meta_select_image_expose_event;
|
widget_class->expose_event = meta_select_image_expose_event;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if USE_GTK3
|
||||||
|
static gboolean
|
||||||
|
meta_select_image_draw (GtkWidget *widget,
|
||||||
|
cairo_t *cr)
|
||||||
|
{
|
||||||
|
GtkAllocation allocation;
|
||||||
|
|
||||||
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
#else /* !USE_GTK3 */
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_select_image_expose_event (GtkWidget *widget,
|
meta_select_image_expose_event (GtkWidget *widget,
|
||||||
GdkEventExpose *event)
|
GdkEventExpose *event)
|
||||||
{
|
{
|
||||||
|
GtkAllocation allocation;
|
||||||
|
cairo_t *cr = gdk_cairo_create (event->window);
|
||||||
|
|
||||||
|
gdk_cairo_region (cr, event->region);
|
||||||
|
cairo_clip (cr);
|
||||||
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
cairo_translate (cr, allocation.x, allocation.y);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (META_SELECT_IMAGE (widget)->selected)
|
if (META_SELECT_IMAGE (widget)->selected)
|
||||||
{
|
{
|
||||||
GtkAllocation allocation;
|
|
||||||
GtkMisc *misc;
|
GtkMisc *misc;
|
||||||
GtkRequisition requisition;
|
GtkRequisition requisition;
|
||||||
GtkStyle *style;
|
GtkStyle *style;
|
||||||
@ -717,21 +757,15 @@ meta_select_image_expose_event (GtkWidget *widget,
|
|||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
gint xpad, ypad;
|
gint xpad, ypad;
|
||||||
gfloat xalign, yalign;
|
gfloat xalign, yalign;
|
||||||
cairo_t *cr;
|
|
||||||
|
|
||||||
misc = GTK_MISC (widget);
|
misc = GTK_MISC (widget);
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
|
||||||
gtk_widget_get_requisition (widget, &requisition);
|
gtk_widget_get_requisition (widget, &requisition);
|
||||||
gtk_misc_get_alignment (misc, &xalign, &yalign);
|
gtk_misc_get_alignment (misc, &xalign, &yalign);
|
||||||
gtk_misc_get_padding (misc, &xpad, &ypad);
|
gtk_misc_get_padding (misc, &xpad, &ypad);
|
||||||
|
|
||||||
x = (allocation.x * (1.0 - xalign) +
|
x = (allocation.width - (requisition.width - xpad * 2)) * xalign + 0.5;
|
||||||
(allocation.x + allocation.width
|
y = (allocation.height - (requisition.height - ypad * 2)) * yalign + 0.5;
|
||||||
- (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;
|
x -= INSIDE_SELECT_RECT + 1;
|
||||||
y -= INSIDE_SELECT_RECT + 1;
|
y -= INSIDE_SELECT_RECT + 1;
|
||||||
@ -742,7 +776,6 @@ meta_select_image_expose_event (GtkWidget *widget,
|
|||||||
window = gtk_widget_get_window (widget);
|
window = gtk_widget_get_window (widget);
|
||||||
style = gtk_widget_get_style (widget);
|
style = gtk_widget_get_style (widget);
|
||||||
state = gtk_widget_get_state (widget);
|
state = gtk_widget_get_state (widget);
|
||||||
cr = gdk_cairo_create (window);
|
|
||||||
|
|
||||||
cairo_set_line_width (cr, 2.0);
|
cairo_set_line_width (cr, 2.0);
|
||||||
gdk_cairo_set_source_color (cr, &style->fg[state]);
|
gdk_cairo_set_source_color (cr, &style->fg[state]);
|
||||||
@ -751,22 +784,15 @@ meta_select_image_expose_event (GtkWidget *widget,
|
|||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
|
|
||||||
cairo_set_line_width (cr, 1.0);
|
cairo_set_line_width (cr, 1.0);
|
||||||
#if 0
|
|
||||||
gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_SELECTED]);
|
|
||||||
cairo_rectangle (cr, x, y, w, h);
|
|
||||||
cairo_fill (cr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
gtk_paint_focus (widget->style, widget->window,
|
|
||||||
&event->area, widget, "meta-tab-image",
|
|
||||||
x, y, w, h);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cairo_destroy (cr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
return GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
|
||||||
|
#else
|
||||||
|
cairo_destroy (cr);
|
||||||
|
|
||||||
return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
|
return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
|
||||||
|
#endif /* !USE_GTK3 */
|
||||||
}
|
}
|
||||||
|
|
||||||
#define META_TYPE_SELECT_WORKSPACE (meta_select_workspace_get_type ())
|
#define META_TYPE_SELECT_WORKSPACE (meta_select_workspace_get_type ())
|
||||||
@ -830,8 +856,13 @@ unselect_workspace (GtkWidget *widget)
|
|||||||
|
|
||||||
static void meta_select_workspace_class_init (MetaSelectWorkspaceClass *klass);
|
static void meta_select_workspace_class_init (MetaSelectWorkspaceClass *klass);
|
||||||
|
|
||||||
|
#if USE_GTK3
|
||||||
|
static gboolean meta_select_workspace_draw (GtkWidget *widget,
|
||||||
|
cairo_t *cr);
|
||||||
|
#else
|
||||||
static gboolean meta_select_workspace_expose_event (GtkWidget *widget,
|
static gboolean meta_select_workspace_expose_event (GtkWidget *widget,
|
||||||
GdkEventExpose *event);
|
GdkEventExpose *event);
|
||||||
|
#endif
|
||||||
|
|
||||||
GType
|
GType
|
||||||
meta_select_workspace_get_type (void)
|
meta_select_workspace_get_type (void)
|
||||||
@ -869,7 +900,11 @@ meta_select_workspace_class_init (MetaSelectWorkspaceClass *klass)
|
|||||||
|
|
||||||
widget_class = GTK_WIDGET_CLASS (klass);
|
widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
|
||||||
|
#if USE_GTK3
|
||||||
|
widget_class->draw = meta_select_workspace_draw;
|
||||||
|
#else
|
||||||
widget_class->expose_event = meta_select_workspace_expose_event;
|
widget_class->expose_event = meta_select_workspace_expose_event;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -906,16 +941,22 @@ meta_convert_meta_to_wnck (MetaWindow *window, MetaScreen *screen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
static gboolean
|
||||||
|
meta_select_workspace_draw (GtkWidget *widget,
|
||||||
|
cairo_t *cr)
|
||||||
|
{
|
||||||
|
#else /* !USE_GTK3 */
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_select_workspace_expose_event (GtkWidget *widget,
|
meta_select_workspace_expose_event (GtkWidget *widget,
|
||||||
GdkEventExpose *event)
|
GdkEventExpose *event)
|
||||||
{
|
{
|
||||||
|
cairo_t *cr = gdk_cairo_create (event->window);
|
||||||
|
#endif /* !USE_GTK3 */
|
||||||
MetaWorkspace *workspace;
|
MetaWorkspace *workspace;
|
||||||
WnckWindowDisplayInfo *windows;
|
WnckWindowDisplayInfo *windows;
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
GtkStyle *style;
|
GtkStyle *style;
|
||||||
GdkWindow *window;
|
|
||||||
cairo_t *cr;
|
|
||||||
int i, n_windows;
|
int i, n_windows;
|
||||||
GList *tmp, *list;
|
GList *tmp, *list;
|
||||||
|
|
||||||
@ -954,11 +995,8 @@ meta_select_workspace_expose_event (GtkWidget *widget,
|
|||||||
|
|
||||||
g_list_free (list);
|
g_list_free (list);
|
||||||
|
|
||||||
window = gtk_widget_get_window (widget);
|
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
|
||||||
cr = gdk_cairo_create (window);
|
|
||||||
|
|
||||||
wnck_draw_workspace (widget,
|
wnck_draw_workspace (widget,
|
||||||
cr,
|
cr,
|
||||||
SELECT_OUTLINE_WIDTH,
|
SELECT_OUTLINE_WIDTH,
|
||||||
@ -989,8 +1027,9 @@ meta_select_workspace_expose_event (GtkWidget *widget,
|
|||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef USE_GTK3
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "region.h"
|
#include "region.h"
|
||||||
|
|
||||||
|
#include "gdk2-drawing-utils.h"
|
||||||
|
|
||||||
#define OUTLINE_WIDTH 5 /* frame width in non-composite case */
|
#define OUTLINE_WIDTH 5 /* frame width in non-composite case */
|
||||||
|
|
||||||
|
|
||||||
@ -45,17 +47,21 @@ struct _MetaTilePreview {
|
|||||||
gboolean has_alpha: 1;
|
gboolean has_alpha: 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
static gboolean
|
||||||
|
meta_tile_preview_draw (GtkWidget *widget,
|
||||||
|
cairo_t *cr,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
#else
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_tile_preview_expose (GtkWidget *widget,
|
meta_tile_preview_expose (GtkWidget *widget,
|
||||||
GdkEventExpose *event,
|
GdkEventExpose *event,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
cairo_t *cr = gdk_cairo_create (event->window);
|
||||||
|
#endif
|
||||||
MetaTilePreview *preview = user_data;
|
MetaTilePreview *preview = user_data;
|
||||||
GdkWindow *window;
|
|
||||||
cairo_t *cr;
|
|
||||||
|
|
||||||
window = gtk_widget_get_window (widget);
|
|
||||||
cr = gdk_cairo_create (window);
|
|
||||||
|
|
||||||
cairo_set_line_width (cr, 1.0);
|
cairo_set_line_width (cr, 1.0);
|
||||||
|
|
||||||
@ -93,7 +99,9 @@ meta_tile_preview_expose (GtkWidget *widget,
|
|||||||
preview->tile_rect.height - 1);
|
preview->tile_rect.height - 1);
|
||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
|
|
||||||
|
#ifndef USE_GTK3
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
|
#endif
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -134,11 +142,9 @@ meta_tile_preview_new (int screen_number,
|
|||||||
gboolean composited)
|
gboolean composited)
|
||||||
{
|
{
|
||||||
MetaTilePreview *preview;
|
MetaTilePreview *preview;
|
||||||
GdkColormap *rgba_colormap;
|
|
||||||
GdkScreen *screen;
|
GdkScreen *screen;
|
||||||
|
|
||||||
screen = gdk_display_get_screen (gdk_display_get_default (), screen_number);
|
screen = gdk_display_get_screen (gdk_display_get_default (), screen_number);
|
||||||
rgba_colormap = gdk_screen_get_rgba_colormap (screen);
|
|
||||||
|
|
||||||
preview = g_new (MetaTilePreview, 1);
|
preview = g_new (MetaTilePreview, 1);
|
||||||
|
|
||||||
@ -153,11 +159,18 @@ meta_tile_preview_new (int screen_number,
|
|||||||
preview->tile_rect.x = preview->tile_rect.y = 0;
|
preview->tile_rect.x = preview->tile_rect.y = 0;
|
||||||
preview->tile_rect.width = preview->tile_rect.height = 0;
|
preview->tile_rect.width = preview->tile_rect.height = 0;
|
||||||
|
|
||||||
preview->has_alpha = rgba_colormap && composited;
|
preview->has_alpha = composited &&
|
||||||
|
(gdk_screen_get_rgba_visual (screen) != NULL);
|
||||||
|
|
||||||
if (preview->has_alpha)
|
if (preview->has_alpha)
|
||||||
{
|
{
|
||||||
gtk_widget_set_colormap (preview->preview_window, rgba_colormap);
|
#ifdef USE_GTK3
|
||||||
|
gtk_window_set_visual (GTK_WINDOW (preview->preview_window),
|
||||||
|
gdk_screen_get_rgba_visual (screen));
|
||||||
|
#else
|
||||||
|
gtk_widget_set_colormap (preview->preview_window,
|
||||||
|
gdk_screen_get_rgba_colormap (screen));
|
||||||
|
#endif
|
||||||
|
|
||||||
g_signal_connect (preview->preview_window, "style-set",
|
g_signal_connect (preview->preview_window, "style-set",
|
||||||
G_CALLBACK (on_preview_window_style_set), preview);
|
G_CALLBACK (on_preview_window_style_set), preview);
|
||||||
@ -169,11 +182,15 @@ meta_tile_preview_new (int screen_number,
|
|||||||
*/
|
*/
|
||||||
preview->create_serial = XNextRequest (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
|
preview->create_serial = XNextRequest (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
|
||||||
gtk_widget_realize (preview->preview_window);
|
gtk_widget_realize (preview->preview_window);
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
g_signal_connect (preview->preview_window, "draw",
|
||||||
|
G_CALLBACK (meta_tile_preview_draw), preview);
|
||||||
|
#else
|
||||||
gdk_window_set_back_pixmap (gtk_widget_get_window (preview->preview_window),
|
gdk_window_set_back_pixmap (gtk_widget_get_window (preview->preview_window),
|
||||||
NULL, FALSE);
|
NULL, FALSE);
|
||||||
|
|
||||||
g_signal_connect (preview->preview_window, "expose-event",
|
g_signal_connect (preview->preview_window, "expose-event",
|
||||||
G_CALLBACK (meta_tile_preview_expose), preview);
|
G_CALLBACK (meta_tile_preview_expose), preview);
|
||||||
|
#endif
|
||||||
|
|
||||||
return preview;
|
return preview;
|
||||||
}
|
}
|
||||||
|
70
src/ui/ui.c
70
src/ui/ui.c
@ -33,9 +33,11 @@
|
|||||||
|
|
||||||
#include "inlinepixbufs.h"
|
#include "inlinepixbufs.h"
|
||||||
#include "gdk-compat.h"
|
#include "gdk-compat.h"
|
||||||
|
#include "gdk2-drawing-utils.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <cairo-xlib.h>
|
||||||
|
|
||||||
static void meta_stock_icons_init (void);
|
static void meta_stock_icons_init (void);
|
||||||
static void meta_ui_accelerator_parse (const char *accel,
|
static void meta_ui_accelerator_parse (const char *accel,
|
||||||
@ -172,7 +174,9 @@ meta_ui_create_frame_window (MetaUI *ui,
|
|||||||
gint attributes_mask;
|
gint attributes_mask;
|
||||||
GdkWindow *window;
|
GdkWindow *window;
|
||||||
GdkVisual *visual;
|
GdkVisual *visual;
|
||||||
|
#ifndef USE_GTK3
|
||||||
GdkColormap *cmap = gdk_screen_get_default_colormap (screen);
|
GdkColormap *cmap = gdk_screen_get_default_colormap (screen);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Default depth/visual handles clients with weird visuals; they can
|
/* Default depth/visual handles clients with weird visuals; they can
|
||||||
* always be children of the root depth/visual obviously, but
|
* always be children of the root depth/visual obviously, but
|
||||||
@ -185,7 +189,9 @@ meta_ui_create_frame_window (MetaUI *ui,
|
|||||||
{
|
{
|
||||||
visual = gdk_x11_screen_lookup_visual (screen,
|
visual = gdk_x11_screen_lookup_visual (screen,
|
||||||
XVisualIDFromVisual (xvisual));
|
XVisualIDFromVisual (xvisual));
|
||||||
|
#ifndef USE_GTK3
|
||||||
cmap = gdk_colormap_new (visual, FALSE);
|
cmap = gdk_colormap_new (visual, FALSE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
attrs.title = NULL;
|
attrs.title = NULL;
|
||||||
@ -201,7 +207,9 @@ meta_ui_create_frame_window (MetaUI *ui,
|
|||||||
attrs.y = y;
|
attrs.y = y;
|
||||||
attrs.wclass = GDK_INPUT_OUTPUT;
|
attrs.wclass = GDK_INPUT_OUTPUT;
|
||||||
attrs.visual = visual;
|
attrs.visual = visual;
|
||||||
|
#ifndef USE_GTK3
|
||||||
attrs.colormap = cmap;
|
attrs.colormap = cmap;
|
||||||
|
#endif
|
||||||
attrs.window_type = GDK_WINDOW_CHILD;
|
attrs.window_type = GDK_WINDOW_CHILD;
|
||||||
attrs.cursor = NULL;
|
attrs.cursor = NULL;
|
||||||
attrs.wmclass_name = NULL;
|
attrs.wmclass_name = NULL;
|
||||||
@ -211,7 +219,11 @@ meta_ui_create_frame_window (MetaUI *ui,
|
|||||||
attrs.width = width;
|
attrs.width = width;
|
||||||
attrs.height = height;
|
attrs.height = height;
|
||||||
|
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
|
||||||
|
#else
|
||||||
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
|
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* We make an assumption that gdk_window_new() is going to call
|
/* We make an assumption that gdk_window_new() is going to call
|
||||||
* XCreateWindow as it's first operation; this seems to be true currently
|
* XCreateWindow as it's first operation; this seems to be true currently
|
||||||
@ -358,6 +370,63 @@ meta_ui_window_menu_free (MetaWindowMenu *menu)
|
|||||||
meta_window_menu_free (menu);
|
meta_window_menu_free (menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_GTK3
|
||||||
|
GdkPixbuf*
|
||||||
|
meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf *dest,
|
||||||
|
Pixmap xpixmap,
|
||||||
|
int src_x,
|
||||||
|
int src_y,
|
||||||
|
int dest_x,
|
||||||
|
int dest_y,
|
||||||
|
int width,
|
||||||
|
int height)
|
||||||
|
{
|
||||||
|
cairo_surface_t *surface;
|
||||||
|
Display *display;
|
||||||
|
Window root_return;
|
||||||
|
int x_ret, y_ret;
|
||||||
|
unsigned int w_ret, h_ret, bw_ret, depth_ret;
|
||||||
|
XWindowAttributes attrs;
|
||||||
|
GdkPixbuf *retval;
|
||||||
|
|
||||||
|
display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
|
||||||
|
|
||||||
|
if (!XGetGeometry (display, xpixmap, &root_return,
|
||||||
|
&x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (depth_ret == 1)
|
||||||
|
{
|
||||||
|
surface = cairo_xlib_surface_create_for_bitmap (display,
|
||||||
|
xpixmap,
|
||||||
|
GDK_SCREEN_XSCREEN (gdk_screen_get_default ()),
|
||||||
|
w_ret,
|
||||||
|
h_ret);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!XGetWindowAttributes (display, root_return, &attrs))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
surface = cairo_xlib_surface_create (display,
|
||||||
|
xpixmap,
|
||||||
|
attrs.visual,
|
||||||
|
w_ret, h_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
retval = gdk_pixbuf_get_from_surface (dest,
|
||||||
|
surface,
|
||||||
|
src_x,
|
||||||
|
src_y,
|
||||||
|
dest_x,
|
||||||
|
dest_y,
|
||||||
|
width,
|
||||||
|
height);
|
||||||
|
cairo_surface_destroy (surface);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
#else /* !USE_GTK3 */
|
||||||
static GdkColormap*
|
static GdkColormap*
|
||||||
get_cmap (GdkPixmap *pixmap)
|
get_cmap (GdkPixmap *pixmap)
|
||||||
{
|
{
|
||||||
@ -437,6 +506,7 @@ meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf *dest,
|
|||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
#endif /* !USE_GTK3 */
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_ui_push_delay_exposes (MetaUI *ui)
|
meta_ui_push_delay_exposes (MetaUI *ui)
|
||||||
|
Loading…
Reference in New Issue
Block a user