Commit c659d1a5 authored by Johannes Schmid's avatar Johannes Schmid

Merge branch 'master' into native-layout

parents e08d04b5 182108c6
......@@ -41,10 +41,8 @@ a GtkBuilder UI definition.
@g_iface: the parent class
@set_name: Stores the name attribute given in the GtkBuilder UI definition.
#GtkWidget maps this to the #GtkWidget:name property, and
gtk_buildable_set_name() has a fallback implementation that stores
the name as object data. Implement this method if your object
has some notion of "name" and it makes sense to map the XML name
#GtkWidget stores the name as object data. Implement this method if your
object has some notion of "name" and it makes sense to map the XML name
attribute to it.
@get_name: The getter corresponding to @set_name. Implement this
if you implement @set_name.
......
......@@ -86,6 +86,14 @@ gdk_screen_get_n_monitors (GdkScreen *screen)
return 1;
}
gint
gdk_screen_get_primary_monitor (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return 0;
}
void
gdk_screen_get_monitor_geometry (GdkScreen *screen,
gint num_monitor,
......
......@@ -1074,12 +1074,13 @@ gdk_screen_get_width_mm
gdk_screen_get_height
gdk_screen_get_height_mm
gdk_screen_get_number
gdk_screen_get_primary_monitor
gdk_screen_get_root_window
gdk_screen_get_default_colormap
gdk_screen_set_default_colormap
gdk_screen_get_n_monitors
gdk_screen_get_monitor_geometry
gdk_screen_get_monitor_width_mm
gdk_screen_get_monitor_width_mm
gdk_screen_get_monitor_height_mm
gdk_screen_get_monitor_plug_name
gdk_screen_get_rgba_colormap
......
......@@ -257,7 +257,8 @@ gdk_offscreen_window_get_visual (GdkDrawable *drawable)
static void
add_damage (GdkOffscreenWindow *offscreen,
int x, int y,
int w, int h)
int w, int h,
gboolean is_line)
{
GdkRectangle rect;
GdkRegion *damage;
......@@ -267,6 +268,26 @@ add_damage (GdkOffscreenWindow *offscreen,
rect.width = w;
rect.height = h;
if (is_line)
{
/* This should really take into account line width, line
* joins (and miter) and line caps. But these are hard
* to compute, rarely used and generally a pain. And in
* the end a snug damage rectangle is not that important
* as multiple damages are generally created anyway.
*
* So, we just add some padding around the rect.
* We use a padding of 3 pixels, plus an extra row
* below and on the right for the normal line size. I.E.
* line from (0,0) to (2,0) gets h=0 but is really
* at least one pixel tall.
*/
rect.x -= 3;
rect.y -= 3;
rect.width += 7;
rect.height += 7;
}
damage = gdk_region_rectangle (&rect);
_gdk_window_add_damage (offscreen->wrapper, damage);
gdk_region_destroy (damage);
......@@ -300,7 +321,7 @@ gdk_offscreen_window_draw_drawable (GdkDrawable *drawable,
xdest, ydest,
width, height);
add_damage (offscreen, xdest, ydest, width, height);
add_damage (offscreen, xdest, ydest, width, height, FALSE);
}
static void
......@@ -318,7 +339,7 @@ gdk_offscreen_window_draw_rectangle (GdkDrawable *drawable,
gdk_draw_rectangle (real_drawable,
gc, filled, x, y, width, height);
add_damage (offscreen, x, y, width, height);
add_damage (offscreen, x, y, width, height, !filled);
}
......@@ -345,7 +366,7 @@ gdk_offscreen_window_draw_arc (GdkDrawable *drawable,
height,
angle1,
angle2);
add_damage (offscreen, x, y, width, height);
add_damage (offscreen, x, y, width, height, !filled);
}
static void
......@@ -381,7 +402,7 @@ gdk_offscreen_window_draw_polygon (GdkDrawable *drawable,
add_damage (offscreen, min_x, min_y,
max_x - min_x,
max_y - min_y);
max_y - min_y, !filled);
}
}
......@@ -407,7 +428,7 @@ gdk_offscreen_window_draw_text (GdkDrawable *drawable,
text_length);
/* Hard to compute the minimal size, not that often used anyway. */
add_damage (offscreen, 0, 0, private->width, private->height);
add_damage (offscreen, 0, 0, private->width, private->height, FALSE);
}
static void
......@@ -432,7 +453,7 @@ gdk_offscreen_window_draw_text_wc (GdkDrawable *drawable,
text_length);
/* Hard to compute the minimal size, not that often used anyway. */
add_damage (offscreen, 0, 0, private->width, private->height);
add_damage (offscreen, 0, 0, private->width, private->height, FALSE);
}
static void
......@@ -466,8 +487,9 @@ gdk_offscreen_window_draw_points (GdkDrawable *drawable,
}
add_damage (offscreen, min_x, min_y,
max_x - min_x,
max_y - min_y);
max_x - min_x + 1,
max_y - min_y + 1,
FALSE);
}
}
......@@ -506,7 +528,7 @@ gdk_offscreen_window_draw_segments (GdkDrawable *drawable,
add_damage (offscreen, min_x, min_y,
max_x - min_x,
max_y - min_y);
max_y - min_y, TRUE);
}
}
......@@ -529,7 +551,7 @@ gdk_offscreen_window_draw_lines (GdkDrawable *drawable,
/* Hard to compute the minimal size, as we don't know the line
width, and since joins are hard to calculate.
Its not that often used anyway, damage it all */
add_damage (offscreen, 0, 0, private->width, private->height);
add_damage (offscreen, 0, 0, private->width, private->height, TRUE);
}
static void
......@@ -556,7 +578,7 @@ gdk_offscreen_window_draw_image (GdkDrawable *drawable,
width,
height);
add_damage (offscreen, xdest, ydest, width, height);
add_damage (offscreen, xdest, ydest, width, height, FALSE);
}
......@@ -590,7 +612,7 @@ gdk_offscreen_window_draw_pixbuf (GdkDrawable *drawable,
x_dither,
y_dither);
add_damage (offscreen, dest_x, dest_y, width, height);
add_damage (offscreen, dest_x, dest_y, width, height, FALSE);
}
......@@ -637,6 +659,7 @@ _gdk_offscreen_window_new (GdkWindow *window,
private->width,
private->height,
private->depth);
gdk_drawable_set_colormap (offscreen->pixmap, offscreen->colormap);
}
static gboolean
......
......@@ -91,6 +91,7 @@ GList * gdk_screen_get_toplevel_windows (GdkScreen *screen);
gchar * gdk_screen_make_display_name (GdkScreen *screen);
gint gdk_screen_get_n_monitors (GdkScreen *screen);
gint gdk_screen_get_primary_monitor (GdkScreen *screen);
void gdk_screen_get_monitor_geometry (GdkScreen *screen,
gint monitor_num,
GdkRectangle *dest);
......
......@@ -1181,14 +1181,12 @@ get_native_event_mask (GdkWindowObject *private)
/* Do whatever the app asks to, since the app
* may be asking for weird things for native windows,
* but filter out things that override the special
* requests below. */
mask = private->event_mask &
~(GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_MOTION_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON2_MOTION_MASK |
GDK_BUTTON3_MOTION_MASK);
* but don't use motion hints as that may affect non-native
* child windows that don't want it. Also, we need to
* set all the app-specified masks since they will be picked
* up by any implicit grabs (i.e. if they were not set as
* native we would not get the events we need). */
mask = private->event_mask & ~GDK_POINTER_MOTION_HINT_MASK;
/* We need thse for all native windows so we can
emulate events on children: */
......@@ -1228,11 +1226,7 @@ get_native_grab_event_mask (GdkEventMask grab_mask)
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
GDK_SCROLL_MASK |
(grab_mask &
~(GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_MOTION_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON2_MOTION_MASK |
GDK_BUTTON3_MOTION_MASK));
~GDK_POINTER_MOTION_HINT_MASK);
}
/* Puts the native window in the right order wrt the other native windows
......@@ -1737,6 +1731,67 @@ gdk_window_reparent (GdkWindow *window,
_gdk_synthesize_crossing_events_for_geometry_change (window);
}
static gboolean
temporary_disable_extension_events (GdkWindowObject *window)
{
GdkWindowObject *child;
GList *l;
gboolean res;
if (window->extension_events != 0)
{
g_object_set_data (G_OBJECT (window),
"gdk-window-extension-events",
GINT_TO_POINTER (window->extension_events));
gdk_input_set_extension_events ((GdkWindow *)window, 0,
GDK_EXTENSION_EVENTS_NONE);
}
else
res = FALSE;
for (l = window->children; l != NULL; l = l->next)
{
child = l->data;
if (window->impl_window == child->impl_window)
res |= temporary_disable_extension_events (window);
}
return res;
}
static void
reenable_extension_events (GdkWindowObject *window)
{
GdkWindowObject *child;
GList *l;
int mask;
mask = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window),
"gdk-window-extension-events"));
if (mask != 0)
{
/* We don't have the mode here, so we pass in cursor.
This works with the current code since mode is not
stored except as part of the mask, and cursor doesn't
change the mask. */
gdk_input_set_extension_events ((GdkWindow *)window, mask,
GDK_EXTENSION_EVENTS_CURSOR);
g_object_set_data (G_OBJECT (window),
"gdk-window-extension-events",
NULL);
}
for (l = window->children; l != NULL; l = l->next)
{
child = l->data;
if (window->impl_window == child->impl_window)
reenable_extension_events (window);
}
}
/**
* gdk_window_ensure_native:
* @window: a #GdkWindow
......@@ -1764,6 +1819,7 @@ gdk_window_ensure_native (GdkWindow *window)
GdkWindowObject *above;
GList listhead;
GdkWindowImplIface *impl_iface;
gboolean disabled_extension_events;
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
......@@ -1784,6 +1840,12 @@ gdk_window_ensure_native (GdkWindow *window)
/* Need to create a native window */
/* First we disable any extension events on the window or its
descendants to handle the native input window moving */
disabled_extension_events = FALSE;
if (impl_window->input_window)
disabled_extension_events = temporary_disable_extension_events (private);
screen = gdk_drawable_get_screen (window);
visual = gdk_drawable_get_visual (window);
......@@ -1837,6 +1899,9 @@ gdk_window_ensure_native (GdkWindow *window)
if (gdk_window_is_viewable (window))
impl_iface->show (window, FALSE);
if (disabled_extension_events)
reenable_extension_events (private);
return TRUE;
}
......@@ -2546,6 +2611,14 @@ gdk_window_begin_implicit_paint (GdkWindow *window, GdkRectangle *rect)
private->implicit_paint != NULL)
return FALSE; /* Don't stack implicit paints */
/* Never do implicit paints for foreign windows, they don't need
* double buffer combination since they have no client side children,
* and creating pixmaps for them is risky since they could disappear
* at any time
*/
if (private->window_type == GDK_WINDOW_FOREIGN)
return FALSE;
paint = g_new (GdkWindowPaint, 1);
paint->region = gdk_region_new (); /* Empty */
paint->x_offset = rect->x;
......
......@@ -404,7 +404,7 @@ gdk_screen_get_height_mm (GdkScreen *screen)
GDK_SCREEN_QUARTZ (screen)->height);
}
int
gint
gdk_screen_get_n_monitors (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
......@@ -412,6 +412,14 @@ gdk_screen_get_n_monitors (GdkScreen *screen)
return GDK_SCREEN_QUARTZ (screen)->n_screens;
}
gint
gdk_screen_get_primary_monitor (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return 0;
}
gint
gdk_screen_get_monitor_width_mm (GdkScreen *screen,
gint monitor_num)
......
......@@ -66,6 +66,14 @@ gdk_screen_get_n_monitors (GdkScreen *screen)
return _gdk_num_monitors;
}
gint
gdk_screen_get_primary_monitor (GdkScreen *screen)
{
g_return_val_if_fail (screen == _gdk_screen, 0);
return 0;
}
gint
gdk_screen_get_monitor_width_mm (GdkScreen *screen,
gint num_monitor)
......
......@@ -354,6 +354,31 @@ gdk_screen_get_n_monitors (GdkScreen *screen)
return GDK_SCREEN_X11 (screen)->n_monitors;
}
/**
* gdk_screen_get_primary_monitor:
* @screen: a #GdkScreen.
*
* Gets the primary monitor for @screen. The primary monitor
* is considered the monitor where the 'main desktop' lives.
* While normal application windows typically allow the window
* manager to place the windows, specialized desktop applications
* such as panels should place themselves on the primary monitor.
*
* If no primary monitor is configured by the user, the return value
* will be 0, defaulting to the first monitor.
*
* Returns: An integer index for the primary monitor, or 0 if none is configured.
*
* Since: 2.20
*/
gint
gdk_screen_get_primary_monitor (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return GDK_SCREEN_X11 (screen)->primary_monitor;
}
/**
* gdk_screen_get_monitor_width_mm:
* @screen: a #GdkScreen
......@@ -722,6 +747,7 @@ init_randr13 (GdkScreen *screen)
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
Display *dpy = GDK_SCREEN_XDISPLAY (screen);
XRRScreenResources *resources;
RROutput primary_output;
int i;
GArray *monitors;
gboolean randr12_compat = FALSE;
......@@ -733,15 +759,23 @@ init_randr13 (GdkScreen *screen)
screen_x11->xroot_window);
if (!resources)
return FALSE;
monitors = g_array_sized_new (FALSE, TRUE, sizeof (GdkX11Monitor),
resources->noutput);
primary_output = XRRGetOutputPrimary (screen_x11->xdisplay,
screen_x11->xroot_window);
for (i = 0; i < resources->noutput; ++i)
{
XRROutputInfo *output =
XRRGetOutputInfo (dpy, resources, resources->outputs[i]);
if (resources->outputs[i] == primary_output)
{
screen_x11->primary_monitor = i;
}
/* Non RandR1.2 X driver have output name "default" */
randr12_compat |= !g_strcmp0(output->name, "default");
......@@ -1110,7 +1144,10 @@ _gdk_x11_screen_size_changed (GdkScreen *screen,
display_x11 = GDK_DISPLAY_X11 (gdk_screen_get_display (screen));
if (display_x11->have_randr13 && event->type == ConfigureNotify)
return;
{
g_signal_emit_by_name (screen, "monitors-changed");
return;
}
XRRUpdateConfiguration (event);
#else
......
......@@ -93,6 +93,7 @@ struct _GdkScreenX11
/* Xinerama/RandR 1.2 */
gint n_monitors;
GdkX11Monitor *monitors;
gint primary_monitor;
/* Pango renderer object singleton */
PangoRenderer *renderer;
......
......@@ -3256,7 +3256,7 @@ _gdk_windowing_window_at_pointer (GdkDisplay *display,
xwindow_last = xwindow;
XQueryPointer (xdisplay, xwindow,
&root, &xwindow, &rootx, &rooty, &winx, &winy, &xmask);
if (get_toplevel &&
if (get_toplevel && xwindow_last != root &&
(window = gdk_window_lookup_for_display (display, xwindow_last)) != NULL &&
GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
{
......@@ -3326,7 +3326,7 @@ _gdk_windowing_window_at_pointer (GdkDisplay *display,
gdk_flush ();
if (gdk_error_trap_pop ())
break;
if (get_toplevel &&
if (get_toplevel && xwindow_last != root &&
(window = gdk_window_lookup_for_display (display, xwindow_last)) != NULL &&
GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
break;
......
......@@ -2938,6 +2938,7 @@ gtk_print_context_get_width
gtk_print_context_get_height
gtk_print_context_get_dpi_x
gtk_print_context_get_dpi_y
gtk_print_context_get_hard_margins
gtk_print_context_get_pango_fontmap
gtk_print_context_create_pango_context
gtk_print_context_create_pango_layout
......
......@@ -50,7 +50,7 @@ struct _GtkAccessible
* The GtkWidget whose properties and features are exported via this
* accessible instance.
*/
GtkWidget *widget;
GtkWidget *GSEAL (widget);
};
struct _GtkAccessibleClass
......
......@@ -55,7 +55,8 @@ struct _GtkAssistantPage
{
GtkWidget *page;
GtkAssistantPageType type;
gboolean complete;
guint complete : 1;
guint complete_set : 1;
GtkWidget *title;
GdkPixbuf *header_image;
......@@ -136,6 +137,8 @@ static void gtk_assistant_buildable_custom_finished (GtkBuildable *bui
const gchar *tagname,
gpointer user_data);
static GList* find_page (GtkAssistant *assistant,
GtkWidget *page);
enum
{
......@@ -516,7 +519,7 @@ set_assistant_buttons_state (GtkAssistant *assistant)
compute_last_button_state (assistant);
break;
case GTK_ASSISTANT_PAGE_SUMMARY:
gtk_widget_set_sensitive (assistant->close, TRUE);
gtk_widget_set_sensitive (assistant->close, priv->current_page->complete);
gtk_widget_grab_default (assistant->close);
gtk_widget_show (assistant->close);
gtk_widget_hide (assistant->cancel);
......@@ -1928,6 +1931,13 @@ gtk_assistant_set_page_type (GtkAssistant *assistant,
{
page_info->type = type;
/* backwards compatibility to the era before fixing bug 604289 */
if (type == GTK_ASSISTANT_PAGE_SUMMARY && !page_info->complete_set)
{
gtk_assistant_set_page_complete (assistant, page, TRUE);
page_info->complete_set = FALSE;
}
/* Always set buttons state, a change in a future page
might change current page buttons */
set_assistant_buttons_state (assistant);
......@@ -2159,6 +2169,7 @@ gtk_assistant_set_page_complete (GtkAssistant *assistant,
if (complete != page_info->complete)
{
page_info->complete = complete;
page_info->complete_set = TRUE;
/* Always set buttons state, a change in a future page
might change current page buttons */
......
......@@ -2137,12 +2137,23 @@ static void
gtk_button_screen_changed (GtkWidget *widget,
GdkScreen *previous_screen)
{
GtkButton *button;
GtkSettings *settings;
guint show_image_connection;
if (!gtk_widget_has_screen (widget))
return;
button = GTK_BUTTON (widget);
/* If the button is being pressed while the screen changes the
release might never occur, so we reset the state. */
if (button->button_down)
{
button->button_down = FALSE;
gtk_button_update_state (button);
}
settings = gtk_widget_get_settings (widget);
show_image_connection =
......@@ -2159,7 +2170,7 @@ gtk_button_screen_changed (GtkWidget *widget,
I_("gtk-button-connection"),
GUINT_TO_POINTER (show_image_connection));
show_image_change_notify (GTK_BUTTON (widget));
show_image_change_notify (button);
}
static void
......
......@@ -331,8 +331,10 @@ gtk_cell_renderer_combo_editing_done (GtkCellEditable *combo,
g_signal_handler_disconnect (combo, cell->focus_out_id);
cell->focus_out_id = 0;
}
canceled = _gtk_combo_box_editing_canceled (GTK_COMBO_BOX (combo));
g_object_get (combo,
"editing-canceled", &canceled,
NULL);
gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (data), canceled);
if (canceled)
{
......
......@@ -230,7 +230,9 @@ gtk_cell_renderer_spin_focus_out_event (GtkWidget *widget,
const gchar *new_text;
gboolean canceled;
canceled = GTK_ENTRY (widget)->editing_canceled;
g_object_get (widget,
"editing-canceled", &canceled,
NULL);
g_signal_handlers_disconnect_by_func (widget,
gtk_cell_renderer_spin_focus_out_event,
......
......@@ -1701,6 +1701,7 @@ gtk_cell_renderer_text_editing_done (GtkCellEditable *entry,
{
const gchar *path;
const gchar *new_text;
gboolean canceled;
GtkCellRendererTextPrivate *priv;
priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (data);
......@@ -1725,9 +1726,12 @@ gtk_cell_renderer_text_editing_done (GtkCellEditable *entry,
priv->entry_menu_popdown_timeout = 0;
}
gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (data),
GTK_ENTRY (entry)->editing_canceled);
if (GTK_ENTRY (entry)->editing_canceled)
g_object_get (entry,
"editing-canceled", &canceled,
NULL);
gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (data), canceled);
if (canceled)
return;
path = g_object_get_data (G_OBJECT (entry), GTK_CELL_RENDERER_TEXT_PATH);
......@@ -1801,7 +1805,9 @@ gtk_cell_renderer_text_focus_out_event (GtkWidget *entry,
if (priv->in_entry_menu)
return FALSE;
GTK_ENTRY (entry)->editing_canceled = TRUE;
g_object_set (entry,
"editing-canceled", TRUE,
NULL);
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (entry));
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (entry));
......
......@@ -3198,7 +3198,9 @@ gtk_combo_box_menu_item_activate (GtkWidget *item,
gtk_tree_path_free (path);
combo_box->priv->editing_canceled = FALSE;
g_object_set (combo_box,
"editing-canceled", FALSE,
NULL);
}
static void
......@@ -5510,8 +5512,9 @@ gtk_cell_editable_key_press (GtkWidget *widget,
if (event->keyval == GDK_Escape)
{
combo_box->priv->editing_canceled = TRUE;
g_object_set (combo_box,
"editing-canceled", TRUE,
NULL);
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (combo_box));
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (combo_box));
......@@ -5566,7 +5569,9 @@ popup_idle (gpointer data)
combo_box, 0);
/* we unset this if a menu item is activated */
combo_box->priv->editing_canceled = TRUE;
g_object_set (combo_box,
"editing-canceled", TRUE,
NULL);
gtk_combo_box_popup (combo_box);
combo_box->priv->popup_idle_id = 0;
......@@ -5727,14 +5732,6 @@ gtk_combo_box_set_title (GtkComboBox *combo_box,
}
}
gboolean
_gtk_combo_box_editing_canceled (GtkComboBox *combo_box)
{
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), TRUE);
return combo_box->priv->editing_canceled;
}
/**
* gtk_combo_box_get_popup_accessible:
* @combo_box: a #GtkComboBox
......
......@@ -136,8 +136,6 @@ void gtk_combo_box_popup (GtkComboBox *combo_box);