Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c82fd5c4c | |||
| 0d63fdadfe | |||
| 3086970654 |
@@ -21,7 +21,7 @@ Overview of Changes in GTK+ 3.15.1
|
||||
739001 Fix Build of broadwayd on Visual Studio
|
||||
739005 gtkstatusicon.c won't build with both X11 and Quartz backen...
|
||||
739111 GtkFontChooserDialog fixes
|
||||
739150 Dragging bookmark crashes nautilus
|
||||
739150 Dragging bookmark crashes nautilus
|
||||
|
||||
Translation updates:
|
||||
Czech
|
||||
|
||||
@@ -33,7 +33,7 @@ echo $(Configuration) > ..\..\..\MSVC_$(Configuration)
|
||||
:DONE_GDKCONFIG_H
|
||||
</GenGdkConfigHWin32>
|
||||
<GenGdkConfigHBroadway>
|
||||
if exist ..\..\..\MSVC_$(Configuration)_Broadway goto DONE_GDKCONFIG_H
|
||||
if exist ..\..\..\MSVC_$(Configuration) goto DONE_GDKCONFIG_H
|
||||
|
||||
|
||||
if exist ..\..\..\gdk\gdkconfig.h del ..\..\..\gdk\gdkconfig.h
|
||||
@@ -53,7 +53,7 @@ copy ..\..\..\gdk\gdkconfig.h.win32_broadway ..\..\..\gdk\gdkconfig.h
|
||||
|
||||
copy ..\..\..\gdk\gdkconfig.h.win32_broadway ..\..\..\GDK_BROADWAY_BUILD
|
||||
|
||||
echo $(Configuration) > ..\..\..\MSVC_$(Configuration)_Broadway
|
||||
echo $(Configuration) > ..\..\..\MSVC_$(Configuration)
|
||||
|
||||
:DONE_GDKCONFIG_H
|
||||
</GenGdkConfigHBroadway>
|
||||
|
||||
@@ -36,7 +36,7 @@ echo $(ConfigurationName) > ..\..\..\MSVC_$(ConfigurationName)

|
||||
<UserMacro
|
||||
Name="GenGdkConfigHBroadway"
|
||||
Value="
|
||||
if exist ..\..\..\MSVC_$(ConfigurationName)_Broadway goto DONE_GDKCONFIG_H

|
||||
if exist ..\..\..\MSVC_$(ConfigurationName) goto DONE_GDKCONFIG_H

|
||||
|
||||
if exist ..\..\..\gdk\gdkconfig.h del ..\..\..\gdk\gdkconfig.h

|
||||
if exist ..\..\..\GDK_WIN32ONLY_BUILD del ..\..\..\GDK_WIN32ONLY_BUILD

|
||||
@@ -50,7 +50,7 @@ if "$(ConfigurationName)" == "Debug_Broadway" del ..\..\..\M
|
||||
copy ..\..\..\gdk\gdkconfig.h.win32_broadway ..\..\..\gdk\gdkconfig.h

|
||||
copy ..\..\..\gdk\gdkconfig.h.win32_broadway ..\..\..\GDK_BROADWAY_BUILD

|
||||
|
||||
echo $(ConfigurationName) > ..\..\..\MSVC_$(ConfigurationName)_Broadway

|
||||
echo $(ConfigurationName) > ..\..\..\MSVC_$(ConfigurationName)

|
||||
:DONE_GDKCONFIG_H

|
||||
"
|
||||
/>
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
/* Define to 1 if you have the `bind_textdomain_codeset' function. */
|
||||
#define HAVE_BIND_TEXTDOMAIN_CODESET 1
|
||||
|
||||
/* Define to 1 if you have the `cairo_surface_set_device_scale' function. */
|
||||
/* #undef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE */
|
||||
|
||||
/* define if we have colord */
|
||||
/* #undef HAVE_COLORD */
|
||||
|
||||
|
||||
+14
-20
@@ -43,12 +43,11 @@ m4_define([gtk_binary_version], [3.0.0])
|
||||
# required versions of other packages
|
||||
m4_define([glib_required_version], [2.43.0])
|
||||
m4_define([pango_required_version], [1.36.7])
|
||||
m4_define([atk_required_version], [2.15.1])
|
||||
m4_define([cairo_required_version], [1.14.0])
|
||||
m4_define([atk_required_version], [2.12.0])
|
||||
m4_define([cairo_required_version], [1.12.0])
|
||||
m4_define([gdk_pixbuf_required_version], [2.30.0])
|
||||
m4_define([introspection_required_version], [1.39.0])
|
||||
m4_define([wayland_required_version], [1.5.91])
|
||||
m4_define([mirclient_required_version], [0.9.0])
|
||||
m4_define([epoxy_required_version], [1.0])
|
||||
GLIB_REQUIRED_VERSION=glib_required_version
|
||||
PANGO_REQUIRED_VERSION=pango_required_version
|
||||
@@ -310,10 +309,6 @@ AC_ARG_ENABLE(xdamage,
|
||||
[AS_HELP_STRING([--enable-xdamage],
|
||||
[support X Damage extension [default=maybe]])],,
|
||||
[enable_xdamage="maybe"])
|
||||
AC_ARG_ENABLE(xpresent,
|
||||
[AS_HELP_STRING([--enable-xpresent],
|
||||
[support X Present extension [default=maybe]])],,
|
||||
[enable_xpresent="maybe"])
|
||||
|
||||
AC_ARG_ENABLE(x11-backend,
|
||||
[AS_HELP_STRING([--enable-x11-backend],
|
||||
@@ -469,7 +464,7 @@ else
|
||||
AM_CONDITIONAL(USE_WAYLAND, false)
|
||||
fi
|
||||
|
||||
MIR_DEPENDENCIES="mirclient >= mirclient_required_version"
|
||||
MIR_DEPENDENCIES="mirclient"
|
||||
if test "$enable_mir_backend" = "maybe" ; then
|
||||
PKG_CHECK_EXISTS($MIR_DEPENDENCIES, [have_mir_deps=yes], [have_mir_deps=no])
|
||||
AC_MSG_CHECKING([for MIR_DEPENDENCIES])
|
||||
@@ -1290,18 +1285,6 @@ if test "x$enable_x11_backend" = xyes; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x"$enable_xpresent" != xno; then
|
||||
if $PKG_CONFIG --exists xcb-present ; then
|
||||
AC_DEFINE(HAVE_PRESENT, 1, [Have the Present X extension])
|
||||
|
||||
X_PACKAGES="$X_PACKAGES xcb-present"
|
||||
X_EXTENSIONS="$X_EXTENSIONS Present"
|
||||
GTK_PACKAGES_FOR_X="$GTK_PACKAGES_FOR_X xcb-present"
|
||||
elif test x"$enable_xpresent" = xyes; then
|
||||
AC_MSG_ERROR([Present support requested but xcb-present not found])
|
||||
fi
|
||||
fi
|
||||
|
||||
if $have_base_x_pc ; then
|
||||
GDK_EXTRA_LIBS="$x_extra_libs"
|
||||
else
|
||||
@@ -1359,6 +1342,17 @@ else
|
||||
LIBS="$gtk_save_LIBS"
|
||||
fi
|
||||
|
||||
# Check for cairo_set_device_scale, as we don't want to depend hard on
|
||||
# this until there is a stable release with it
|
||||
CAIRO_CFLAGS=`$PKG_CONFIG --cflags cairo`
|
||||
CAIRO_LIBS=`$PKG_CONFIG --libs cairo`
|
||||
CFLAGS="$CFLAGS $CAIRO_CFLAGS"
|
||||
gtk_save_LIBS="$LIBS"
|
||||
LIBS="$CAIRO_LIBS $LIBS"
|
||||
AC_CHECK_FUNCS(cairo_surface_set_device_scale)
|
||||
LIBS="$gtk_save_LIBS"
|
||||
|
||||
|
||||
CFLAGS="$saved_cflags"
|
||||
LDFLAGS="$saved_ldflags"
|
||||
|
||||
|
||||
@@ -239,8 +239,8 @@ do_hypertext (GtkWidget *do_widget)
|
||||
GtkWidget *sw;
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
hand_cursor = gdk_cursor_new_for_display (gtk_widget_get_display (do_widget), GDK_HAND2);
|
||||
regular_cursor = gdk_cursor_new_for_display (gtk_widget_get_display (do_widget), GDK_XTERM);
|
||||
hand_cursor = gdk_cursor_new (GDK_HAND2);
|
||||
regular_cursor = gdk_cursor_new (GDK_XTERM);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
|
||||
+5
-42
@@ -772,53 +772,19 @@ load_file (const gchar *demoname,
|
||||
case 3:
|
||||
/* Reading program body */
|
||||
gtk_text_buffer_insert (source_buffer, &start, p, -1);
|
||||
if (lines[i+1] != NULL)
|
||||
gtk_text_buffer_insert (source_buffer, &start, "\n", 1);
|
||||
gtk_text_buffer_insert (source_buffer, &start, "\n", 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_strfreev (lines);
|
||||
|
||||
fontify (source_buffer);
|
||||
|
||||
gtk_text_buffer_create_tag (source_buffer, "top-margin",
|
||||
"pixels-above-lines", 20,
|
||||
NULL);
|
||||
gtk_text_buffer_get_start_iter (source_buffer, &start);
|
||||
end = start;
|
||||
gtk_text_iter_forward_word_end (&end);
|
||||
gtk_text_buffer_apply_tag_by_name (source_buffer, "top-margin", &start, &end);
|
||||
|
||||
gtk_text_buffer_create_tag (source_buffer, "bottom-margin",
|
||||
"pixels-below-lines", 20,
|
||||
NULL);
|
||||
gtk_text_buffer_get_end_iter (source_buffer, &end);
|
||||
start = end;
|
||||
gtk_text_iter_backward_word_start (&start);
|
||||
gtk_text_buffer_apply_tag_by_name (source_buffer, "bottom-margin", &start, &end);
|
||||
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (source_view), source_buffer);
|
||||
g_object_unref (source_buffer);
|
||||
|
||||
gtk_text_buffer_create_tag (info_buffer, "top-margin",
|
||||
"pixels-above-lines", 20,
|
||||
NULL);
|
||||
gtk_text_buffer_get_start_iter (info_buffer, &start);
|
||||
end = start;
|
||||
gtk_text_iter_forward_word_end (&end);
|
||||
gtk_text_buffer_apply_tag_by_name (info_buffer, "top-margin", &start, &end);
|
||||
|
||||
gtk_text_buffer_create_tag (info_buffer, "bottom-margin",
|
||||
"pixels-below-lines", 20,
|
||||
NULL);
|
||||
gtk_text_buffer_get_end_iter (info_buffer, &end);
|
||||
start = end;
|
||||
gtk_text_iter_backward_word_start (&start);
|
||||
gtk_text_buffer_apply_tag_by_name (info_buffer, "bottom-margin", &start, &end);
|
||||
g_strfreev (lines);
|
||||
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (info_view), info_buffer);
|
||||
g_object_unref (info_buffer);
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (source_view), source_buffer);
|
||||
g_object_unref (source_buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -864,10 +830,7 @@ create_text (GtkWidget **view,
|
||||
GTK_SHADOW_NONE);
|
||||
|
||||
*view = text_view = gtk_text_view_new ();
|
||||
g_object_set (text_view,
|
||||
"left-margin", 20,
|
||||
"right-margin", 20,
|
||||
NULL);
|
||||
g_object_set (text_view, "margin", 20, NULL);
|
||||
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE);
|
||||
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (text_view), FALSE);
|
||||
|
||||
@@ -133,8 +133,10 @@
|
||||
<object class="GtkTextView" id="info-textview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="left-margin">20</property>
|
||||
<property name="right-margin">20</property>
|
||||
<property name="margin_start">20</property>
|
||||
<property name="margin_end">20</property>
|
||||
<property name="margin_top">20</property>
|
||||
<property name="margin_bottom">20</property>
|
||||
<property name="pixels_above_lines">2</property>
|
||||
<property name="pixels_below_lines">2</property>
|
||||
<property name="editable">False</property>
|
||||
@@ -168,8 +170,10 @@
|
||||
<object class="GtkTextView" id="source-textview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="left-margin">20</property>
|
||||
<property name="right-margin">20</property>
|
||||
<property name="margin_start">20</property>
|
||||
<property name="margin_end">20</property>
|
||||
<property name="margin_top">20</property>
|
||||
<property name="margin_bottom">20</property>
|
||||
<property name="editable">False</property>
|
||||
<property name="cursor_visible">False</property>
|
||||
</object>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#include <string.h>
|
||||
#include "iconbrowserapp.h"
|
||||
#include "iconbrowserwin.h"
|
||||
#include <gtk/gtk.h>
|
||||
@@ -52,7 +51,7 @@ enum {
|
||||
G_DEFINE_TYPE(IconBrowserWindow, icon_browser_window, GTK_TYPE_APPLICATION_WINDOW);
|
||||
|
||||
static void
|
||||
search_text_changed (GtkEntry *entry, IconBrowserWindow *win)
|
||||
search_text_changed (GtkEntry *entry)
|
||||
{
|
||||
const gchar *text;
|
||||
|
||||
@@ -60,8 +59,6 @@ search_text_changed (GtkEntry *entry, IconBrowserWindow *win)
|
||||
|
||||
if (text[0] == '\0')
|
||||
return;
|
||||
|
||||
gtk_tree_model_filter_refilter (win->filter_model);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -194,8 +191,6 @@ selected_context_changed (GtkListBox *list, IconBrowserWindow *win)
|
||||
if (row == NULL)
|
||||
return;
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (win->search), FALSE);
|
||||
|
||||
label = gtk_bin_get_child (GTK_BIN (row));
|
||||
win->current_context = g_object_get_data (G_OBJECT (label), "context");
|
||||
gtk_tree_model_filter_refilter (win->filter_model);
|
||||
@@ -676,13 +671,11 @@ populate (IconBrowserWindow *win)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
key_press_event_cb (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
key_press_event_cb (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GtkSearchBar *bar)
|
||||
{
|
||||
IconBrowserWindow *win = data;
|
||||
|
||||
return gtk_search_bar_handle_event (GTK_SEARCH_BAR (win->searchbar), event);
|
||||
return gtk_search_bar_handle_event (bar, event);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -694,13 +687,8 @@ icon_visible_func (GtkTreeModel *model,
|
||||
gchar *context;
|
||||
gchar *name;
|
||||
gint column;
|
||||
gboolean search;
|
||||
const gchar *search_text;
|
||||
gboolean visible;
|
||||
|
||||
search = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (win->search));
|
||||
search_text = gtk_entry_get_text (GTK_ENTRY (win->searchentry));
|
||||
|
||||
if (win->symbolic)
|
||||
column = SYMBOLIC_NAME_COLUMN;
|
||||
else
|
||||
@@ -710,12 +698,8 @@ icon_visible_func (GtkTreeModel *model,
|
||||
column, &name,
|
||||
CONTEXT_COLUMN, &context,
|
||||
-1);
|
||||
if (!name)
|
||||
visible = FALSE;
|
||||
else if (search)
|
||||
visible = strstr (name, search_text) != NULL;
|
||||
else
|
||||
visible = win->current_context != NULL && g_strcmp0 (context, win->current_context->id) == 0;
|
||||
|
||||
visible = name != NULL && win->current_context != NULL && g_strcmp0 (context, win->current_context->id) == 0;
|
||||
|
||||
g_free (name);
|
||||
g_free (context);
|
||||
@@ -742,13 +726,6 @@ symbolic_toggled (GtkToggleButton *toggle, IconBrowserWindow *win)
|
||||
gtk_widget_queue_draw (win->list);
|
||||
}
|
||||
|
||||
static void
|
||||
search_mode_toggled (GObject *searchbar, GParamSpec *pspec, IconBrowserWindow *win)
|
||||
{
|
||||
if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (searchbar)))
|
||||
gtk_list_box_unselect_all (GTK_LIST_BOX (win->context_list));
|
||||
}
|
||||
|
||||
static void
|
||||
icon_browser_window_init (IconBrowserWindow *win)
|
||||
{
|
||||
@@ -756,13 +733,16 @@ icon_browser_window_init (IconBrowserWindow *win)
|
||||
|
||||
win->contexts = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
|
||||
|
||||
g_object_bind_property (win->search, "active",
|
||||
win->searchbar, "search-mode-enabled",
|
||||
G_BINDING_BIDIRECTIONAL);
|
||||
|
||||
// gtk_tree_view_set_search_entry (GTK_TREE_VIEW (win->list), GTK_ENTRY (win->searchentry));
|
||||
g_signal_connect (win, "key-press-event", G_CALLBACK (key_press_event_cb), win->searchbar);
|
||||
|
||||
gtk_tree_model_filter_set_visible_func (win->filter_model, icon_visible_func, win, NULL);
|
||||
gtk_window_set_transient_for (GTK_WINDOW (win->details), GTK_WINDOW (win));
|
||||
|
||||
|
||||
g_signal_connect (win->searchbar, "notify::search-mode-enabled",
|
||||
G_CALLBACK (search_mode_toggled), win);
|
||||
|
||||
symbolic_toggled (GTK_TOGGLE_BUTTON (win->symbolic_radio), win);
|
||||
|
||||
populate (win);
|
||||
@@ -798,7 +778,6 @@ icon_browser_window_class_init (IconBrowserWindowClass *class)
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), item_activated);
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), selected_context_changed);
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), symbolic_toggled);
|
||||
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), key_press_event_cb);
|
||||
}
|
||||
|
||||
IconBrowserWindow *
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
<property name="title" translatable="yes">Icon Browser</property>
|
||||
<property name="default-width">600</property>
|
||||
<property name="default-height">800</property>
|
||||
<signal name="key-press-event" handler="key_press_event_cb"/>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<property name="visible">True</property>
|
||||
@@ -48,7 +47,7 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="search">
|
||||
<property name="visible">True</property>
|
||||
<property name="visible">False</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
@@ -84,11 +83,10 @@
|
||||
<child>
|
||||
<object class="GtkSearchBar" id="searchbar">
|
||||
<property name="visible">True</property>
|
||||
<property name="search-mode-enabled" bind-source="search" bind-property="active" bind-flags="bidirectional"/>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="searchentry">
|
||||
<property name="visible">True</property>
|
||||
<signal name="search-changed" handler="search_text_changed"/>
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
@@ -761,7 +761,7 @@ background_loaded_cb (GObject *source,
|
||||
pixbuf = gdk_pixbuf_new_from_stream_finish (res, &error);
|
||||
if (error)
|
||||
{
|
||||
g_warning ("Error loading '%s': %s", bd->filename, error->message);
|
||||
g_warning ("%s", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
@@ -1073,19 +1073,6 @@ textbuffer_notify_selection (GObject *object, GParamSpec *pspec, GtkWidget *butt
|
||||
gtk_widget_set_sensitive (button, has_selection);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
osd_frame_button_press (GtkWidget *frame, GdkEventButton *event, gpointer data)
|
||||
{
|
||||
GtkWidget *osd;
|
||||
gboolean visible;
|
||||
|
||||
osd = g_object_get_data (G_OBJECT (frame), "osd");
|
||||
visible = gtk_widget_get_visible (osd);
|
||||
gtk_widget_set_visible (osd, !visible);
|
||||
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
static void
|
||||
activate (GApplication *app)
|
||||
{
|
||||
@@ -1132,7 +1119,6 @@ activate (GApplication *app)
|
||||
gtk_builder_add_callback_symbol (builder, "on_page_combo_changed", (GCallback)on_page_combo_changed);
|
||||
gtk_builder_add_callback_symbol (builder, "on_range_from_changed", (GCallback)on_range_from_changed);
|
||||
gtk_builder_add_callback_symbol (builder, "on_range_to_changed", (GCallback)on_range_to_changed);
|
||||
gtk_builder_add_callback_symbol (builder, "osd_frame_button_press", (GCallback)osd_frame_button_press);
|
||||
|
||||
gtk_builder_connect_signals (builder, NULL);
|
||||
|
||||
@@ -1280,10 +1266,6 @@ activate (GApplication *app)
|
||||
g_signal_connect (gtk_widget_get_clipboard (widget2, GDK_SELECTION_CLIPBOARD), "owner-change",
|
||||
G_CALLBACK (clipboard_owner_change), widget);
|
||||
|
||||
widget = (GtkWidget *)gtk_builder_get_object (builder, "osd_frame");
|
||||
widget2 = (GtkWidget *)gtk_builder_get_object (builder, "totem_like_osd");
|
||||
g_object_set_data (G_OBJECT (widget), "osd", widget2);
|
||||
|
||||
gtk_widget_show_all (GTK_WIDGET (window));
|
||||
|
||||
g_object_unref (builder);
|
||||
|
||||
@@ -82,7 +82,6 @@
|
||||
</menu>
|
||||
<object class="GtkAdjustment" id="adjustment1">
|
||||
<property name="upper">100</property>
|
||||
<property name="lower">1</property>
|
||||
<property name="value">50</property>
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">10</property>
|
||||
@@ -169,7 +168,7 @@ Morbi massa libero, congue vitae scelerisque vel, ultricies vel nisl.
|
||||
Vestibulum in tortor diam, quis aliquet quam. Praesent ut justo neque, tempus rutrum est.
|
||||
Duis eu lectus quam. Vivamus eget metus a mauris molestie venenatis pulvinar eleifend nisi.
|
||||
Nulla facilisi. Pellentesque at dolor sit amet purus dapibus pulvinar molestie quis neque.
|
||||
Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
Suspendisse feugiat quam quis dolor accumsan cursus. </property>
|
||||
</object>
|
||||
<object class="GtkTextBuffer" id="textbuffer2">
|
||||
<property name="text">* Translation updates:
|
||||
@@ -1602,8 +1601,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="buffer">textbuffer1</property>
|
||||
<property name="wrap_mode">2</property>
|
||||
<property name="left_margin">10</property>
|
||||
<property name="right_margin">10</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@@ -2139,8 +2136,6 @@ microphone-sensitivity-medium-symbolic</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="buffer">textbuffer2</property>
|
||||
<property name="left_margin">10</property>
|
||||
<property name="right_margin">10</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@@ -2903,8 +2898,6 @@ microphone-sensitivity-medium-symbolic</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="buffer">textbuffer1</property>
|
||||
<property name="wrap_mode">2</property>
|
||||
<property name="left_margin">10</property>
|
||||
<property name="right_margin">10</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@@ -3026,7 +3019,6 @@ microphone-sensitivity-medium-symbolic</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="expanded">True</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow3">
|
||||
<property name="visible">True</property>
|
||||
@@ -3719,154 +3711,60 @@ microphone-sensitivity-medium-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkOverlay">
|
||||
<object class="GtkFrame">
|
||||
<property name="visible">True</property>
|
||||
<child type="overlay">
|
||||
<object class="GtkToolbar" id="totem_like_osd">
|
||||
<property name="no-show-all">True</property>
|
||||
<property name="opacity">0.9</property>
|
||||
<property name="margin">20</property>
|
||||
<property name="halign">fill</property>
|
||||
<property name="valign">end</property>
|
||||
<style>
|
||||
<class name="osd"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkPaned">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="wide-handle">True</property>
|
||||
<child>
|
||||
<object class="GtkToolItem">
|
||||
<object class="GtkNotebook">
|
||||
<property name="visible">True</property>
|
||||
<property name="show-border">False</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<style>
|
||||
<class name="linked"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">pan-start-symbolic</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">pan-end-symbolic</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<property name="height-request">120</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<child type="tab">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Page 1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="height-request">120</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="tab">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Page 2</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolItem">
|
||||
<object class="GtkNotebook">
|
||||
<property name="visible">True</property>
|
||||
<property name="show-border">False</property>
|
||||
<child>
|
||||
<object class="GtkScale">
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="draw-value">False</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="adjustment">adjustment1</property>
|
||||
<property name="height-request">120</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolItem">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkVolumeButton">
|
||||
<child type="tab">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="use-symbolic">True</property>
|
||||
<property name="value">.5</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<property name="label" translatable="yes">Page 3</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame" id="osd_frame">
|
||||
<property name="visible">True</property>
|
||||
<signal name="button-press-event" handler="osd_frame_button_press"/>
|
||||
<child>
|
||||
<object class="GtkPaned">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="wide-handle">True</property>
|
||||
<child>
|
||||
<object class="GtkNotebook">
|
||||
<property name="visible">True</property>
|
||||
<property name="show-border">False</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="height-request">120</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="tab">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Page 1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="tab">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Page 2</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkNotebook">
|
||||
<property name="visible">True</property>
|
||||
<property name="show-border">False</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="tab">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Page 3</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
@@ -1286,6 +1286,7 @@ gdk_frame_get_type
|
||||
<SECTION>
|
||||
<FILE>gdkglcontext</FILE>
|
||||
GdkGLContext
|
||||
gdk_gl_context_get_visual
|
||||
gdk_gl_context_get_window
|
||||
gdk_gl_context_make_current
|
||||
gdk_gl_context_clear_current
|
||||
|
||||
@@ -114,7 +114,6 @@
|
||||
<xi:include href="xml/gtkscalebutton.xml" />
|
||||
<xi:include href="xml/gtkvolumebutton.xml" />
|
||||
<xi:include href="xml/gtklockbutton.xml" />
|
||||
<xi:include href="xml/gtkmodelbutton.xml" />
|
||||
</chapter>
|
||||
|
||||
<chapter id="NumericEntry">
|
||||
@@ -192,7 +191,6 @@
|
||||
<xi:include href="xml/gtktoggletoolbutton.xml" />
|
||||
<xi:include href="xml/gtkradiotoolbutton.xml" />
|
||||
<xi:include href="xml/gtkpopover.xml" />
|
||||
<xi:include href="xml/gtkpopovermenu.xml" />
|
||||
</chapter>
|
||||
|
||||
<chapter id="SelectorWidgets">
|
||||
|
||||
@@ -6046,7 +6046,6 @@ GTK_STYLE_CLASS_SIDEBAR
|
||||
GTK_STYLE_CLASS_SLIDER
|
||||
GTK_STYLE_CLASS_SPINBUTTON
|
||||
GTK_STYLE_CLASS_SPINNER
|
||||
GTK_STYLE_CLASS_STATUSBAR
|
||||
GTK_STYLE_CLASS_SUBTITLE
|
||||
GTK_STYLE_CLASS_SUGGESTED_ACTION
|
||||
GTK_STYLE_CLASS_TITLE
|
||||
@@ -7956,22 +7955,6 @@ gtk_popover_set_modal
|
||||
gtk_popover_get_modal
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkpopovermenu</FILE>
|
||||
<TITLE>GtkPopoverMenu</TITLE>
|
||||
GtkPopoverMenu
|
||||
gtk_popover_menu_new
|
||||
gtk_popover_menu_open_submenu
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkmodelbutton</FILE>
|
||||
<TITLE>GtkModelButton</TITLE>
|
||||
GtkModelButton
|
||||
GtkButtonRole
|
||||
gtk_model_button_new
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkeventcontroller</FILE>
|
||||
<TITLE>GtkEventController</TITLE>
|
||||
|
||||
@@ -126,7 +126,6 @@ gtk_menu_shell_get_type
|
||||
gtk_menu_tool_button_get_type
|
||||
gtk_message_dialog_get_type
|
||||
gtk_misc_get_type
|
||||
gtk_model_button_get_type
|
||||
gtk_mount_operation_get_type
|
||||
gtk_notebook_get_type
|
||||
gtk_numerable_icon_get_type
|
||||
@@ -140,7 +139,6 @@ gtk_paper_size_get_type
|
||||
gtk_places_sidebar_get_type
|
||||
@ENABLE_ON_X11@gtk_plug_get_type
|
||||
gtk_popover_get_type
|
||||
gtk_popover_menu_get_type
|
||||
@DISABLE_ON_W32@gtk_printer_get_type
|
||||
gtk_print_context_get_type
|
||||
@DISABLE_ON_W32@gtk_print_job_get_type
|
||||
|
||||
@@ -99,7 +99,6 @@ gdk_h_sources = \
|
||||
$(deprecated_h_sources)
|
||||
|
||||
gdk_private_headers = \
|
||||
gdk-private.h \
|
||||
gdkapplaunchcontextprivate.h \
|
||||
gdkcursorprivate.h \
|
||||
gdkdevicemanagerprivate.h \
|
||||
@@ -122,7 +121,6 @@ deprecated_c_sources = \
|
||||
|
||||
gdk_c_sources = \
|
||||
$(deprecated_c_sources) \
|
||||
gdk-private.c \
|
||||
gdk.c \
|
||||
gdkapplaunchcontext.c \
|
||||
gdkcairo.c \
|
||||
|
||||
@@ -330,6 +330,19 @@ gdk_broadway_display_get_next_serial (GdkDisplay *display)
|
||||
return _gdk_broadway_server_get_next_serial (broadway_display->server);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_display_event_data_copy (GdkDisplay *display,
|
||||
const GdkEvent *src,
|
||||
GdkEvent *dst)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_display_event_data_free (GdkDisplay *display,
|
||||
GdkEvent *event)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
gdk_broadway_display_show_keyboard (GdkBroadwayDisplay *display)
|
||||
{
|
||||
@@ -385,6 +398,8 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
|
||||
display_class->after_process_all_updates = _gdk_broadway_display_after_process_all_updates;
|
||||
display_class->get_next_serial = gdk_broadway_display_get_next_serial;
|
||||
display_class->notify_startup_complete = gdk_broadway_display_notify_startup_complete;
|
||||
display_class->event_data_copy = gdk_broadway_display_event_data_copy;
|
||||
display_class->event_data_free = gdk_broadway_display_event_data_free;
|
||||
display_class->create_window_impl = _gdk_broadway_display_create_window_impl;
|
||||
display_class->get_keymap = _gdk_broadway_display_get_keymap;
|
||||
display_class->get_selection_owner = _gdk_broadway_display_get_selection_owner;
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#include "config.h"
|
||||
#include "gdk-private.h"
|
||||
|
||||
GdkPrivateVTable *
|
||||
gdk__private__ (void)
|
||||
{
|
||||
static GdkPrivateVTable table = {
|
||||
gdk_device_grab_info,
|
||||
gdk_display_open_default,
|
||||
gdk_add_option_entries,
|
||||
gdk_pre_parse,
|
||||
gdk_gl_get_flags,
|
||||
gdk_gl_set_flags,
|
||||
gdk_window_freeze_toplevel_updates,
|
||||
gdk_window_thaw_toplevel_updates,
|
||||
gdk_display_get_rendering_mode,
|
||||
gdk_display_set_rendering_mode,
|
||||
gdk_display_get_debug_updates,
|
||||
gdk_display_set_debug_updates
|
||||
};
|
||||
|
||||
return &table;
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
#ifndef __GDK__PRIVATE_H__
|
||||
#define __GDK__PRIVATE_H__
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include "gdk/gdkinternals.h"
|
||||
|
||||
#define GDK_PRIVATE_CALL(symbol) (gdk__private__ ()->symbol)
|
||||
|
||||
GdkDisplay * gdk_display_open_default (void);
|
||||
|
||||
gboolean gdk_device_grab_info (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
GdkWindow **grab_window,
|
||||
gboolean *owner_events);
|
||||
|
||||
void gdk_add_option_entries (GOptionGroup *group);
|
||||
|
||||
void gdk_pre_parse (void);
|
||||
|
||||
GdkGLFlags gdk_gl_get_flags (void);
|
||||
void gdk_gl_set_flags (GdkGLFlags flags);
|
||||
|
||||
void gdk_window_freeze_toplevel_updates (GdkWindow *window);
|
||||
void gdk_window_thaw_toplevel_updates (GdkWindow *window);
|
||||
|
||||
GdkRenderingMode gdk_display_get_rendering_mode (GdkDisplay *display);
|
||||
void gdk_display_set_rendering_mode (GdkDisplay *display,
|
||||
GdkRenderingMode mode);
|
||||
|
||||
gboolean gdk_display_get_debug_updates (GdkDisplay *display);
|
||||
void gdk_display_set_debug_updates (GdkDisplay *display,
|
||||
gboolean debug_updates);
|
||||
|
||||
typedef struct {
|
||||
/* add all private functions here, initialize them in gdk-private.c */
|
||||
gboolean (* gdk_device_grab_info) (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
GdkWindow **grab_window,
|
||||
gboolean *owner_events);
|
||||
|
||||
GdkDisplay *(* gdk_display_open_default) (void);
|
||||
|
||||
void (* gdk_add_option_entries) (GOptionGroup *group);
|
||||
void (* gdk_pre_parse) (void);
|
||||
|
||||
GdkGLFlags (* gdk_gl_get_flags) (void);
|
||||
void (* gdk_gl_set_flags) (GdkGLFlags flags);
|
||||
|
||||
void (* gdk_window_freeze_toplevel_updates) (GdkWindow *window);
|
||||
void (* gdk_window_thaw_toplevel_updates) (GdkWindow *window);
|
||||
|
||||
GdkRenderingMode (* gdk_display_get_rendering_mode) (GdkDisplay *display);
|
||||
void (* gdk_display_set_rendering_mode) (GdkDisplay *display,
|
||||
GdkRenderingMode mode);
|
||||
|
||||
gboolean (* gdk_display_get_debug_updates) (GdkDisplay *display);
|
||||
void (* gdk_display_set_debug_updates) (GdkDisplay *display,
|
||||
gboolean debug_updates);
|
||||
} GdkPrivateVTable;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkPrivateVTable * gdk__private__ (void);
|
||||
|
||||
#endif /* __GDK__PRIVATE_H__ */
|
||||
@@ -30,8 +30,6 @@
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkintl.h"
|
||||
|
||||
#include "gdk-private.h"
|
||||
|
||||
#ifndef HAVE_XCONVERTCASE
|
||||
#include "gdkkeysyms.h"
|
||||
#endif
|
||||
@@ -136,15 +134,6 @@ static GMutex gdk_threads_mutex;
|
||||
static GCallback gdk_threads_lock = NULL;
|
||||
static GCallback gdk_threads_unlock = NULL;
|
||||
|
||||
static const GDebugKey gdk_gl_keys[] = {
|
||||
{"disable", GDK_GL_DISABLE},
|
||||
{"always", GDK_GL_ALWAYS},
|
||||
{"software-draw", GDK_GL_SOFTWARE_DRAW_GL | GDK_GL_SOFTWARE_DRAW_SURFACE},
|
||||
{"software-draw-gl", GDK_GL_SOFTWARE_DRAW_GL},
|
||||
{"software-draw-surface", GDK_GL_SOFTWARE_DRAW_SURFACE},
|
||||
{"texture-rectangle", GDK_GL_TEXTURE_RECTANGLE},
|
||||
};
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
static const GDebugKey gdk_debug_keys[] = {
|
||||
{"events", GDK_DEBUG_EVENTS},
|
||||
@@ -160,6 +149,7 @@ static const GDebugKey gdk_debug_keys[] = {
|
||||
{"eventloop", GDK_DEBUG_EVENTLOOP},
|
||||
{"frames", GDK_DEBUG_FRAMES},
|
||||
{"settings", GDK_DEBUG_SETTINGS},
|
||||
{"nogl", GDK_DEBUG_NOGL},
|
||||
{"opengl", GDK_DEBUG_OPENGL},
|
||||
};
|
||||
|
||||
@@ -241,33 +231,23 @@ static const GOptionEntry gdk_args[] = {
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
void
|
||||
gdk_add_option_entries (GOptionGroup *group)
|
||||
{
|
||||
g_option_group_add_entries (group, gdk_args);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_add_option_entries_libgtk_only:
|
||||
* @group: An option group.
|
||||
*
|
||||
* Appends gdk option entries to the passed in option group. This is
|
||||
* not public API and must not be used by applications.
|
||||
*
|
||||
* Deprecated: 3.16: This symbol was never meant to be used outside
|
||||
* of GTK+
|
||||
*/
|
||||
void
|
||||
gdk_add_option_entries_libgtk_only (GOptionGroup *group)
|
||||
{
|
||||
gdk_add_option_entries (group);
|
||||
g_option_group_add_entries (group, gdk_args);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_pre_parse (void)
|
||||
gdk_pre_parse_libgtk_only (void)
|
||||
{
|
||||
const char *rendering_mode;
|
||||
const gchar *gl_string;
|
||||
|
||||
gdk_initialized = TRUE;
|
||||
|
||||
@@ -288,12 +268,6 @@ gdk_pre_parse (void)
|
||||
}
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
|
||||
gl_string = getenv("GDK_GL");
|
||||
if (gl_string != NULL)
|
||||
_gdk_gl_flags = g_parse_debug_string (gl_string,
|
||||
(GDebugKey *) gdk_gl_keys,
|
||||
G_N_ELEMENTS (gdk_gl_keys));
|
||||
|
||||
if (getenv ("GDK_NATIVE_WINDOWS"))
|
||||
{
|
||||
g_warning ("The GDK_NATIVE_WINDOWS environment variable is not supported in GTK3.\n"
|
||||
@@ -313,20 +287,6 @@ gdk_pre_parse (void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_pre_parse_libgtk_only:
|
||||
*
|
||||
* Prepare for parsing command line arguments for GDK. This is not
|
||||
* public API and should not be used in application code.
|
||||
*
|
||||
* Deprecated: 3.16: This symbol was never meant to be used outside
|
||||
* of GTK+
|
||||
*/
|
||||
void
|
||||
gdk_pre_parse_libgtk_only (void)
|
||||
{
|
||||
gdk_pre_parse ();
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_parse_args:
|
||||
@@ -355,7 +315,7 @@ gdk_parse_args (int *argc,
|
||||
if (gdk_initialized)
|
||||
return;
|
||||
|
||||
gdk_pre_parse ();
|
||||
gdk_pre_parse_libgtk_only ();
|
||||
|
||||
option_context = g_option_context_new (NULL);
|
||||
g_option_context_set_ignore_unknown_options (option_context, TRUE);
|
||||
@@ -414,8 +374,8 @@ gdk_get_display_arg_name (void)
|
||||
return _gdk_display_arg_name;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_display_open_default:
|
||||
/**
|
||||
* gdk_display_open_default_libgtk_only:
|
||||
*
|
||||
* Opens the default display specified by command line arguments or
|
||||
* environment variables, sets it as the default display, and returns
|
||||
@@ -425,9 +385,9 @@ gdk_get_display_arg_name (void)
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the default display, if it
|
||||
* could be opened, otherwise %NULL.
|
||||
*/
|
||||
**/
|
||||
GdkDisplay *
|
||||
gdk_display_open_default (void)
|
||||
gdk_display_open_default_libgtk_only (void)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
|
||||
@@ -442,27 +402,6 @@ gdk_display_open_default (void)
|
||||
return display;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_display_open_default_libgtk_only:
|
||||
*
|
||||
* Opens the default display specified by command line arguments or
|
||||
* environment variables, sets it as the default display, and returns
|
||||
* it. gdk_parse_args() must have been called first. If the default
|
||||
* display has previously been set, simply returns that. An internal
|
||||
* function that should not be used by applications.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the default display, if it
|
||||
* could be opened, otherwise %NULL.
|
||||
*
|
||||
* Deprecated: 3.16: This symbol was never meant to be used outside
|
||||
* of GTK+
|
||||
*/
|
||||
GdkDisplay *
|
||||
gdk_display_open_default_libgtk_only (void)
|
||||
{
|
||||
return gdk_display_open_default ();
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_init_check:
|
||||
* @argc: (inout): the number of command line arguments.
|
||||
@@ -485,7 +424,7 @@ gdk_init_check (int *argc,
|
||||
{
|
||||
gdk_parse_args (argc, argv);
|
||||
|
||||
return gdk_display_open_default () != NULL;
|
||||
return gdk_display_open_default_libgtk_only () != NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -192,13 +192,11 @@ gdk_cursor_unref (GdkCursor *cursor)
|
||||
* To make the cursor invisible, use %GDK_BLANK_CURSOR.
|
||||
*
|
||||
* Returns: a new #GdkCursor
|
||||
*
|
||||
* Deprecated: 3.16: Use gdk_cursor_new_for_display() instead.
|
||||
*/
|
||||
GdkCursor*
|
||||
gdk_cursor_new (GdkCursorType cursor_type)
|
||||
{
|
||||
return gdk_cursor_new_for_display (gdk_display_get_default (), cursor_type);
|
||||
return gdk_cursor_new_for_display (gdk_display_get_default(), cursor_type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -450,7 +448,9 @@ gdk_cursor_get_image (GdkCursor *cursor)
|
||||
h = cairo_image_surface_get_height (surface);
|
||||
|
||||
x_scale = y_scale = 1;
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_get_device_scale (surface, &x_scale, &y_scale);
|
||||
#endif
|
||||
|
||||
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, w, h);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
+1
-1
@@ -219,7 +219,7 @@ GType gdk_cursor_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkCursor* gdk_cursor_new_for_display (GdkDisplay *display,
|
||||
GdkCursorType cursor_type);
|
||||
GDK_DEPRECATED_IN_3_16
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkCursor* gdk_cursor_new (GdkCursorType cursor_type);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkCursor* gdk_cursor_new_from_pixbuf (GdkDisplay *display,
|
||||
|
||||
+2
-5
@@ -1260,8 +1260,6 @@ get_native_grab_event_mask (GdkEventMask grab_mask)
|
||||
* or the window becomes unviewable. This overrides any previous grab on the device
|
||||
* by this client.
|
||||
*
|
||||
* Note that @device and @window need to be on the same display.
|
||||
*
|
||||
* Device grabs are used for operations which need complete control over the
|
||||
* given device events (either pointer or keyboard). For example in GTK+ this
|
||||
* is used for Drag and Drop operations, popup menus and such.
|
||||
@@ -1293,9 +1291,8 @@ gdk_device_grab (GdkDevice *device,
|
||||
GdkGrabStatus res;
|
||||
GdkWindow *native;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), GDK_GRAB_FAILED);
|
||||
g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_GRAB_FAILED);
|
||||
g_return_val_if_fail (gdk_window_get_display (window) == gdk_device_get_display (device), GDK_GRAB_FAILED);
|
||||
g_return_val_if_fail (GDK_IS_DEVICE (device), GDK_GRAB_SUCCESS);
|
||||
g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_GRAB_SUCCESS);
|
||||
|
||||
native = gdk_window_get_toplevel (window);
|
||||
|
||||
|
||||
+1
-1
@@ -265,7 +265,7 @@ void gdk_device_warp (GdkDevice *device,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
GDK_DEPRECATED_IN_3_16
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_device_grab_info_libgtk_only (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
GdkWindow **grab_window,
|
||||
|
||||
+54
-82
@@ -24,8 +24,6 @@
|
||||
#include "gdkdisplay.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
|
||||
#include "gdk-private.h"
|
||||
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkdisplaymanagerprivate.h"
|
||||
#include "gdkevents.h"
|
||||
@@ -112,19 +110,6 @@ gdk_display_real_opened (GdkDisplay *display)
|
||||
_gdk_display_manager_add_display (gdk_display_manager_get (), display);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_display_real_event_data_copy (GdkDisplay *display,
|
||||
const GdkEvent *src,
|
||||
GdkEvent *dst)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_display_real_event_data_free (GdkDisplay *display,
|
||||
GdkEvent *dst)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_display_class_init (GdkDisplayClass *class)
|
||||
{
|
||||
@@ -138,8 +123,6 @@ gdk_display_class_init (GdkDisplayClass *class)
|
||||
|
||||
class->opened = gdk_display_real_opened;
|
||||
class->make_default = gdk_display_real_make_default;
|
||||
class->event_data_copy = gdk_display_real_event_data_copy;
|
||||
class->event_data_free = gdk_display_real_event_data_free;
|
||||
|
||||
/**
|
||||
* GdkDisplay::opened:
|
||||
@@ -223,8 +206,6 @@ gdk_display_init (GdkDisplay *display)
|
||||
|
||||
display->multiple_click_info = g_hash_table_new_full (NULL, NULL, NULL,
|
||||
(GDestroyNotify) g_free);
|
||||
|
||||
display->rendering_mode = _gdk_rendering_mode;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1297,8 +1278,8 @@ _gdk_display_pointer_info_foreach (GdkDisplay *display,
|
||||
}
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_device_grab_info:
|
||||
/**
|
||||
* gdk_device_grab_info_libgtk_only:
|
||||
* @display: the display for which to get the grab information
|
||||
* @device: device to get the grab information from
|
||||
* @grab_window: (out) (transfer none): location to store current grab window
|
||||
@@ -1311,12 +1292,12 @@ _gdk_display_pointer_info_foreach (GdkDisplay *display,
|
||||
*
|
||||
* Returns: %TRUE if this application currently has the
|
||||
* keyboard grabbed.
|
||||
*/
|
||||
**/
|
||||
gboolean
|
||||
gdk_device_grab_info (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
GdkWindow **grab_window,
|
||||
gboolean *owner_events)
|
||||
gdk_device_grab_info_libgtk_only (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
GdkWindow **grab_window,
|
||||
gboolean *owner_events)
|
||||
{
|
||||
GdkDeviceGrabInfo *info;
|
||||
|
||||
@@ -1338,33 +1319,6 @@ gdk_device_grab_info (GdkDisplay *display,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_grab_info_libgtk_only:
|
||||
* @display: the display for which to get the grab information
|
||||
* @device: device to get the grab information from
|
||||
* @grab_window: (out) (transfer none): location to store current grab window
|
||||
* @owner_events: (out): location to store boolean indicating whether
|
||||
* the @owner_events flag to gdk_keyboard_grab() or
|
||||
* gdk_pointer_grab() was %TRUE.
|
||||
*
|
||||
* Determines information about the current keyboard grab.
|
||||
* This is not public API and must not be used by applications.
|
||||
*
|
||||
* Returns: %TRUE if this application currently has the
|
||||
* keyboard grabbed.
|
||||
*
|
||||
* Deprecated: 3.16: The symbol was never meant to be used outside
|
||||
* of GTK+
|
||||
*/
|
||||
gboolean
|
||||
gdk_device_grab_info_libgtk_only (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
GdkWindow **grab_window,
|
||||
gboolean *owner_events)
|
||||
{
|
||||
return gdk_device_grab_info (display, device, grab_window, owner_events);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_display_pointer_is_grabbed:
|
||||
* @display: a #GdkDisplay
|
||||
@@ -2275,6 +2229,28 @@ gdk_error_trap_pop (void)
|
||||
return gdk_error_trap_pop_internal (TRUE);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_display_destroy_gl_context:
|
||||
* @display: a #GdkDisplay
|
||||
* @context: a #GdkGLContext
|
||||
*
|
||||
* Destroys the platform-specific parts of the @context.
|
||||
*
|
||||
* The @context instance is still valid, though inert, after
|
||||
* this functionr returns.
|
||||
*/
|
||||
void
|
||||
gdk_display_destroy_gl_context (GdkDisplay *display,
|
||||
GdkGLContext *context)
|
||||
{
|
||||
GdkGLContext *current = gdk_display_get_current_gl_context (display);
|
||||
|
||||
if (current == context)
|
||||
g_object_set_data (G_OBJECT (display), "-gdk-gl-current-context", NULL);
|
||||
|
||||
GDK_DISPLAY_GET_CLASS (display)->destroy_gl_context (display, context);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_display_make_gl_context_current:
|
||||
* @display: a #GdkDisplay
|
||||
@@ -2283,39 +2259,35 @@ gdk_error_trap_pop (void)
|
||||
* Makes the given @context the current GL context, or unsets
|
||||
* the current GL context if @context is %NULL.
|
||||
*/
|
||||
gboolean
|
||||
void
|
||||
gdk_display_make_gl_context_current (GdkDisplay *display,
|
||||
GdkGLContext *context)
|
||||
{
|
||||
return GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context);
|
||||
}
|
||||
GdkGLContext *current = gdk_display_get_current_gl_context (display);
|
||||
|
||||
GdkRenderingMode
|
||||
gdk_display_get_rendering_mode (GdkDisplay *display)
|
||||
{
|
||||
return display->rendering_mode;
|
||||
}
|
||||
if (current == context)
|
||||
return;
|
||||
|
||||
void
|
||||
gdk_display_set_rendering_mode (GdkDisplay *display,
|
||||
GdkRenderingMode mode)
|
||||
{
|
||||
display->rendering_mode = mode;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_display_set_debug_updates (GdkDisplay *display,
|
||||
gboolean debug_updates)
|
||||
{
|
||||
display->debug_updates = debug_updates;
|
||||
display->debug_updates_set = TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_display_get_debug_updates (GdkDisplay *display)
|
||||
{
|
||||
if (display->debug_updates_set)
|
||||
return display->debug_updates;
|
||||
if (context == NULL)
|
||||
g_object_set_data (G_OBJECT (display), "-gdk-gl-current-context", NULL);
|
||||
else
|
||||
return _gdk_debug_updates;
|
||||
g_object_set_data_full (G_OBJECT (display), "-gdk-gl-current-context",
|
||||
g_object_ref (context),
|
||||
(GDestroyNotify) g_object_unref);
|
||||
|
||||
GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_display_get_current_gl_context:
|
||||
* @display: a #GdkDisplay
|
||||
*
|
||||
* Retrieves the current #GdkGLContext associated with @display.
|
||||
*
|
||||
* Returns: (transfer none): the current #GdkGLContext or %NULL
|
||||
*/
|
||||
GdkGLContext *
|
||||
gdk_display_get_current_gl_context (GdkDisplay *display)
|
||||
{
|
||||
return g_object_get_data (G_OBJECT (display), "-gdk-gl-current-context");
|
||||
}
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@ void gdk_display_warp_pointer (GdkDisplay *disp
|
||||
gint y);
|
||||
#endif /* GDK_MULTIDEVICE_SAFE */
|
||||
|
||||
GDK_DEPRECATED_IN_3_16
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDisplay *gdk_display_open_default_libgtk_only (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "gdkdisplay.h"
|
||||
#include "gdkwindow.h"
|
||||
#include "gdkcursor.h"
|
||||
#include "gdkinternals.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -120,11 +119,6 @@ struct _GdkDisplay
|
||||
|
||||
guint has_gl_extension_texture_non_power_of_two : 1;
|
||||
guint has_gl_extension_texture_rectangle : 1;
|
||||
|
||||
guint debug_updates : 1;
|
||||
guint debug_updates_set : 1;
|
||||
|
||||
GdkRenderingMode rendering_mode;
|
||||
};
|
||||
|
||||
struct _GdkDisplayClass
|
||||
@@ -234,8 +228,10 @@ struct _GdkDisplayClass
|
||||
gchar * (*utf8_to_string_target) (GdkDisplay *display,
|
||||
const gchar *text);
|
||||
|
||||
gboolean (*make_gl_context_current) (GdkDisplay *display,
|
||||
GdkGLContext *context);
|
||||
void (*make_gl_context_current) (GdkDisplay *display,
|
||||
GdkGLContext *context);
|
||||
void (*destroy_gl_context) (GdkDisplay *display,
|
||||
GdkGLContext *context);
|
||||
|
||||
/* Signals */
|
||||
void (*opened) (GdkDisplay *display);
|
||||
@@ -315,8 +311,11 @@ void _gdk_display_create_window_impl (GdkDisplay *display
|
||||
gint attributes_mask);
|
||||
GdkWindow * _gdk_display_create_window (GdkDisplay *display);
|
||||
|
||||
gboolean gdk_display_make_gl_context_current (GdkDisplay *display,
|
||||
void gdk_display_destroy_gl_context (GdkDisplay *display,
|
||||
GdkGLContext *context);
|
||||
void gdk_display_make_gl_context_current (GdkDisplay *display,
|
||||
GdkGLContext *context);
|
||||
GdkGLContext * gdk_display_get_current_gl_context (GdkDisplay *display);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+9
-15
@@ -461,15 +461,6 @@ gdk_event_peek (void)
|
||||
return event;
|
||||
}
|
||||
|
||||
static GdkDisplay *
|
||||
event_get_display (const GdkEvent *event)
|
||||
{
|
||||
if (event->any.window)
|
||||
return gdk_window_get_display (event->any.window);
|
||||
else
|
||||
return gdk_display_get_default ();
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_put:
|
||||
* @event: a #GdkEvent.
|
||||
@@ -485,7 +476,10 @@ gdk_event_put (const GdkEvent *event)
|
||||
|
||||
g_return_if_fail (event != NULL);
|
||||
|
||||
display = event_get_display (event);
|
||||
if (event->any.window)
|
||||
display = gdk_window_get_display (event->any.window);
|
||||
else
|
||||
display = gdk_display_get_default ();
|
||||
|
||||
gdk_display_put_event (display, event);
|
||||
}
|
||||
@@ -719,7 +713,7 @@ gdk_event_copy (const GdkEvent *event)
|
||||
}
|
||||
|
||||
if (gdk_event_is_allocated (event))
|
||||
_gdk_display_event_data_copy (event_get_display (event), event, new_event);
|
||||
_gdk_display_event_data_copy (gdk_display_get_default (), event, new_event);
|
||||
|
||||
return new_event;
|
||||
}
|
||||
@@ -740,6 +734,9 @@ gdk_event_free (GdkEvent *event)
|
||||
|
||||
g_return_if_fail (event != NULL);
|
||||
|
||||
if (event->any.window)
|
||||
g_object_unref (event->any.window);
|
||||
|
||||
switch (event->any.type)
|
||||
{
|
||||
case GDK_KEY_PRESS:
|
||||
@@ -807,13 +804,10 @@ gdk_event_free (GdkEvent *event)
|
||||
break;
|
||||
}
|
||||
|
||||
display = event_get_display (event);
|
||||
display = gdk_display_get_default ();
|
||||
if (display)
|
||||
_gdk_display_event_data_free (display, event);
|
||||
|
||||
if (event->any.window)
|
||||
g_object_unref (event->any.window);
|
||||
|
||||
g_hash_table_remove (event_hash, event);
|
||||
g_slice_free (GdkEventPrivate, (GdkEventPrivate*) event);
|
||||
}
|
||||
|
||||
+77
-331
@@ -35,254 +35,6 @@ gdk_cairo_surface_mark_as_direct (cairo_surface_t *surface,
|
||||
g_object_ref (window), g_object_unref);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_vertex_type_name (int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GL_VERTEX_SHADER:
|
||||
return "vertex";
|
||||
case GL_GEOMETRY_SHADER:
|
||||
return "geometry";
|
||||
case GL_FRAGMENT_SHADER:
|
||||
return "fragment";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
static guint
|
||||
create_shader (int type, const char const *code)
|
||||
{
|
||||
guint shader;
|
||||
int status;
|
||||
|
||||
shader = glCreateShader (type);
|
||||
glShaderSource (shader, 1, &code, NULL);
|
||||
glCompileShader (shader);
|
||||
|
||||
glGetShaderiv (shader, GL_COMPILE_STATUS, &status);
|
||||
if (status == GL_FALSE)
|
||||
{
|
||||
int log_len;
|
||||
char *buffer;
|
||||
|
||||
glGetShaderiv (shader, GL_INFO_LOG_LENGTH, &log_len);
|
||||
|
||||
buffer = g_malloc (log_len + 1);
|
||||
glGetShaderInfoLog (shader, log_len, NULL, buffer);
|
||||
|
||||
g_warning ("Compile failure in %s shader:\n%s\n", get_vertex_type_name (type), buffer);
|
||||
g_free (buffer);
|
||||
|
||||
glDeleteShader (shader);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
static guint
|
||||
make_program (const char const *vertex_shader_code, const char const *fragment_shader_code)
|
||||
{
|
||||
guint program, vertex_shader, fragment_shader;
|
||||
int status;
|
||||
|
||||
vertex_shader = create_shader (GL_VERTEX_SHADER, vertex_shader_code);
|
||||
if (vertex_shader == 0)
|
||||
return 0;
|
||||
|
||||
fragment_shader = create_shader (GL_FRAGMENT_SHADER, fragment_shader_code);
|
||||
if (fragment_shader == 0)
|
||||
{
|
||||
glDeleteShader (vertex_shader);
|
||||
return 0;
|
||||
}
|
||||
|
||||
program = glCreateProgram ();
|
||||
glAttachShader (program, vertex_shader);
|
||||
glAttachShader (program, fragment_shader);
|
||||
|
||||
glLinkProgram (program);
|
||||
|
||||
glDeleteShader (vertex_shader);
|
||||
glDeleteShader (fragment_shader);
|
||||
|
||||
glGetProgramiv (program, GL_LINK_STATUS, &status);
|
||||
if (status == GL_FALSE)
|
||||
{
|
||||
int log_len;
|
||||
char *buffer;
|
||||
|
||||
glGetProgramiv (program, GL_INFO_LOG_LENGTH, &log_len);
|
||||
|
||||
buffer = g_malloc (log_len + 1);
|
||||
glGetProgramInfoLog (program, log_len, NULL, buffer);
|
||||
g_warning ("Linker failure: %s\n", buffer);
|
||||
g_free (buffer);
|
||||
|
||||
glDeleteProgram (program);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return program;
|
||||
}
|
||||
|
||||
static void
|
||||
bind_vao (GdkGLContextPaintData *paint_data)
|
||||
{
|
||||
if (paint_data->vertex_array_object == 0)
|
||||
{
|
||||
glGenVertexArrays (1, &paint_data->vertex_array_object);
|
||||
/* ATM we only use one VAO, so always bind it */
|
||||
glBindVertexArray (paint_data->vertex_array_object);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
use_texture_2d_program (GdkGLContextPaintData *paint_data,
|
||||
guint *position_location,
|
||||
guint *uv_location,
|
||||
guint *map_location)
|
||||
{
|
||||
const char *vertex_shader_code =
|
||||
"#version 120\n"
|
||||
"uniform sampler2D map;"
|
||||
"attribute vec2 position;\n"
|
||||
"attribute vec2 uv;\n"
|
||||
"varying vec2 vUv;\n"
|
||||
"void main() {\n"
|
||||
" gl_Position = vec4(position, 0, 1);\n"
|
||||
" vUv = uv;\n"
|
||||
"}\n";
|
||||
const char *fragment_shader_code =
|
||||
"#version 120\n"
|
||||
"varying vec2 vUv;\n"
|
||||
"uniform sampler2D map;\n"
|
||||
"void main() {\n"
|
||||
" gl_FragColor = texture2D (map, vUv);\n"
|
||||
"}\n";
|
||||
|
||||
if (paint_data->texture_quad_program == 0)
|
||||
{
|
||||
paint_data->texture_quad_program = make_program (vertex_shader_code, fragment_shader_code);
|
||||
paint_data->texture_quad_program_position_location = glGetAttribLocation (paint_data->texture_quad_program, "position");
|
||||
paint_data->texture_quad_program_uv_location = glGetAttribLocation (paint_data->texture_quad_program, "uv");
|
||||
paint_data->texture_quad_program_map_location = glGetUniformLocation (paint_data->texture_quad_program, "map");
|
||||
}
|
||||
|
||||
if (paint_data->current_program != paint_data->texture_quad_program)
|
||||
{
|
||||
glUseProgram (paint_data->texture_quad_program);
|
||||
paint_data->current_program = paint_data->texture_quad_program;
|
||||
}
|
||||
|
||||
*position_location = paint_data->texture_quad_program_position_location;
|
||||
*uv_location = paint_data->texture_quad_program_uv_location;
|
||||
*map_location = paint_data->texture_quad_program_map_location;
|
||||
}
|
||||
|
||||
static void
|
||||
use_texture_rect_program (GdkGLContextPaintData *paint_data,
|
||||
guint *position_location,
|
||||
guint *uv_location,
|
||||
guint *map_location)
|
||||
{
|
||||
const char *vertex_shader_code =
|
||||
"#version 120\n"
|
||||
"uniform sampler2DRect map;"
|
||||
"attribute vec2 position;\n"
|
||||
"attribute vec2 uv;\n"
|
||||
"varying vec2 vUv;\n"
|
||||
"void main() {\n"
|
||||
" gl_Position = vec4(position, 0, 1);\n"
|
||||
" vUv = uv;\n"
|
||||
"}\n";
|
||||
const char *fragment_shader_code =
|
||||
"#version 120\n"
|
||||
"varying vec2 vUv;\n"
|
||||
"uniform sampler2DRect map;\n"
|
||||
"void main() {\n"
|
||||
" gl_FragColor = texture2DRect (map, vUv);\n"
|
||||
"}\n";
|
||||
|
||||
if (paint_data->texture_quad_rect_program == 0)
|
||||
{
|
||||
paint_data->texture_quad_rect_program = make_program (vertex_shader_code, fragment_shader_code);
|
||||
paint_data->texture_quad_rect_program_position_location = glGetAttribLocation (paint_data->texture_quad_rect_program, "position");
|
||||
paint_data->texture_quad_rect_program_uv_location = glGetAttribLocation (paint_data->texture_quad_rect_program, "uv");
|
||||
paint_data->texture_quad_rect_program_map_location = glGetUniformLocation (paint_data->texture_quad_rect_program, "map");
|
||||
}
|
||||
|
||||
if (paint_data->current_program != paint_data->texture_quad_rect_program)
|
||||
{
|
||||
glUseProgram (paint_data->texture_quad_rect_program);
|
||||
paint_data->current_program = paint_data->texture_quad_rect_program;
|
||||
}
|
||||
|
||||
*position_location = paint_data->texture_quad_rect_program_position_location;
|
||||
*uv_location = paint_data->texture_quad_rect_program_uv_location;
|
||||
*map_location = paint_data->texture_quad_rect_program_map_location;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gdk_gl_texture_quad (GdkGLContext *paint_context,
|
||||
guint texture_target,
|
||||
float x1, float y1,
|
||||
float x2, float y2,
|
||||
float u1, float v1,
|
||||
float u2, float v2)
|
||||
{
|
||||
GdkGLContextPaintData *paint_data = gdk_gl_context_get_paint_data (paint_context);
|
||||
GdkWindow *window = gdk_gl_context_get_window (paint_context);
|
||||
int window_scale = gdk_window_get_scale_factor (window);
|
||||
float w = gdk_window_get_width (window) * window_scale;
|
||||
float h = gdk_window_get_height (window) * window_scale;
|
||||
float vertex_buffer_data[] = {
|
||||
(x2 * 2) / w - 1, (y1 * 2) / h - 1,
|
||||
(x2 * 2) / w - 1, (y2 * 2) / h - 1,
|
||||
(x1 * 2) / w - 1, (y2 * 2) / h - 1,
|
||||
(x1 * 2) / w - 1, (y1 * 2) / h - 1,
|
||||
};
|
||||
float uv_buffer_data[] = {
|
||||
u2, v1,
|
||||
u2, v2,
|
||||
u1, v2,
|
||||
u1, v1,
|
||||
};
|
||||
guint position_location, uv_location, map_location;
|
||||
|
||||
bind_vao (paint_data);
|
||||
|
||||
if (paint_data->tmp_vertex_buffer == 0)
|
||||
glGenBuffers(1, &paint_data->tmp_vertex_buffer);
|
||||
|
||||
if (paint_data->tmp_uv_buffer == 0)
|
||||
glGenBuffers(1, &paint_data->tmp_uv_buffer);
|
||||
|
||||
if (texture_target == GL_TEXTURE_RECTANGLE_ARB)
|
||||
use_texture_rect_program (paint_data, &position_location, &uv_location, &map_location);
|
||||
else
|
||||
use_texture_2d_program (paint_data, &position_location, &uv_location, &map_location);
|
||||
|
||||
glActiveTexture (GL_TEXTURE0);
|
||||
glUniform1i(map_location, 0); /* Use texture unit 0 */
|
||||
|
||||
glEnableVertexAttribArray (0);
|
||||
glBindBuffer (GL_ARRAY_BUFFER, paint_data->tmp_vertex_buffer);
|
||||
glBufferData (GL_ARRAY_BUFFER, sizeof(vertex_buffer_data), vertex_buffer_data, GL_STREAM_DRAW);
|
||||
glVertexAttribPointer (position_location, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
||||
glEnableVertexAttribArray (1);
|
||||
glBindBuffer (GL_ARRAY_BUFFER, paint_data->tmp_uv_buffer);
|
||||
glBufferData (GL_ARRAY_BUFFER, sizeof(uv_buffer_data), uv_buffer_data, GL_STREAM_DRAW);
|
||||
glVertexAttribPointer (uv_location, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
||||
glDrawArrays (GL_TRIANGLE_FAN, 0, 4);
|
||||
glDisableVertexAttribArray (0);
|
||||
glDisableVertexAttribArray (1);
|
||||
}
|
||||
|
||||
|
||||
/* x,y,width,height describes a rectangle in the gl render buffer
|
||||
coordinate space, and its top left corner is drawn at the current
|
||||
position according to the cairo translation. */
|
||||
@@ -302,8 +54,6 @@ gdk_gl_texture_quad (GdkGLContext *paint_context,
|
||||
* This is the main way to draw GL content in GTK+. It takes a render buffer ID
|
||||
* (@source_type == #GL_RENDERBUFFER) or a texture id (@source_type == #GL_TEXTURE)
|
||||
* and draws it onto @cr with an OVER operation, respecting the current clip.
|
||||
* The top left corner of the rectangle specified by @x, @y, @width and @height
|
||||
* will be drawn at the current (0,0) position of the cairo_t.
|
||||
*
|
||||
* This will work for *all* cairo_t, as long as @window is realized, but the
|
||||
* fallback implementation that reads back the pixels from the buffer may be
|
||||
@@ -314,8 +64,6 @@ gdk_gl_texture_quad (GdkGLContext *paint_context,
|
||||
* For #GL_RENDERBUFFER the code will always fall back to software for buffers
|
||||
* with alpha components, so make sure you use #GL_TEXTURE if using alpha.
|
||||
*
|
||||
* Calling this may change the current GL context.
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
void
|
||||
@@ -329,24 +77,23 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
GdkGLContext *paint_context;
|
||||
GdkGLContext *context;
|
||||
cairo_surface_t *image;
|
||||
cairo_matrix_t matrix;
|
||||
int dx, dy, window_scale;
|
||||
gboolean trivial_transform;
|
||||
cairo_surface_t *group_target;
|
||||
GdkWindow *direct_window, *impl_window;
|
||||
guint framebuffer;
|
||||
int alpha_size = 0;
|
||||
GLuint framebuffer;
|
||||
GLint alpha_size = 0;
|
||||
cairo_region_t *clip_region;
|
||||
GdkGLContextPaintData *paint_data;
|
||||
|
||||
impl_window = window->impl_window;
|
||||
|
||||
window_scale = gdk_window_get_scale_factor (impl_window);
|
||||
|
||||
paint_context = gdk_window_get_paint_gl_context (window, NULL);
|
||||
if (paint_context == NULL)
|
||||
context = gdk_window_get_paint_gl_context (window, NULL);
|
||||
if (context == NULL)
|
||||
{
|
||||
g_warning ("gdk_cairo_draw_gl_render_buffer failed - no paint context");
|
||||
return;
|
||||
@@ -354,22 +101,27 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
|
||||
clip_region = gdk_cairo_region_from_clip (cr);
|
||||
|
||||
gdk_gl_context_make_current (paint_context);
|
||||
paint_data = gdk_gl_context_get_paint_data (paint_context);
|
||||
gdk_gl_context_make_current (context);
|
||||
|
||||
if (paint_data->tmp_framebuffer == 0)
|
||||
glGenFramebuffersEXT (1, &paint_data->tmp_framebuffer);
|
||||
glGenFramebuffersEXT (1, &framebuffer);
|
||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, framebuffer);
|
||||
|
||||
if (source_type == GL_RENDERBUFFER)
|
||||
{
|
||||
glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, source);
|
||||
glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_ALPHA_SIZE, &alpha_size);
|
||||
|
||||
glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, source);
|
||||
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_RENDERBUFFER_EXT, source);
|
||||
glBindFramebufferEXT (GL_DRAW_FRAMEBUFFER_EXT, 0);
|
||||
}
|
||||
else if (source_type == GL_TEXTURE)
|
||||
{
|
||||
glBindTexture (GL_TEXTURE_2D, source);
|
||||
|
||||
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &alpha_size);
|
||||
|
||||
glBindFramebufferEXT (GL_DRAW_FRAMEBUFFER_EXT, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -393,34 +145,25 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
|
||||
/* For direct paint of non-alpha renderbuffer, we can
|
||||
just do a bitblit */
|
||||
if ((_gdk_gl_flags & GDK_GL_SOFTWARE_DRAW_GL) == 0 &&
|
||||
source_type == GL_RENDERBUFFER &&
|
||||
if (source_type == GL_RENDERBUFFER &&
|
||||
alpha_size == 0 &&
|
||||
direct_window != NULL &&
|
||||
direct_window->current_paint.use_gl &&
|
||||
trivial_transform &&
|
||||
clip_region != NULL)
|
||||
{
|
||||
int unscaled_window_height;
|
||||
int window_height;
|
||||
int i;
|
||||
|
||||
/* Create a framebuffer with the source renderbuffer and
|
||||
make it the current target for reads */
|
||||
framebuffer = paint_data->tmp_framebuffer;
|
||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, framebuffer);
|
||||
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_RENDERBUFFER_EXT, source);
|
||||
glBindFramebufferEXT (GL_DRAW_FRAMEBUFFER_EXT, 0);
|
||||
|
||||
/* Translate to impl coords */
|
||||
cairo_region_translate (clip_region, dx, dy);
|
||||
|
||||
glEnable (GL_SCISSOR_TEST);
|
||||
|
||||
gdk_window_get_unscaled_size (impl_window, NULL, &unscaled_window_height);
|
||||
window_height = gdk_window_get_height (impl_window);
|
||||
glDrawBuffer (GL_BACK);
|
||||
|
||||
#define FLIP_Y(_y) (unscaled_window_height - (_y))
|
||||
#define FLIP_Y(_y) (window_height*window_scale - (_y))
|
||||
|
||||
for (i = 0; i < cairo_region_num_rectangles (clip_region); i++)
|
||||
{
|
||||
@@ -468,20 +211,17 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
|
||||
glDisable (GL_SCISSOR_TEST);
|
||||
|
||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
|
||||
|
||||
#undef FLIP_Y
|
||||
|
||||
}
|
||||
/* For direct paint of alpha or non-alpha textures we can use texturing */
|
||||
else if ((_gdk_gl_flags & GDK_GL_SOFTWARE_DRAW_GL) == 0 &&
|
||||
source_type == GL_TEXTURE &&
|
||||
else if (source_type == GL_TEXTURE &&
|
||||
direct_window != NULL &&
|
||||
direct_window->current_paint.use_gl &&
|
||||
trivial_transform &&
|
||||
clip_region != NULL)
|
||||
{
|
||||
int unscaled_window_height;
|
||||
int window_height;
|
||||
GLint texture_width;
|
||||
GLint texture_height;
|
||||
int i;
|
||||
@@ -522,13 +262,15 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_TEXTURE_2D, source, 0);
|
||||
|
||||
glEnable (GL_SCISSOR_TEST);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
|
||||
gdk_window_get_unscaled_size (impl_window, NULL, &unscaled_window_height);
|
||||
window_height = gdk_window_get_height (impl_window);
|
||||
|
||||
#define FLIP_Y(_y) (unscaled_window_height - (_y))
|
||||
#define FLIP_Y(_y) (window_height*window_scale - (_y))
|
||||
|
||||
for (i = 0; i < cairo_region_num_rectangles (clip_region); i++)
|
||||
{
|
||||
@@ -554,12 +296,19 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
int clipped_src_x = x + (dest.x - dx * window_scale);
|
||||
int clipped_src_y = y + (height - dest.height - (dest.y - dy * window_scale));
|
||||
|
||||
gdk_gl_texture_quad (paint_context,
|
||||
GL_TEXTURE_2D,
|
||||
dest.x, FLIP_Y(dest.y),
|
||||
dest.x + dest.width, FLIP_Y(dest.y + dest.height),
|
||||
clipped_src_x / (float)texture_width, (clipped_src_y + dest.height) / (float)texture_height,
|
||||
(clipped_src_x + dest.width) / (float)texture_width, clipped_src_y / (float)texture_height);
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2f (clipped_src_x / (float)texture_width, clipped_src_y / (float)texture_height);
|
||||
glVertex2f (dest.x, FLIP_Y(dest.y + dest.height));
|
||||
|
||||
glTexCoord2f ((clipped_src_x + dest.width) / (float)texture_width, clipped_src_y / (float)texture_height);
|
||||
glVertex2f (dest.x + dest.width, FLIP_Y(dest.y + dest.height));
|
||||
|
||||
glTexCoord2f ((clipped_src_x + dest.width) / (float)texture_width, (clipped_src_y + dest.height) / (float)texture_height);
|
||||
glVertex2f (dest.x + dest.width, FLIP_Y(dest.y));
|
||||
|
||||
glTexCoord2f (clipped_src_x / (float)texture_width, (clipped_src_y + dest.height) / (float)texture_height);
|
||||
glVertex2f (dest.x, FLIP_Y(dest.y));
|
||||
glEnd();
|
||||
|
||||
if (impl_window->current_paint.flushed_region)
|
||||
{
|
||||
@@ -596,23 +345,9 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
(alpha_size == 0) ? CAIRO_FORMAT_RGB24 : CAIRO_FORMAT_ARGB32,
|
||||
width, height);
|
||||
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_set_device_scale (image, buffer_scale, buffer_scale);
|
||||
|
||||
framebuffer = paint_data->tmp_framebuffer;
|
||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, framebuffer);
|
||||
|
||||
if (source_type == GL_RENDERBUFFER)
|
||||
{
|
||||
/* Create a framebuffer with the source renderbuffer and
|
||||
make it the current target for reads */
|
||||
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_RENDERBUFFER_EXT, source);
|
||||
}
|
||||
else
|
||||
{
|
||||
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_TEXTURE_2D, source, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
glPixelStorei (GL_PACK_ALIGNMENT, 4);
|
||||
glPixelStorei (GL_PACK_ROW_LENGTH, cairo_image_surface_get_stride (image) / 4);
|
||||
@@ -622,8 +357,6 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
|
||||
glPixelStorei (GL_PACK_ROW_LENGTH, 0);
|
||||
|
||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
|
||||
|
||||
cairo_surface_mark_dirty (image);
|
||||
|
||||
/* Invert due to opengl having different origin */
|
||||
@@ -637,22 +370,27 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
cairo_surface_destroy (image);
|
||||
}
|
||||
|
||||
glDrawBuffer (GL_BACK);
|
||||
glReadBuffer(GL_BACK);
|
||||
|
||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
|
||||
glDeleteFramebuffersEXT (1, &framebuffer);
|
||||
|
||||
if (clip_region)
|
||||
cairo_region_destroy (clip_region);
|
||||
}
|
||||
|
||||
/* This is always called with the paint context current */
|
||||
void
|
||||
gdk_gl_texture_from_surface (cairo_surface_t *surface,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkGLContext *paint_context;
|
||||
GdkGLContext *current;
|
||||
cairo_surface_t *image;
|
||||
double device_x_offset, device_y_offset;
|
||||
cairo_rectangle_int_t rect, e;
|
||||
int n_rects, i;
|
||||
GdkWindow *window;
|
||||
int unscaled_window_height;
|
||||
int window_height;
|
||||
unsigned int texture_id;
|
||||
int window_scale;
|
||||
double sx, sy;
|
||||
@@ -660,22 +398,24 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface,
|
||||
gboolean use_texture_rectangle;
|
||||
guint target;
|
||||
|
||||
paint_context = gdk_gl_context_get_current ();
|
||||
if ((_gdk_gl_flags & GDK_GL_SOFTWARE_DRAW_SURFACE) == 0 &&
|
||||
paint_context &&
|
||||
GDK_GL_CONTEXT_GET_CLASS (paint_context)->texture_from_surface &&
|
||||
GDK_GL_CONTEXT_GET_CLASS (paint_context)->texture_from_surface (paint_context, surface, region))
|
||||
current = gdk_gl_context_get_current ();
|
||||
if (current &&
|
||||
GDK_GL_CONTEXT_GET_CLASS (current)->texture_from_surface &&
|
||||
GDK_GL_CONTEXT_GET_CLASS (current)->texture_from_surface (current, surface, region))
|
||||
return;
|
||||
|
||||
/* Software fallback */
|
||||
use_texture_rectangle = gdk_gl_context_use_texture_rectangle (paint_context);
|
||||
|
||||
window = gdk_gl_context_get_window (paint_context);
|
||||
use_texture_rectangle = gdk_gl_context_use_texture_rectangle (current);
|
||||
|
||||
window = gdk_gl_context_get_window (current);
|
||||
window_scale = gdk_window_get_scale_factor (window);
|
||||
gdk_window_get_unscaled_size (window, NULL, &unscaled_window_height);
|
||||
window_height = gdk_window_get_height (window);
|
||||
|
||||
sx = sy = 1;
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_get_device_scale (window->current_paint.surface, &sx, &sy);
|
||||
#endif
|
||||
|
||||
cairo_surface_get_device_offset (surface,
|
||||
&device_x_offset, &device_y_offset);
|
||||
@@ -688,19 +428,18 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface,
|
||||
|
||||
glBindTexture (target, texture_id);
|
||||
glEnable (target);
|
||||
glEnable (GL_SCISSOR_TEST);
|
||||
|
||||
glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
n_rects = cairo_region_num_rectangles (region);
|
||||
for (i = 0; i < n_rects; i++)
|
||||
{
|
||||
cairo_region_get_rectangle (region, i, &rect);
|
||||
|
||||
glScissor (rect.x * window_scale, unscaled_window_height - (rect.y + rect.height) * window_scale,
|
||||
glScissor (rect.x * window_scale, (window_height - rect.y - rect.height) * window_scale,
|
||||
rect.width * window_scale, rect.height * window_scale);
|
||||
|
||||
e = rect;
|
||||
@@ -720,7 +459,7 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface,
|
||||
|
||||
cairo_surface_unmap_image (surface, image);
|
||||
|
||||
#define FLIP_Y(_y) (unscaled_window_height - (_y))
|
||||
#define FLIP_Y(_y) (window_height - (_y))
|
||||
|
||||
if (use_texture_rectangle)
|
||||
{
|
||||
@@ -733,14 +472,21 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface,
|
||||
vmax = 1.0;
|
||||
}
|
||||
|
||||
gdk_gl_texture_quad (paint_context, target,
|
||||
rect.x * window_scale, FLIP_Y(rect.y),
|
||||
(rect.x + rect.width) * window_scale, FLIP_Y((rect.y + rect.height) * window_scale),
|
||||
0, 0,
|
||||
umax, vmax);
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2f (0, vmax);
|
||||
glVertex2f (rect.x * window_scale, FLIP_Y(rect.y + rect.height) * window_scale);
|
||||
|
||||
glTexCoord2f (umax, vmax);
|
||||
glVertex2f ((rect.x + rect.width) * window_scale, FLIP_Y(rect.y + rect.height) * window_scale);
|
||||
|
||||
glTexCoord2f (umax, 0);
|
||||
glVertex2f ((rect.x + rect.width) * window_scale, FLIP_Y(rect.y) * window_scale);
|
||||
|
||||
glTexCoord2f (0, 0);
|
||||
glVertex2f (rect.x * window_scale, FLIP_Y(rect.y) * window_scale);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
glDisable (GL_SCISSOR_TEST);
|
||||
glDisable (target);
|
||||
glDeleteTextures (1, &texture_id);
|
||||
}
|
||||
|
||||
+47
-247
@@ -72,34 +72,27 @@
|
||||
|
||||
#include "gdkglcontextprivate.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkvisual.h"
|
||||
#include "gdkinternals.h"
|
||||
|
||||
#include "gdkintl.h"
|
||||
#include "gdk-private.h"
|
||||
|
||||
#include <epoxy/gl.h>
|
||||
|
||||
typedef struct {
|
||||
GdkDisplay *display;
|
||||
GdkWindow *window;
|
||||
GdkGLContext *shared_context;
|
||||
GdkGLProfile profile;
|
||||
GdkVisual *visual;
|
||||
|
||||
guint realized : 1;
|
||||
guint use_texture_rectangle : 1;
|
||||
guint has_gl_framebuffer_blit : 1;
|
||||
guint has_frame_terminator : 1;
|
||||
|
||||
GdkGLContextPaintData *paint_data;
|
||||
} GdkGLContextPrivate;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
|
||||
PROP_DISPLAY,
|
||||
PROP_WINDOW,
|
||||
PROP_PROFILE,
|
||||
PROP_SHARED_CONTEXT,
|
||||
PROP_VISUAL,
|
||||
|
||||
LAST_PROP
|
||||
};
|
||||
@@ -110,35 +103,20 @@ G_DEFINE_QUARK (gdk-gl-error-quark, gdk_gl_error)
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkGLContext, gdk_gl_context, G_TYPE_OBJECT)
|
||||
|
||||
static GPrivate thread_current_context = G_PRIVATE_INIT (g_object_unref);
|
||||
|
||||
static void
|
||||
gdk_gl_context_dispose (GObject *gobject)
|
||||
{
|
||||
GdkGLContext *context = GDK_GL_CONTEXT (gobject);
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
GdkGLContext *current;
|
||||
|
||||
current = g_private_get (&thread_current_context);
|
||||
if (current == context)
|
||||
g_private_replace (&thread_current_context, NULL);
|
||||
gdk_display_destroy_gl_context (gdk_window_get_display (priv->window), context);
|
||||
|
||||
g_clear_object (&priv->display);
|
||||
g_clear_object (&priv->window);
|
||||
g_clear_object (&priv->shared_context);
|
||||
g_clear_object (&priv->visual);
|
||||
|
||||
G_OBJECT_CLASS (gdk_gl_context_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gl_context_finalize (GObject *gobject)
|
||||
{
|
||||
GdkGLContext *context = GDK_GL_CONTEXT (gobject);
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
|
||||
g_clear_pointer (&priv->paint_data, g_free);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gl_context_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
@@ -149,20 +127,6 @@ gdk_gl_context_set_property (GObject *gobject,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DISPLAY:
|
||||
{
|
||||
GdkDisplay *display = g_value_get_object (value);
|
||||
|
||||
if (display)
|
||||
g_object_ref (display);
|
||||
|
||||
if (priv->display)
|
||||
g_object_unref (priv->display);
|
||||
|
||||
priv->display = display;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_WINDOW:
|
||||
{
|
||||
GdkWindow *window = g_value_get_object (value);
|
||||
@@ -177,19 +141,15 @@ gdk_gl_context_set_property (GObject *gobject,
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_SHARED_CONTEXT:
|
||||
case PROP_VISUAL:
|
||||
{
|
||||
GdkGLContext *context = g_value_get_object (value);
|
||||
GdkVisual *visual = g_value_get_object (value);
|
||||
|
||||
if (context != NULL)
|
||||
priv->shared_context = g_object_ref (context);
|
||||
if (visual != NULL)
|
||||
priv->visual = g_object_ref (visual);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_PROFILE:
|
||||
priv->profile = g_value_get_enum (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
}
|
||||
@@ -205,20 +165,12 @@ gdk_gl_context_get_property (GObject *gobject,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DISPLAY:
|
||||
g_value_set_object (value, priv->display);
|
||||
break;
|
||||
|
||||
case PROP_WINDOW:
|
||||
g_value_set_object (value, priv->window);
|
||||
break;
|
||||
|
||||
case PROP_SHARED_CONTEXT:
|
||||
g_value_set_object (value, priv->shared_context);
|
||||
break;
|
||||
|
||||
case PROP_PROFILE:
|
||||
g_value_set_enum (value, priv->profile);
|
||||
case PROP_VISUAL:
|
||||
g_value_set_object (value, priv->visual);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -231,22 +183,6 @@ gdk_gl_context_class_init (GdkGLContextClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
/**
|
||||
* GdkGLContext:display:
|
||||
*
|
||||
* The #GdkWindow the gl context is bound to.
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
obj_pspecs[PROP_DISPLAY] =
|
||||
g_param_spec_object ("display",
|
||||
P_("Display"),
|
||||
P_("The GDK display the context is from"),
|
||||
GDK_TYPE_DISPLAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkGLContext:window:
|
||||
*
|
||||
@@ -264,34 +200,17 @@ gdk_gl_context_class_init (GdkGLContextClass *klass)
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkGLContext:profile:
|
||||
* GdkGLContext:visual:
|
||||
*
|
||||
* The #GdkGLProfile of the context
|
||||
* The #GdkVisual matching the pixel format used by the context.
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
obj_pspecs[PROP_PROFILE] =
|
||||
g_param_spec_enum ("profile",
|
||||
P_("Profile"),
|
||||
P_("The GL profile the context was created for"),
|
||||
GDK_TYPE_GL_PROFILE,
|
||||
GDK_GL_PROFILE_DEFAULT,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkGLContext:shared-context:
|
||||
*
|
||||
* The #GdkGLContext that this context is sharing data with, or #NULL
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
obj_pspecs[PROP_SHARED_CONTEXT] =
|
||||
g_param_spec_object ("shared-context",
|
||||
P_("Shared context"),
|
||||
P_("The GL context this context share data with"),
|
||||
GDK_TYPE_GL_CONTEXT,
|
||||
obj_pspecs[PROP_VISUAL] =
|
||||
g_param_spec_object ("visual",
|
||||
P_("Visual"),
|
||||
P_("The GDK visual used by the GL context"),
|
||||
GDK_TYPE_VISUAL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
@@ -299,7 +218,6 @@ gdk_gl_context_class_init (GdkGLContextClass *klass)
|
||||
gobject_class->set_property = gdk_gl_context_set_property;
|
||||
gobject_class->get_property = gdk_gl_context_get_property;
|
||||
gobject_class->dispose = gdk_gl_context_dispose;
|
||||
gobject_class->finalize = gdk_gl_context_finalize;
|
||||
|
||||
g_object_class_install_properties (gobject_class, LAST_PROP, obj_pspecs);
|
||||
}
|
||||
@@ -309,6 +227,26 @@ gdk_gl_context_init (GdkGLContext *self)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_context_get_visual:
|
||||
* @context: a #GdkGLContext
|
||||
*
|
||||
* Retrieves the #GdkVisual associated with the @context.
|
||||
*
|
||||
* Returns: (transfer none): the #GdkVisual
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
GdkVisual *
|
||||
gdk_gl_context_get_visual (GdkGLContext *context)
|
||||
{
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), NULL);
|
||||
|
||||
return priv->visual;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_gl_context_end_frame:
|
||||
* @context: a #GdkGLContext
|
||||
@@ -333,18 +271,6 @@ gdk_gl_context_end_frame (GdkGLContext *context,
|
||||
GDK_GL_CONTEXT_GET_CLASS (context)->end_frame (context, painted, damage);
|
||||
}
|
||||
|
||||
GdkGLContextPaintData *
|
||||
gdk_gl_context_get_paint_data (GdkGLContext *context)
|
||||
{
|
||||
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
|
||||
if (priv->paint_data == NULL)
|
||||
priv->paint_data = g_new0 (GdkGLContextPaintData, 1);
|
||||
|
||||
return priv->paint_data;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_gl_context_use_texture_rectangle (GdkGLContext *context)
|
||||
{
|
||||
@@ -353,22 +279,6 @@ gdk_gl_context_use_texture_rectangle (GdkGLContext *context)
|
||||
return priv->use_texture_rectangle;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_gl_context_has_framebuffer_blit (GdkGLContext *context)
|
||||
{
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
|
||||
return priv->has_gl_framebuffer_blit;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_gl_context_has_frame_terminator (GdkGLContext *context)
|
||||
{
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
|
||||
return priv->has_frame_terminator;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gl_context_realize (GdkGLContext *context)
|
||||
{
|
||||
@@ -378,17 +288,12 @@ gdk_gl_context_realize (GdkGLContext *context)
|
||||
has_npot = epoxy_has_gl_extension ("GL_ARB_texture_non_power_of_two");
|
||||
has_texture_rectangle = epoxy_has_gl_extension ("GL_ARB_texture_rectangle");
|
||||
|
||||
priv->has_gl_framebuffer_blit = epoxy_has_gl_extension ("GL_EXT_framebuffer_blit");
|
||||
priv->has_frame_terminator = epoxy_has_gl_extension ("GL_GREMEDY_frame_terminator");
|
||||
|
||||
if (_gdk_gl_flags & GDK_GL_TEXTURE_RECTANGLE)
|
||||
priv->use_texture_rectangle = TRUE;
|
||||
else if (has_npot)
|
||||
if (has_npot)
|
||||
priv->use_texture_rectangle = FALSE;
|
||||
else if (has_texture_rectangle)
|
||||
priv->use_texture_rectangle = TRUE;
|
||||
else
|
||||
g_warning ("GL implementation doesn't support any form of non-power-of-two textures");
|
||||
g_warning ("Gl implementation doesn't support any form of non-power-of-two textures");
|
||||
|
||||
priv->realized = TRUE;
|
||||
}
|
||||
@@ -405,40 +310,13 @@ void
|
||||
gdk_gl_context_make_current (GdkGLContext *context)
|
||||
{
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
GdkGLContext *current;
|
||||
|
||||
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
||||
|
||||
current = g_private_get (&thread_current_context);
|
||||
if (current == context)
|
||||
return;
|
||||
gdk_display_make_gl_context_current (gdk_window_get_display (priv->window), context);
|
||||
|
||||
if (gdk_display_make_gl_context_current (priv->display, context))
|
||||
{
|
||||
g_private_replace (&thread_current_context, g_object_ref (context));
|
||||
if (!priv->realized)
|
||||
gdk_gl_context_realize (context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_context_get_display:
|
||||
* @context: a #GdkGLContext
|
||||
*
|
||||
* Retrieves the #GdkDisplay the @context is created for
|
||||
*
|
||||
* Returns: (transfer none): a #GdkDisplay or %NULL
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
GdkDisplay *
|
||||
gdk_gl_context_get_display (GdkGLContext *context)
|
||||
{
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), NULL);
|
||||
|
||||
return priv->display;
|
||||
if (!priv->realized)
|
||||
gdk_gl_context_realize (context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -461,46 +339,6 @@ gdk_gl_context_get_window (GdkGLContext *context)
|
||||
return priv->window;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_context_get_profile:
|
||||
* @context: a #GdkGLContext
|
||||
*
|
||||
* Retrieves the #GdkGLProfile that @context was created for.
|
||||
*
|
||||
* Returns: a #GdkGLProfile
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
GdkGLProfile
|
||||
gdk_gl_context_get_profile (GdkGLContext *context)
|
||||
{
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), GDK_GL_PROFILE_LEGACY);
|
||||
|
||||
return priv->profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_context_get_shared_context:
|
||||
* @context: a #GdkGLContext
|
||||
*
|
||||
* Retrieves the #GdkGLContext that this @context share data with.
|
||||
*
|
||||
* Returns: (transfer none): a #GdkGLContext or %NULL
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
GdkGLContext *
|
||||
gdk_gl_context_get_shared_context (GdkGLContext *context)
|
||||
{
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), NULL);
|
||||
|
||||
return priv->shared_context;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_context_clear_current:
|
||||
*
|
||||
@@ -514,16 +352,9 @@ gdk_gl_context_get_shared_context (GdkGLContext *context)
|
||||
void
|
||||
gdk_gl_context_clear_current (void)
|
||||
{
|
||||
GdkGLContext *current;
|
||||
GdkDisplay *display = gdk_display_get_default ();
|
||||
|
||||
current = g_private_get (&thread_current_context);
|
||||
if (current != NULL)
|
||||
{
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (current);
|
||||
|
||||
if (gdk_display_make_gl_context_current (priv->display, NULL))
|
||||
g_private_replace (&thread_current_context, NULL);
|
||||
}
|
||||
gdk_display_make_gl_context_current (display, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -538,38 +369,7 @@ gdk_gl_context_clear_current (void)
|
||||
GdkGLContext *
|
||||
gdk_gl_context_get_current (void)
|
||||
{
|
||||
GdkGLContext *current;
|
||||
GdkDisplay *display = gdk_display_get_default ();
|
||||
|
||||
current = g_private_get (&thread_current_context);
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_get_flags:
|
||||
*
|
||||
* Returns the currently active GL flags.
|
||||
*
|
||||
* Returns: the GL flags
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
GdkGLFlags
|
||||
gdk_gl_get_flags (void)
|
||||
{
|
||||
return _gdk_gl_flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_set_flags:
|
||||
* @flags: #GdkGLFlags to set
|
||||
*
|
||||
* Sets GL flags.
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
void
|
||||
gdk_gl_set_flags (GdkGLFlags flags)
|
||||
{
|
||||
_gdk_gl_flags = flags;
|
||||
return gdk_display_get_current_gl_context (display);
|
||||
}
|
||||
|
||||
+1
-3
@@ -43,11 +43,9 @@ GDK_AVAILABLE_IN_3_16
|
||||
GType gdk_gl_context_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GdkDisplay * gdk_gl_context_get_display (GdkGLContext *context);
|
||||
GdkVisual * gdk_gl_context_get_visual (GdkGLContext *context);
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GdkWindow * gdk_gl_context_get_window (GdkGLContext *context);
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GdkGLProfile gdk_gl_context_get_profile (GdkGLContext *context);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
void gdk_gl_context_make_current (GdkGLContext *context);
|
||||
|
||||
@@ -40,6 +40,7 @@ struct _GdkGLContextClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (* update) (GdkGLContext *context);
|
||||
void (* end_frame) (GdkGLContext *context,
|
||||
cairo_region_t *painted,
|
||||
cairo_region_t *damage);
|
||||
@@ -48,29 +49,10 @@ struct _GdkGLContextClass
|
||||
cairo_region_t *region);
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
guint vertex_array_object;
|
||||
guint tmp_framebuffer;
|
||||
guint tmp_vertex_buffer;
|
||||
guint tmp_uv_buffer;
|
||||
guint current_program;
|
||||
guint texture_quad_program;
|
||||
guint texture_quad_program_position_location;
|
||||
guint texture_quad_program_uv_location;
|
||||
guint texture_quad_program_map_location;
|
||||
guint texture_quad_rect_program;
|
||||
guint texture_quad_rect_program_position_location;
|
||||
guint texture_quad_rect_program_uv_location;
|
||||
guint texture_quad_rect_program_map_location;
|
||||
} GdkGLContextPaintData;
|
||||
|
||||
GdkGLContextPaintData *gdk_gl_context_get_paint_data (GdkGLContext *context);
|
||||
gboolean gdk_gl_context_use_texture_rectangle (GdkGLContext *context);
|
||||
gboolean gdk_gl_context_has_framebuffer_blit (GdkGLContext *context);
|
||||
gboolean gdk_gl_context_has_frame_terminator (GdkGLContext *context);
|
||||
void gdk_gl_context_end_frame (GdkGLContext *context,
|
||||
cairo_region_t *painted,
|
||||
cairo_region_t *damage);
|
||||
gboolean gdk_gl_context_use_texture_rectangle (GdkGLContext *context);
|
||||
void gdk_gl_context_end_frame (GdkGLContext *context,
|
||||
cairo_region_t *painted,
|
||||
cairo_region_t *damage);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -34,5 +34,4 @@ GList *_gdk_default_filters = NULL;
|
||||
gchar *_gdk_display_name = NULL;
|
||||
gchar *_gdk_display_arg_name = NULL;
|
||||
gboolean _gdk_disable_multidevice = FALSE;
|
||||
guint _gdk_gl_flags = 0;
|
||||
GdkRenderingMode _gdk_rendering_mode = GDK_RENDERING_MODE_SIMILAR;
|
||||
|
||||
+3
-20
@@ -85,7 +85,8 @@ typedef enum {
|
||||
GDK_DEBUG_EVENTLOOP = 1 << 10,
|
||||
GDK_DEBUG_FRAMES = 1 << 11,
|
||||
GDK_DEBUG_SETTINGS = 1 << 12,
|
||||
GDK_DEBUG_OPENGL = 1 << 13,
|
||||
GDK_DEBUG_NOGL = 1 << 13,
|
||||
GDK_DEBUG_OPENGL = 1 << 14
|
||||
} GdkDebugFlag;
|
||||
|
||||
typedef enum {
|
||||
@@ -94,21 +95,11 @@ typedef enum {
|
||||
GDK_RENDERING_MODE_RECORDING
|
||||
} GdkRenderingMode;
|
||||
|
||||
typedef enum {
|
||||
GDK_GL_DISABLE = 1 << 0,
|
||||
GDK_GL_ALWAYS = 1 << 1,
|
||||
GDK_GL_SOFTWARE_DRAW_GL = 1 << 2,
|
||||
GDK_GL_SOFTWARE_DRAW_SURFACE = 1 << 3,
|
||||
GDK_GL_TEXTURE_RECTANGLE = 1 << 4
|
||||
} GdkGLFlags;
|
||||
|
||||
extern GList *_gdk_default_filters;
|
||||
extern GdkWindow *_gdk_parent_root;
|
||||
|
||||
extern guint _gdk_debug_flags;
|
||||
extern guint _gdk_gl_flags;
|
||||
extern GdkRenderingMode _gdk_rendering_mode;
|
||||
extern gboolean _gdk_debug_updates;
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
|
||||
@@ -350,12 +341,6 @@ gboolean _gdk_cairo_surface_extents (cairo_surface_t *surface,
|
||||
GdkRectangle *extents);
|
||||
void gdk_gl_texture_from_surface (cairo_surface_t *surface,
|
||||
cairo_region_t *region);
|
||||
void gdk_gl_texture_quad (GdkGLContext *paint_context,
|
||||
guint texture_target,
|
||||
float x1, float y1,
|
||||
float x2, float y2,
|
||||
float u1, float v1,
|
||||
float u2, float v2);
|
||||
void gdk_cairo_surface_mark_as_direct (cairo_surface_t *surface,
|
||||
GdkWindow *window);
|
||||
cairo_region_t *gdk_cairo_region_from_clip (cairo_t *cr);
|
||||
@@ -375,9 +360,7 @@ void _gdk_window_update_size (GdkWindow *window);
|
||||
gboolean _gdk_window_update_viewable (GdkWindow *window);
|
||||
GdkGLContext * gdk_window_get_paint_gl_context (GdkWindow *window,
|
||||
GError **error);
|
||||
void gdk_window_get_unscaled_size (GdkWindow *window,
|
||||
int *unscaled_width,
|
||||
int *unscaled_height);
|
||||
|
||||
|
||||
void _gdk_window_process_updates_recurse (GdkWindow *window,
|
||||
cairo_region_t *expose_region);
|
||||
|
||||
+2
-2
@@ -49,9 +49,9 @@ void gdk_init (gint *argc,
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_init_check (gint *argc,
|
||||
gchar ***argv);
|
||||
GDK_DEPRECATED_IN_3_16
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_add_option_entries_libgtk_only (GOptionGroup *group);
|
||||
GDK_DEPRECATED_IN_3_16
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_pre_parse_libgtk_only (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
||||
+1
-3
@@ -310,7 +310,6 @@ typedef enum
|
||||
* @GDK_GRAB_NOT_VIEWABLE: the grab window or the @confine_to window are not
|
||||
* viewable.
|
||||
* @GDK_GRAB_FROZEN: the resource is frozen by an active grab of another client.
|
||||
* @GDK_GRAB_FAILED: the grab failed for some other reason.
|
||||
*
|
||||
* Returned by gdk_device_grab(), gdk_pointer_grab() and gdk_keyboard_grab() to
|
||||
* indicate success or the reason for the failure of the grab attempt.
|
||||
@@ -321,8 +320,7 @@ typedef enum
|
||||
GDK_GRAB_ALREADY_GRABBED = 1,
|
||||
GDK_GRAB_INVALID_TIME = 2,
|
||||
GDK_GRAB_NOT_VIEWABLE = 3,
|
||||
GDK_GRAB_FROZEN = 4,
|
||||
GDK_GRAB_FAILED = 5
|
||||
GDK_GRAB_FROZEN = 4
|
||||
} GdkGrabStatus;
|
||||
|
||||
/**
|
||||
|
||||
+52
-117
@@ -40,7 +40,6 @@
|
||||
#include "gdkframeclockidle.h"
|
||||
#include "gdkwindowimpl.h"
|
||||
#include "gdkglcontextprivate.h"
|
||||
#include "gdk-private.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
@@ -288,11 +287,16 @@ create_surface_accumulator (GSignalInvocationHint *ihint,
|
||||
|
||||
static GQuark quark_pointer_window = 0;
|
||||
|
||||
static gboolean always_use_gl = FALSE;
|
||||
|
||||
static void
|
||||
gdk_window_class_init (GdkWindowClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
if (g_getenv ("GDK_ALWAYS_USE_GL"))
|
||||
always_use_gl = TRUE;
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gdk_window_finalize;
|
||||
@@ -1420,7 +1424,7 @@ gdk_window_new (GdkWindow *parent,
|
||||
G_CALLBACK (device_removed_cb), window);
|
||||
|
||||
|
||||
if ((_gdk_gl_flags & (GDK_GL_ALWAYS | GDK_GL_DISABLE)) == GDK_GL_ALWAYS)
|
||||
if (always_use_gl)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
@@ -1989,14 +1993,6 @@ _gdk_window_destroy_hierarchy (GdkWindow *window,
|
||||
}
|
||||
}
|
||||
|
||||
if (window->gl_paint_context)
|
||||
{
|
||||
/* Make sure to destroy if current */
|
||||
g_object_run_dispose (G_OBJECT (window->gl_paint_context));
|
||||
g_object_unref (window->gl_paint_context);
|
||||
window->gl_paint_context = NULL;
|
||||
}
|
||||
|
||||
if (window->frame_clock)
|
||||
{
|
||||
g_object_run_dispose (G_OBJECT (window->frame_clock));
|
||||
@@ -2726,7 +2722,7 @@ gdk_window_ref_impl_surface (GdkWindow *window)
|
||||
GdkGLContext *
|
||||
gdk_window_get_paint_gl_context (GdkWindow *window, GError **error)
|
||||
{
|
||||
if (_gdk_gl_flags & GDK_GL_DISABLE)
|
||||
if (_gdk_debug_flags & GDK_DEBUG_NOGL)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
@@ -2735,26 +2731,12 @@ gdk_window_get_paint_gl_context (GdkWindow *window, GError **error)
|
||||
}
|
||||
|
||||
if (window->impl_window->gl_paint_context == NULL)
|
||||
{
|
||||
window->impl_window->gl_paint_context =
|
||||
GDK_WINDOW_IMPL_GET_CLASS (window->impl)->create_gl_context (window,
|
||||
TRUE,
|
||||
GDK_GL_PROFILE_3_2_CORE,
|
||||
NULL,
|
||||
error);
|
||||
if (window->impl_window->gl_paint_context == NULL &&
|
||||
g_error_matches (*error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_UNSUPPORTED_PROFILE))
|
||||
{
|
||||
g_clear_error (error);
|
||||
window->impl_window->gl_paint_context =
|
||||
GDK_WINDOW_IMPL_GET_CLASS (window->impl)->create_gl_context (window,
|
||||
TRUE,
|
||||
GDK_GL_PROFILE_DEFAULT,
|
||||
NULL,
|
||||
error);
|
||||
}
|
||||
}
|
||||
window->impl_window->gl_paint_context =
|
||||
GDK_WINDOW_IMPL_GET_CLASS (window->impl)->create_gl_context (window,
|
||||
TRUE,
|
||||
GDK_GL_PROFILE_DEFAULT,
|
||||
NULL,
|
||||
error);
|
||||
|
||||
return window->impl_window->gl_paint_context;
|
||||
}
|
||||
@@ -2935,6 +2917,13 @@ gdk_window_begin_paint_region (GdkWindow *window,
|
||||
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
|
||||
glViewport (0, 0, ww, wh);
|
||||
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
glOrtho (0.0f, ww, 0.0f, wh, -1.0f, 1.0f);
|
||||
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
glLoadIdentity ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2945,7 +2934,9 @@ gdk_window_begin_paint_region (GdkWindow *window,
|
||||
MAX (clip_box.width, 1),
|
||||
MAX (clip_box.height, 1));
|
||||
sx = sy = 1;
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_get_device_scale (window->current_paint.surface, &sx, &sy);
|
||||
#endif
|
||||
cairo_surface_set_device_offset (window->current_paint.surface, -clip_box.x*sx, -clip_box.y*sy);
|
||||
gdk_cairo_surface_mark_as_direct (window->current_paint.surface, window);
|
||||
|
||||
@@ -3019,7 +3010,6 @@ gdk_window_mark_paint_from_clip (GdkWindow *window,
|
||||
cairo_region_subtract (impl_window->current_paint.flushed_region, clip_region);
|
||||
cairo_region_union (impl_window->current_paint.need_blend_region, clip_region);
|
||||
}
|
||||
cairo_region_destroy (clip_region);
|
||||
|
||||
/* Clear the area on the double buffer surface to transparent so we
|
||||
can start drawing from scratch the area "above" the flushed
|
||||
@@ -3069,6 +3059,7 @@ gdk_window_end_paint (GdkWindow *window)
|
||||
if (impl_class->end_paint)
|
||||
impl_class->end_paint (window);
|
||||
|
||||
|
||||
if (window->current_paint.surface_needs_composite)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
@@ -3099,8 +3090,11 @@ gdk_window_end_paint (GdkWindow *window)
|
||||
gdk_gl_context_end_frame (window->gl_paint_context,
|
||||
window->current_paint.region,
|
||||
window->active_update_area);
|
||||
|
||||
if (epoxy_has_gl_extension ("GL_GREMEDY_frame_terminator"))
|
||||
glFrameTerminatorGREMEDY();
|
||||
}
|
||||
else if (!impl_class->do_composite (window))
|
||||
else
|
||||
{
|
||||
surface = gdk_window_ref_impl_surface (window);
|
||||
cr = cairo_create (surface);
|
||||
@@ -3114,8 +3108,6 @@ gdk_window_end_paint (GdkWindow *window)
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_destroy (cr);
|
||||
|
||||
cairo_surface_flush (surface);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3337,7 +3329,7 @@ gdk_cairo_create (GdkWindow *window)
|
||||
/* Code for dirty-region queueing
|
||||
*/
|
||||
static GSList *update_windows = NULL;
|
||||
gboolean _gdk_debug_updates = FALSE;
|
||||
static gboolean debug_updates = FALSE;
|
||||
|
||||
static inline gboolean
|
||||
gdk_window_is_ancestor (GdkWindow *window,
|
||||
@@ -3612,9 +3604,7 @@ gdk_window_process_updates_internal (GdkWindow *window)
|
||||
{
|
||||
GdkWindowImplClass *impl_class;
|
||||
GdkWindow *toplevel;
|
||||
GdkDisplay *display;
|
||||
|
||||
display = gdk_window_get_display (window);
|
||||
toplevel = gdk_window_get_toplevel (window);
|
||||
if (toplevel->geometry_dirty)
|
||||
{
|
||||
@@ -3654,7 +3644,7 @@ gdk_window_process_updates_internal (GdkWindow *window)
|
||||
/* Clip to part visible in impl window */
|
||||
cairo_region_intersect (expose_region, window->clip_region);
|
||||
|
||||
if (gdk_display_get_debug_updates (display))
|
||||
if (debug_updates)
|
||||
{
|
||||
cairo_region_t *swap_region = cairo_region_copy (expose_region);
|
||||
cairo_region_subtract (swap_region, window->active_update_area);
|
||||
@@ -4068,7 +4058,6 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow *window,
|
||||
{
|
||||
cairo_region_t *visible_region;
|
||||
cairo_rectangle_int_t r;
|
||||
GdkDisplay *display;
|
||||
|
||||
g_return_if_fail (GDK_IS_WINDOW (window));
|
||||
|
||||
@@ -4088,8 +4077,7 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow *window,
|
||||
|
||||
invalidate_impl_subwindows (window, region, child_func, user_data, 0, 0);
|
||||
|
||||
display = gdk_window_get_display (window);
|
||||
if (gdk_display_get_debug_updates (display))
|
||||
if (debug_updates)
|
||||
draw_ugly_color (window, visible_region, 0);
|
||||
|
||||
while (window != NULL &&
|
||||
@@ -4383,17 +4371,9 @@ gdk_window_thaw_updates (GdkWindow *window)
|
||||
*
|
||||
* This function is not part of the GDK public API and is only
|
||||
* for use by GTK+.
|
||||
*
|
||||
* Deprecated: 3.16: This symbol was never meant to be used outside of GTK+
|
||||
*/
|
||||
**/
|
||||
void
|
||||
gdk_window_freeze_toplevel_updates_libgtk_only (GdkWindow *window)
|
||||
{
|
||||
gdk_window_freeze_toplevel_updates (window);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_window_freeze_toplevel_updates (GdkWindow *window)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_WINDOW (window));
|
||||
g_return_if_fail (window->window_type != GDK_WINDOW_CHILD);
|
||||
@@ -4411,17 +4391,9 @@ gdk_window_freeze_toplevel_updates (GdkWindow *window)
|
||||
*
|
||||
* This function is not part of the GDK public API and is only
|
||||
* for use by GTK+.
|
||||
*
|
||||
* Deprecated: 3.16: This symbol was never meant to be used outside of GTK+
|
||||
*/
|
||||
**/
|
||||
void
|
||||
gdk_window_thaw_toplevel_updates_libgtk_only (GdkWindow *window)
|
||||
{
|
||||
gdk_window_thaw_toplevel_updates (window);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_window_thaw_toplevel_updates (GdkWindow *window)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_WINDOW (window));
|
||||
g_return_if_fail (window->window_type != GDK_WINDOW_CHILD);
|
||||
@@ -4461,7 +4433,7 @@ gdk_window_thaw_toplevel_updates (GdkWindow *window)
|
||||
void
|
||||
gdk_window_set_debug_updates (gboolean setting)
|
||||
{
|
||||
_gdk_debug_updates = setting;
|
||||
debug_updates = setting;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6043,9 +6015,6 @@ gdk_window_set_cursor_internal (GdkWindow *window,
|
||||
if (GDK_WINDOW_DESTROYED (window))
|
||||
return;
|
||||
|
||||
g_assert (gdk_window_get_display (window) == gdk_device_get_display (device));
|
||||
g_assert (!cursor || gdk_window_get_display (window) == gdk_cursor_get_display (cursor));
|
||||
|
||||
if (window->window_type == GDK_WINDOW_ROOT ||
|
||||
window->window_type == GDK_WINDOW_FOREIGN)
|
||||
GDK_WINDOW_IMPL_GET_CLASS (window->impl)->set_device_cursor (window, device, cursor);
|
||||
@@ -6091,15 +6060,11 @@ gdk_window_get_cursor (GdkWindow *window)
|
||||
* @window: a #GdkWindow
|
||||
* @cursor: (allow-none): a cursor
|
||||
*
|
||||
* Sets the default mouse pointer for a #GdkWindow.
|
||||
*
|
||||
* Note that @cursor must be for the same display as @window.
|
||||
*
|
||||
* Use gdk_cursor_new_for_display() or gdk_cursor_new_from_pixbuf() to
|
||||
* create the cursor. To make the cursor invisible, use %GDK_BLANK_CURSOR.
|
||||
* Passing %NULL for the @cursor argument to gdk_window_set_cursor() means
|
||||
* that @window will use the cursor of its parent window. Most windows
|
||||
* should use this default.
|
||||
* Sets the default mouse pointer for a #GdkWindow. Use gdk_cursor_new_for_display()
|
||||
* or gdk_cursor_new_from_pixbuf() to create the cursor. To make the cursor
|
||||
* invisible, use %GDK_BLANK_CURSOR. Passing %NULL for the @cursor argument
|
||||
* to gdk_window_set_cursor() means that @window will use the cursor of its
|
||||
* parent window. Most windows should use this default.
|
||||
*/
|
||||
void
|
||||
gdk_window_set_cursor (GdkWindow *window,
|
||||
@@ -8028,9 +7993,9 @@ gdk_pointer_grab (GdkWindow * window,
|
||||
gulong serial;
|
||||
GList *devices, *dev;
|
||||
|
||||
g_return_val_if_fail (window != NULL, GDK_GRAB_FAILED);
|
||||
g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_GRAB_FAILED);
|
||||
g_return_val_if_fail (confine_to == NULL || GDK_IS_WINDOW (confine_to), GDK_GRAB_FAILED);
|
||||
g_return_val_if_fail (window != NULL, 0);
|
||||
g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
|
||||
g_return_val_if_fail (confine_to == NULL || GDK_IS_WINDOW (confine_to), 0);
|
||||
|
||||
/* We need a native window for confine to to work, ensure we have one */
|
||||
if (confine_to)
|
||||
@@ -8140,7 +8105,7 @@ gdk_keyboard_grab (GdkWindow *window,
|
||||
gulong serial;
|
||||
GList *devices, *dev;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_GRAB_FAILED);
|
||||
g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
|
||||
|
||||
/* Non-viewable client side window => fail */
|
||||
if (!_gdk_window_has_impl (window) &&
|
||||
@@ -9451,7 +9416,6 @@ gdk_window_create_similar_surface (GdkWindow * window,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
cairo_surface_t *window_surface, *surface;
|
||||
double sx, sy;
|
||||
|
||||
@@ -9459,23 +9423,28 @@ gdk_window_create_similar_surface (GdkWindow * window,
|
||||
|
||||
window_surface = gdk_window_ref_impl_surface (window);
|
||||
sx = sy = 1;
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_get_device_scale (window_surface, &sx, &sy);
|
||||
#endif
|
||||
|
||||
display = gdk_window_get_display (window);
|
||||
switch (display->rendering_mode)
|
||||
switch (_gdk_rendering_mode)
|
||||
{
|
||||
case GDK_RENDERING_MODE_RECORDING:
|
||||
{
|
||||
cairo_rectangle_t rect = { 0, 0, width * sx, height *sy };
|
||||
surface = cairo_recording_surface_create (content, &rect);
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_set_device_scale (surface, sx, sy);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case GDK_RENDERING_MODE_IMAGE:
|
||||
surface = cairo_image_surface_create (content == CAIRO_CONTENT_COLOR ? CAIRO_FORMAT_RGB24 :
|
||||
content == CAIRO_CONTENT_ALPHA ? CAIRO_FORMAT_A8 : CAIRO_FORMAT_ARGB32,
|
||||
width * sx, height * sy);
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_set_device_scale (surface, sx, sy);
|
||||
#endif
|
||||
break;
|
||||
case GDK_RENDERING_MODE_SIMILAR:
|
||||
default:
|
||||
@@ -9553,10 +9522,12 @@ gdk_window_create_similar_image_surface (GdkWindow * window,
|
||||
cairo_surface_destroy (window_surface);
|
||||
}
|
||||
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
if (scale == 0)
|
||||
scale = gdk_window_get_scale_factor (window);
|
||||
|
||||
cairo_surface_set_device_scale (surface, scale, scale);
|
||||
#endif
|
||||
|
||||
return surface;
|
||||
}
|
||||
@@ -10553,12 +10524,7 @@ gdk_window_configure_finished (GdkWindow *window)
|
||||
*
|
||||
* For toplevel windows this depends on support from the windowing system
|
||||
* that may not always be there. For instance, On X11, this works only on
|
||||
* X screens with a compositing manager running. On Wayland, there is no
|
||||
* per-window opacity value that the compositor would apply. Instead, use
|
||||
* `gdk_window_set_opaque_region (window, NULL)` to tell the compositor
|
||||
* that the entire window is (potentially) non-opaque, and draw your content
|
||||
* with alpha, or use gtk_widget_set_opacity() to set an overall opacity
|
||||
* for your widgets.
|
||||
* X screens with a compositing manager running.
|
||||
*
|
||||
* For child windows this function only works for non-native windows.
|
||||
*
|
||||
@@ -11044,37 +11010,6 @@ gdk_window_get_scale_factor (GdkWindow *window)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Returns the *real* unscaled size, which may be a fractional size
|
||||
in window scale coordinates. We need this to properly handle GL
|
||||
coordinates which are y-flipped in the real coordinates. */
|
||||
void
|
||||
gdk_window_get_unscaled_size (GdkWindow *window,
|
||||
int *unscaled_width,
|
||||
int *unscaled_height)
|
||||
{
|
||||
GdkWindowImplClass *impl_class;
|
||||
gint scale;
|
||||
|
||||
g_return_if_fail (GDK_IS_WINDOW (window));
|
||||
|
||||
if (window->impl_window == window)
|
||||
{
|
||||
impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl);
|
||||
|
||||
if (impl_class->get_unscaled_size)
|
||||
return impl_class->get_unscaled_size (window, unscaled_width, unscaled_height);
|
||||
}
|
||||
|
||||
scale = gdk_window_get_scale_factor (window);
|
||||
|
||||
if (unscaled_width)
|
||||
*unscaled_width = window->width * scale;
|
||||
|
||||
if (unscaled_height)
|
||||
*unscaled_height = window->height * scale;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gdk_window_set_opaque_region:
|
||||
* @window: a top-level or non-native #GdkWindow
|
||||
|
||||
+2
-2
@@ -1037,9 +1037,9 @@ void gdk_window_freeze_updates (GdkWindow *window);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_window_thaw_updates (GdkWindow *window);
|
||||
|
||||
GDK_DEPRECATED_IN_3_16
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_window_freeze_toplevel_updates_libgtk_only (GdkWindow *window);
|
||||
GDK_DEPRECATED_IN_3_16
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_window_thaw_toplevel_updates_libgtk_only (GdkWindow *window);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
||||
@@ -46,18 +46,11 @@ gdk_window_impl_process_updates_recurse (GdkWindow *window,
|
||||
_gdk_window_process_updates_recurse (window, region);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_window_impl_do_composite (GdkWindow *window)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_window_impl_class_init (GdkWindowImplClass *impl_class)
|
||||
{
|
||||
impl_class->beep = gdk_window_impl_beep;
|
||||
impl_class->process_updates_recurse = gdk_window_impl_process_updates_recurse;
|
||||
impl_class->do_composite = gdk_window_impl_do_composite;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -279,9 +279,6 @@ struct _GdkWindowImplClass
|
||||
GdkAtom property);
|
||||
|
||||
gint (* get_scale_factor) (GdkWindow *window);
|
||||
void (* get_unscaled_size) (GdkWindow *window,
|
||||
int *unscaled_width,
|
||||
int *unscaled_height);
|
||||
|
||||
void (* set_opaque_region) (GdkWindow *window,
|
||||
cairo_region_t *region);
|
||||
@@ -299,7 +296,6 @@ struct _GdkWindowImplClass
|
||||
GError **error);
|
||||
void (*invalidate_for_new_frame)(GdkWindow *window,
|
||||
cairo_region_t *update_area);
|
||||
gboolean (*do_composite) (GdkWindow *window);
|
||||
};
|
||||
|
||||
/* Interface Functions */
|
||||
|
||||
@@ -24,7 +24,6 @@ libgdk_mir_la_SOURCES = \
|
||||
gdkmirdevicemanager.c \
|
||||
gdkmirdisplay.c \
|
||||
gdkmireventsource.c \
|
||||
gdkmirglcontext.c \
|
||||
gdkmirkeyboard.c \
|
||||
gdkmirkeymap.c \
|
||||
gdkmirpointer.c \
|
||||
|
||||
@@ -18,13 +18,10 @@
|
||||
#ifndef __GDK_PRIVATE_MIR_H__
|
||||
#define __GDK_PRIVATE_MIR_H__
|
||||
|
||||
#include <epoxy/egl.h>
|
||||
|
||||
#include "gdkmir.h"
|
||||
#include "gdkdisplay.h"
|
||||
#include "gdkscreen.h"
|
||||
#include "gdkdevicemanager.h"
|
||||
#include "gdkglcontextprivate.h"
|
||||
#include "gdkkeys.h"
|
||||
#include "gdkwindowimpl.h"
|
||||
|
||||
@@ -38,27 +35,6 @@ typedef struct _GdkMirEventSource GdkMirEventSource;
|
||||
|
||||
GType gdk_mir_window_impl_get_type (void);
|
||||
|
||||
|
||||
struct _GdkMirGLContext
|
||||
{
|
||||
GdkGLContext parent_instance;
|
||||
|
||||
EGLContext egl_context;
|
||||
EGLConfig egl_config;
|
||||
gboolean is_attached;
|
||||
};
|
||||
|
||||
struct _GdkMirGLContextClass
|
||||
{
|
||||
GdkGLContextClass parent_class;
|
||||
};
|
||||
|
||||
typedef struct _GdkMirGLContext GdkMirGLContext;
|
||||
typedef struct _GdkMirGLContextClass GdkMirGLContextClass;
|
||||
|
||||
#define GDK_MIR_GL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_MIR_GL_CONTEXT, GdkMirGLContext))
|
||||
|
||||
|
||||
GdkDisplay *_gdk_mir_display_open (const gchar *display_name);
|
||||
|
||||
GdkScreen *_gdk_mir_screen_new (GdkDisplay *display);
|
||||
@@ -75,18 +51,12 @@ GdkDevice *_gdk_mir_pointer_new (GdkDeviceManager *device_manager, const gchar *
|
||||
|
||||
void _gdk_mir_pointer_set_location (GdkDevice *pointer, gdouble x, gdouble y, GdkWindow *window, GdkModifierType mask);
|
||||
|
||||
GdkCursor *_gdk_mir_cursor_new_for_type (GdkDisplay *display, GdkCursorType type);
|
||||
|
||||
GdkCursor *_gdk_mir_cursor_new_for_name (GdkDisplay *display, const gchar *name);
|
||||
|
||||
const gchar *_gdk_mir_cursor_get_name (GdkCursor *cursor);
|
||||
GdkCursor *_gdk_mir_cursor_new (GdkDisplay *display, GdkCursorType type);
|
||||
|
||||
GdkWindowImpl *_gdk_mir_window_impl_new (void);
|
||||
|
||||
void _gdk_mir_window_impl_set_surface_state (GdkMirWindowImpl *impl, MirSurfaceState state);
|
||||
|
||||
void _gdk_mir_window_impl_set_surface_type (GdkMirWindowImpl *impl, MirSurfaceType type);
|
||||
|
||||
void _gdk_mir_window_impl_set_cursor_state (GdkMirWindowImpl *impl, gdouble x, gdouble y, gboolean cursor_inside, MirMotionButton button_state);
|
||||
|
||||
void _gdk_mir_window_impl_get_cursor_state (GdkMirWindowImpl *impl, gdouble *x, gdouble *y, gboolean *cursor_inside, MirMotionButton *button_state);
|
||||
@@ -101,24 +71,6 @@ void _gdk_mir_window_reference_unref (GdkMirWindowReference *ref);
|
||||
|
||||
void _gdk_mir_event_source_queue (GdkMirWindowReference *window_ref, const MirEvent *event);
|
||||
|
||||
MirPixelFormat _gdk_mir_display_get_pixel_format (GdkDisplay *display, MirBufferUsage usage);
|
||||
|
||||
gboolean _gdk_mir_display_init_egl_display (GdkDisplay *display);
|
||||
|
||||
EGLDisplay _gdk_mir_display_get_egl_display (GdkDisplay *display);
|
||||
|
||||
gboolean _gdk_mir_display_have_egl_khr_create_context (GdkDisplay *display);
|
||||
|
||||
gboolean _gdk_mir_display_have_egl_buffer_age (GdkDisplay *display);
|
||||
|
||||
gboolean _gdk_mir_display_have_egl_swap_buffers_with_damage (GdkDisplay *display);
|
||||
|
||||
gboolean _gdk_mir_display_have_egl_surfaceless_context (GdkDisplay *display);
|
||||
|
||||
EGLSurface _gdk_mir_window_get_egl_surface (GdkWindow *window, EGLConfig config);
|
||||
|
||||
EGLSurface _gdk_mir_window_get_dummy_egl_surface (GdkWindow *window, EGLConfig config);
|
||||
|
||||
void _gdk_mir_print_modifiers (unsigned int modifiers);
|
||||
|
||||
void _gdk_mir_print_key_event (const MirKeyEvent *event);
|
||||
|
||||
+3
-12
@@ -24,25 +24,16 @@
|
||||
#define GDK_TYPE_MIR_DISPLAY (gdk_mir_display_get_type ())
|
||||
#define GDK_IS_MIR_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_DISPLAY))
|
||||
|
||||
#define GDK_TYPE_MIR_GL_CONTEXT (gdk_mir_gl_context_get_type ())
|
||||
#define GDK_MIR_IS_GL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_MIR_GL_CONTEXT))
|
||||
|
||||
#define GDK_TYPE_MIR_WINDOW (gdk_mir_window_get_type ())
|
||||
#define GDK_IS_MIR_WINDOW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_WINDOW))
|
||||
#define GDK_TYPE_MIR_WINDOW (gdk_mir_window_get_type ())
|
||||
#define GDK_IS_WINDOW_MIR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW_MIR))
|
||||
|
||||
GDK_AVAILABLE_IN_3_10
|
||||
GType gdk_mir_display_get_type (void);
|
||||
|
||||
GDK_AVAILABLE_IN_3_10
|
||||
MirConnection *gdk_mir_display_get_mir_connection (GdkDisplay *display);
|
||||
struct MirConnection *gdk_mir_display_get_mir_connection (GdkDisplay *display);
|
||||
|
||||
GDK_AVAILABLE_IN_3_10
|
||||
GType gdk_mir_window_get_type (void);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
MirSurface *gdk_mir_window_get_mir_surface (GdkWindow *window);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GType gdk_mir_gl_context_get_type (void) G_GNUC_CONST;
|
||||
|
||||
#endif /* __GDK_MIR_H__ */
|
||||
|
||||
+2
-106
@@ -35,8 +35,6 @@ typedef struct GdkMirCursorClass GdkMirCursorClass;
|
||||
struct GdkMirCursor
|
||||
{
|
||||
GdkCursor parent_instance;
|
||||
|
||||
gchar *name;
|
||||
};
|
||||
|
||||
struct GdkMirCursorClass
|
||||
@@ -46,100 +44,10 @@ struct GdkMirCursorClass
|
||||
|
||||
G_DEFINE_TYPE (GdkMirCursor, gdk_mir_cursor, GDK_TYPE_CURSOR)
|
||||
|
||||
static const gchar *
|
||||
get_cursor_name_for_cursor_type (GdkCursorType cursor_type)
|
||||
{
|
||||
switch (cursor_type)
|
||||
{
|
||||
case GDK_BLANK_CURSOR:
|
||||
return mir_disabled_cursor_name;
|
||||
case GDK_X_CURSOR:
|
||||
case GDK_ARROW:
|
||||
case GDK_CENTER_PTR:
|
||||
case GDK_DRAFT_LARGE:
|
||||
case GDK_DRAFT_SMALL:
|
||||
case GDK_LEFT_PTR:
|
||||
case GDK_RIGHT_PTR:
|
||||
case GDK_TOP_LEFT_ARROW:
|
||||
return mir_arrow_cursor_name;
|
||||
case GDK_CLOCK:
|
||||
case GDK_WATCH:
|
||||
return mir_busy_cursor_name;
|
||||
case GDK_XTERM:
|
||||
return mir_caret_cursor_name;
|
||||
case GDK_HAND1:
|
||||
case GDK_HAND2:
|
||||
return mir_pointing_hand_cursor_name;
|
||||
return mir_open_hand_cursor_name;
|
||||
case GDK_FLEUR:
|
||||
return mir_closed_hand_cursor_name;
|
||||
case GDK_LEFT_SIDE:
|
||||
case GDK_LEFT_TEE:
|
||||
case GDK_RIGHT_SIDE:
|
||||
case GDK_RIGHT_TEE:
|
||||
case GDK_SB_LEFT_ARROW:
|
||||
case GDK_SB_RIGHT_ARROW:
|
||||
return mir_horizontal_resize_cursor_name;
|
||||
case GDK_BASED_ARROW_DOWN:
|
||||
case GDK_BASED_ARROW_UP:
|
||||
case GDK_BOTTOM_SIDE:
|
||||
case GDK_BOTTOM_TEE:
|
||||
case GDK_DOUBLE_ARROW:
|
||||
case GDK_SB_DOWN_ARROW:
|
||||
case GDK_SB_UP_ARROW:
|
||||
case GDK_TOP_SIDE:
|
||||
case GDK_TOP_TEE:
|
||||
return mir_vertical_resize_cursor_name;
|
||||
case GDK_BOTTOM_LEFT_CORNER:
|
||||
case GDK_LL_ANGLE:
|
||||
case GDK_TOP_RIGHT_CORNER:
|
||||
case GDK_UR_ANGLE:
|
||||
return mir_diagonal_resize_bottom_to_top_cursor_name;
|
||||
case GDK_BOTTOM_RIGHT_CORNER:
|
||||
case GDK_LR_ANGLE:
|
||||
case GDK_SIZING:
|
||||
case GDK_TOP_LEFT_CORNER:
|
||||
case GDK_UL_ANGLE:
|
||||
return mir_diagonal_resize_top_to_bottom_cursor_name;
|
||||
return mir_omnidirectional_resize_cursor_name;
|
||||
case GDK_SB_V_DOUBLE_ARROW:
|
||||
return mir_vsplit_resize_cursor_name;
|
||||
case GDK_SB_H_DOUBLE_ARROW:
|
||||
return mir_hsplit_resize_cursor_name;
|
||||
default:
|
||||
return mir_default_cursor_name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GdkCursor *
|
||||
_gdk_mir_cursor_new_for_name (GdkDisplay *display, const gchar *name)
|
||||
_gdk_mir_cursor_new (GdkDisplay *display, GdkCursorType type)
|
||||
{
|
||||
GdkMirCursor *cursor;
|
||||
|
||||
cursor = g_object_new (GDK_TYPE_MIR_CURSOR, "display", display, "cursor-type", GDK_CURSOR_IS_PIXMAP, NULL);
|
||||
cursor->name = g_strdup (name);
|
||||
|
||||
return GDK_CURSOR (cursor);
|
||||
}
|
||||
|
||||
GdkCursor *
|
||||
_gdk_mir_cursor_new_for_type (GdkDisplay *display, GdkCursorType type)
|
||||
{
|
||||
GdkMirCursor *cursor;
|
||||
|
||||
cursor = g_object_new (GDK_TYPE_MIR_CURSOR, "display", display, "cursor-type", type, NULL);
|
||||
cursor->name = g_strdup (get_cursor_name_for_cursor_type (type));
|
||||
|
||||
return GDK_CURSOR (cursor);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
_gdk_mir_cursor_get_name (GdkCursor *cursor)
|
||||
{
|
||||
GdkMirCursor *mir_cursor = GDK_MIR_CURSOR (cursor);
|
||||
|
||||
return mir_cursor->name;
|
||||
return g_object_new (GDK_TYPE_MIR_CURSOR, "display", display, "cursor-type", type, NULL);
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
@@ -156,22 +64,10 @@ gdk_mir_cursor_init (GdkMirCursor *cursor)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_mir_cursor_finalize (GObject *object)
|
||||
{
|
||||
GdkMirCursor *mir_cursor = GDK_MIR_CURSOR (object);
|
||||
|
||||
g_free (mir_cursor->name);
|
||||
|
||||
G_OBJECT_CLASS (gdk_mir_cursor_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_mir_cursor_class_init (GdkMirCursorClass *klass)
|
||||
{
|
||||
GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
cursor_class->get_surface = gdk_mir_cursor_get_surface;
|
||||
object_class->finalize = gdk_mir_cursor_finalize;
|
||||
}
|
||||
|
||||
+26
-189
@@ -45,16 +45,9 @@ typedef struct GdkMirDisplay
|
||||
/* Screen information */
|
||||
GdkScreen *screen;
|
||||
|
||||
GdkCursor *cursor;
|
||||
|
||||
GdkKeymap *keymap;
|
||||
|
||||
MirPixelFormat sw_pixel_format;
|
||||
MirPixelFormat hw_pixel_format;
|
||||
|
||||
EGLDisplay egl_display;
|
||||
guint have_egl_khr_create_context : 1;
|
||||
guint have_egl_buffer_age : 1;
|
||||
guint have_egl_swap_buffers_with_damage : 1;
|
||||
guint have_egl_surfaceless_context : 1;
|
||||
} GdkMirDisplay;
|
||||
|
||||
typedef struct GdkMirDisplayClass
|
||||
@@ -62,8 +55,6 @@ typedef struct GdkMirDisplayClass
|
||||
GdkDisplayClass parent_class;
|
||||
} GdkMirDisplayClass;
|
||||
|
||||
static void initialize_pixel_formats (GdkMirDisplay *display);
|
||||
|
||||
/**
|
||||
* SECTION:mir_interaction
|
||||
* @Short_description: Mir backend-specific functions
|
||||
@@ -123,7 +114,6 @@ _gdk_mir_display_open (const gchar *display_name)
|
||||
display->connection = connection;
|
||||
GDK_DISPLAY (display)->device_manager = _gdk_mir_device_manager_new (GDK_DISPLAY (display));
|
||||
display->screen = _gdk_mir_screen_new (GDK_DISPLAY (display));
|
||||
initialize_pixel_formats (display);
|
||||
|
||||
g_signal_emit_by_name (display, "opened");
|
||||
|
||||
@@ -327,14 +317,18 @@ static GdkCursor *
|
||||
gdk_mir_display_get_cursor_for_type (GdkDisplay *display,
|
||||
GdkCursorType cursor_type)
|
||||
{
|
||||
return _gdk_mir_cursor_new_for_type (display, cursor_type);
|
||||
//g_printerr ("gdk_mir_display_get_cursor_for_type (%u)\n", cursor_type);
|
||||
/* We don't support configurable cursors */
|
||||
return g_object_ref (GDK_MIR_DISPLAY (display)->cursor);
|
||||
}
|
||||
|
||||
static GdkCursor *
|
||||
gdk_mir_display_get_cursor_for_name (GdkDisplay *display,
|
||||
const gchar *name)
|
||||
{
|
||||
return _gdk_mir_cursor_new_for_name (display, name);
|
||||
g_printerr ("gdk_mir_display_get_cursor_for_name (\"%s\")\n", name);
|
||||
/* We don't support configurable cursors */
|
||||
return g_object_ref (GDK_MIR_DISPLAY (display)->cursor);
|
||||
}
|
||||
|
||||
static GdkCursor *
|
||||
@@ -388,6 +382,21 @@ gdk_mir_display_notify_startup_complete (GdkDisplay *display,
|
||||
//g_printerr ("gdk_mir_display_notify_startup_complete\n");
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_mir_display_event_data_copy (GdkDisplay *display,
|
||||
const GdkEvent *src,
|
||||
GdkEvent *dst)
|
||||
{
|
||||
//g_printerr ("gdk_mir_display_event_data_copy\n");
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_mir_display_event_data_free (GdkDisplay *display,
|
||||
GdkEvent *event)
|
||||
{
|
||||
//g_printerr ("gdk_mir_display_event_data_free\n");
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_mir_display_create_window_impl (GdkDisplay *display,
|
||||
GdkWindow *window,
|
||||
@@ -499,184 +508,11 @@ gdk_mir_display_utf8_to_string_target (GdkDisplay *display,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
initialize_pixel_formats (GdkMirDisplay *display)
|
||||
{
|
||||
MirPixelFormat formats[mir_pixel_formats];
|
||||
unsigned int n_formats, i;
|
||||
|
||||
mir_connection_get_available_surface_formats (display->connection, formats,
|
||||
mir_pixel_formats, &n_formats);
|
||||
|
||||
display->sw_pixel_format = mir_pixel_format_invalid;
|
||||
display->hw_pixel_format = mir_pixel_format_invalid;
|
||||
|
||||
for (i = 0; i < n_formats; i++)
|
||||
{
|
||||
switch (formats[i])
|
||||
{
|
||||
case mir_pixel_format_abgr_8888:
|
||||
case mir_pixel_format_xbgr_8888:
|
||||
case mir_pixel_format_argb_8888:
|
||||
case mir_pixel_format_xrgb_8888:
|
||||
display->hw_pixel_format = formats[i];
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
if (display->hw_pixel_format != mir_pixel_format_invalid)
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < n_formats; i++)
|
||||
{
|
||||
if (formats[i] == mir_pixel_format_argb_8888)
|
||||
{
|
||||
display->sw_pixel_format = formats[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MirPixelFormat
|
||||
_gdk_mir_display_get_pixel_format (GdkDisplay *display,
|
||||
MirBufferUsage usage)
|
||||
{
|
||||
GdkMirDisplay *mir_dpy = GDK_MIR_DISPLAY (display);
|
||||
|
||||
if (usage == mir_buffer_usage_hardware)
|
||||
return mir_dpy->hw_pixel_format;
|
||||
|
||||
return mir_dpy->sw_pixel_format;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gdk_mir_display_init_egl_display (GdkDisplay *display)
|
||||
{
|
||||
GdkMirDisplay *mir_dpy = GDK_MIR_DISPLAY (display);
|
||||
EGLint major_version, minor_version;
|
||||
EGLDisplay *dpy;
|
||||
|
||||
if (mir_dpy->egl_display)
|
||||
return TRUE;
|
||||
|
||||
dpy = eglGetDisplay (mir_connection_get_egl_native_display (mir_dpy->connection));
|
||||
if (dpy == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!eglInitialize (dpy, &major_version, &minor_version))
|
||||
return FALSE;
|
||||
|
||||
if (!eglBindAPI (EGL_OPENGL_API))
|
||||
return FALSE;
|
||||
|
||||
mir_dpy->egl_display = dpy;
|
||||
|
||||
mir_dpy->have_egl_khr_create_context =
|
||||
epoxy_has_egl_extension (dpy, "EGL_KHR_create_context");
|
||||
|
||||
mir_dpy->have_egl_buffer_age =
|
||||
epoxy_has_egl_extension (dpy, "EGL_EXT_buffer_age");
|
||||
|
||||
mir_dpy->have_egl_swap_buffers_with_damage =
|
||||
epoxy_has_egl_extension (dpy, "EGL_EXT_swap_buffers_with_damage");
|
||||
|
||||
mir_dpy->have_egl_surfaceless_context =
|
||||
epoxy_has_egl_extension (dpy, "EGL_KHR_surfaceless_context");
|
||||
|
||||
GDK_NOTE (OPENGL,
|
||||
g_print ("EGL API version %d.%d found\n"
|
||||
" - Vendor: %s\n"
|
||||
" - Version: %s\n"
|
||||
" - Client APIs: %s\n"
|
||||
" - Extensions:\n"
|
||||
"\t%s\n",
|
||||
major_version,
|
||||
minor_version,
|
||||
eglQueryString (dpy, EGL_VENDOR),
|
||||
eglQueryString (dpy, EGL_VERSION),
|
||||
eglQueryString (dpy, EGL_CLIENT_APIS),
|
||||
eglQueryString (dpy, EGL_EXTENSIONS)));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_mir_display_make_gl_context_current (GdkDisplay *display,
|
||||
GdkGLContext *context)
|
||||
{
|
||||
EGLDisplay egl_display = _gdk_mir_display_get_egl_display (display);
|
||||
GdkMirGLContext *mir_context;
|
||||
GdkWindow *window;
|
||||
EGLSurface egl_surface;
|
||||
|
||||
if (context == NULL)
|
||||
{
|
||||
eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
mir_context = GDK_MIR_GL_CONTEXT (context);
|
||||
window = gdk_gl_context_get_window (context);
|
||||
|
||||
if (mir_context->is_attached)
|
||||
{
|
||||
egl_surface = _gdk_mir_window_get_egl_surface (window,
|
||||
mir_context->egl_config);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_gdk_mir_display_have_egl_surfaceless_context (display))
|
||||
egl_surface = EGL_NO_SURFACE;
|
||||
else
|
||||
egl_surface = _gdk_mir_window_get_dummy_egl_surface (window,
|
||||
mir_context->egl_config);
|
||||
}
|
||||
|
||||
if (!eglMakeCurrent (egl_display, egl_surface, egl_surface, mir_context->egl_context))
|
||||
{
|
||||
g_warning ("eglMakeCurrent failed");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
EGLDisplay _gdk_mir_display_get_egl_display (GdkDisplay *display)
|
||||
{
|
||||
return GDK_MIR_DISPLAY (display)->egl_display;
|
||||
}
|
||||
|
||||
gboolean _gdk_mir_display_have_egl_khr_create_context (GdkDisplay *display)
|
||||
{
|
||||
return GDK_MIR_DISPLAY (display)->have_egl_khr_create_context;
|
||||
}
|
||||
|
||||
gboolean _gdk_mir_display_have_egl_buffer_age (GdkDisplay *display)
|
||||
{
|
||||
/* FIXME: this is not really supported by mir yet (despite is advertised) */
|
||||
// return GDK_MIR_DISPLAY (display)->have_egl_buffer_age;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean _gdk_mir_display_have_egl_swap_buffers_with_damage (GdkDisplay *display)
|
||||
{
|
||||
/* FIXME: this is not really supported by mir yet (despite is advertised) */
|
||||
// return GDK_MIR_DISPLAY (display)->have_egl_swap_buffers_with_damage;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean _gdk_mir_display_have_egl_surfaceless_context (GdkDisplay *display)
|
||||
{
|
||||
return GDK_MIR_DISPLAY (display)->have_egl_surfaceless_context;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gdk_mir_display_init (GdkMirDisplay *display)
|
||||
{
|
||||
display->event_source = _gdk_mir_event_source_new (GDK_DISPLAY (display));
|
||||
display->cursor = _gdk_mir_cursor_new (GDK_DISPLAY (display), GDK_ARROW);
|
||||
display->keymap = _gdk_mir_keymap_new ();
|
||||
}
|
||||
|
||||
@@ -720,6 +556,8 @@ gdk_mir_display_class_init (GdkMirDisplayClass *klass)
|
||||
display_class->after_process_all_updates = gdk_mir_display_after_process_all_updates;
|
||||
display_class->get_next_serial = gdk_mir_display_get_next_serial;
|
||||
display_class->notify_startup_complete = gdk_mir_display_notify_startup_complete;
|
||||
display_class->event_data_copy = gdk_mir_display_event_data_copy;
|
||||
display_class->event_data_free = gdk_mir_display_event_data_free;
|
||||
display_class->create_window_impl = gdk_mir_display_create_window_impl;
|
||||
display_class->get_keymap = gdk_mir_display_get_keymap;
|
||||
display_class->push_error_trap = gdk_mir_display_push_error_trap;
|
||||
@@ -731,5 +569,4 @@ gdk_mir_display_class_init (GdkMirDisplayClass *klass)
|
||||
display_class->convert_selection = gdk_mir_display_convert_selection;
|
||||
display_class->text_property_to_utf8_list = gdk_mir_display_text_property_to_utf8_list;
|
||||
display_class->utf8_to_string_target = gdk_mir_display_utf8_to_string_target;
|
||||
display_class->make_gl_context_current = gdk_mir_display_make_gl_context_current;
|
||||
}
|
||||
|
||||
@@ -162,8 +162,8 @@ generate_scroll_event (GdkWindow *window, gdouble x, gdouble y, gdouble delta_x,
|
||||
event->scroll.y = y;
|
||||
event->scroll.state = state;
|
||||
event->scroll.direction = GDK_SCROLL_SMOOTH;
|
||||
event->scroll.delta_x = -delta_x;
|
||||
event->scroll.delta_y = -delta_y;
|
||||
event->scroll.delta_x = delta_x;
|
||||
event->scroll.delta_y = delta_y;
|
||||
|
||||
send_event (window, get_pointer (window), event);
|
||||
}
|
||||
@@ -311,7 +311,7 @@ handle_motion_event (GdkWindow *window, const MirMotionEvent *event)
|
||||
case mir_motion_action_up:
|
||||
event_type = event->action == mir_motion_action_down ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE;
|
||||
changed_button_state = button_state ^ event->button_state;
|
||||
if (changed_button_state == 0 || (changed_button_state & mir_motion_button_primary) != 0)
|
||||
if ((changed_button_state & mir_motion_button_primary) != 0)
|
||||
generate_button_event (window, event_type, x, y, GDK_BUTTON_PRIMARY, modifier_state);
|
||||
if ((changed_button_state & mir_motion_button_secondary) != 0)
|
||||
generate_button_event (window, event_type, x, y, GDK_BUTTON_SECONDARY, modifier_state);
|
||||
@@ -343,7 +343,6 @@ handle_surface_event (GdkWindow *window, const MirSurfaceEvent *event)
|
||||
switch (event->attrib)
|
||||
{
|
||||
case mir_surface_attrib_type:
|
||||
_gdk_mir_window_impl_set_surface_type (impl, event->value);
|
||||
break;
|
||||
case mir_surface_attrib_state:
|
||||
_gdk_mir_window_impl_set_surface_state (impl, event->value);
|
||||
@@ -414,14 +413,8 @@ gdk_mir_event_source_queue_event (GdkDisplay *display,
|
||||
case mir_event_type_resize:
|
||||
handle_resize_event (window, &event->resize);
|
||||
break;
|
||||
case mir_event_type_prompt_session_state_change:
|
||||
// FIXME?
|
||||
break;
|
||||
case mir_event_type_orientation:
|
||||
// FIXME?
|
||||
break;
|
||||
default:
|
||||
g_warning ("Ignoring unknown Mir event %d", event->type);
|
||||
g_assert_not_reached ();
|
||||
// FIXME?
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
*
|
||||
* gdkmirglcontext.c: Mir specific OpenGL wrappers
|
||||
*
|
||||
* Copyright © 2014 Canonical Ltd
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkmir-private.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkintl.h"
|
||||
|
||||
G_DEFINE_TYPE (GdkMirGLContext, gdk_mir_gl_context, GDK_TYPE_GL_CONTEXT)
|
||||
|
||||
static void
|
||||
gdk_mir_gl_context_end_frame (GdkGLContext *context,
|
||||
cairo_region_t *painted,
|
||||
cairo_region_t *damage)
|
||||
{
|
||||
GdkWindow *window = gdk_gl_context_get_window (context);
|
||||
GdkDisplay *display = gdk_window_get_display (window);
|
||||
GdkMirGLContext *context_mir = GDK_MIR_GL_CONTEXT (context);
|
||||
EGLDisplay egl_display = _gdk_mir_display_get_egl_display (display);
|
||||
EGLSurface egl_surface;
|
||||
|
||||
gdk_gl_context_make_current (context);
|
||||
|
||||
egl_surface = _gdk_mir_window_get_egl_surface (window,
|
||||
context_mir->egl_config);
|
||||
|
||||
if (_gdk_mir_display_have_egl_swap_buffers_with_damage (display))
|
||||
{
|
||||
int i, j, n_rects = cairo_region_num_rectangles (damage);
|
||||
EGLint *rects = g_new (EGLint, n_rects * 4);
|
||||
cairo_rectangle_int_t rect;
|
||||
int window_height = gdk_window_get_height (window);
|
||||
|
||||
for (i = 0, j = 0; i < n_rects; i++)
|
||||
{
|
||||
cairo_region_get_rectangle (damage, i, &rect);
|
||||
rects[j++] = rect.x;
|
||||
rects[j++] = window_height - rect.height - rect.y;
|
||||
rects[j++] = rect.width;
|
||||
rects[j++] = rect.height;
|
||||
}
|
||||
eglSwapBuffersWithDamageEXT (egl_display, egl_surface, rects, n_rects);
|
||||
g_free (rects);
|
||||
}
|
||||
else
|
||||
{
|
||||
eglSwapBuffers (egl_display, egl_surface);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_mir_gl_context_dispose (GObject *gobject)
|
||||
{
|
||||
GdkMirGLContext *context_mir = GDK_MIR_GL_CONTEXT (gobject);
|
||||
|
||||
if (context_mir->egl_context != NULL)
|
||||
{
|
||||
GdkGLContext *context = GDK_GL_CONTEXT (gobject);
|
||||
GdkWindow *window = gdk_gl_context_get_window (context);
|
||||
GdkDisplay *display = gdk_window_get_display (window);
|
||||
EGLDisplay egl_display = _gdk_mir_display_get_egl_display (display);
|
||||
|
||||
if (eglGetCurrentContext () == context_mir->egl_context)
|
||||
eglMakeCurrent (egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
|
||||
GDK_NOTE (OPENGL, g_print ("Destroying EGL context\n"));
|
||||
|
||||
eglDestroyContext (egl_display, context_mir->egl_context);
|
||||
context_mir->egl_context = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gdk_mir_gl_context_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_mir_gl_context_class_init (GdkMirGLContextClass *klass)
|
||||
{
|
||||
GdkGLContextClass *context_class = GDK_GL_CONTEXT_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
context_class->end_frame = gdk_mir_gl_context_end_frame;
|
||||
gobject_class->dispose = gdk_mir_gl_context_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_mir_gl_context_init (GdkMirGLContext *self)
|
||||
{
|
||||
}
|
||||
+14
-98
@@ -94,29 +94,6 @@ get_screen_size (MirDisplayConfiguration *config, gint *width, gint *height)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_screen_size_mm (MirDisplayConfiguration *config, gint *width, gint *height)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
|
||||
if (!config)
|
||||
return;
|
||||
|
||||
for (i = 0; i < config->num_outputs; i++)
|
||||
{
|
||||
MirDisplayOutput *o = &config->outputs[i];
|
||||
|
||||
if (!o->used)
|
||||
continue;
|
||||
|
||||
*width += o->physical_width_mm;
|
||||
*height += o->physical_height_mm;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_display_config (GdkMirScreen *screen)
|
||||
{
|
||||
@@ -147,7 +124,7 @@ _gdk_mir_screen_new (GdkDisplay *display)
|
||||
|
||||
screen = g_object_new (GDK_TYPE_MIR_SCREEN, NULL);
|
||||
screen->display = display;
|
||||
mir_connection_set_display_config_change_callback (get_connection (screen), config_changed_cb, screen);
|
||||
mir_connection_set_display_config_change_callback (get_connection (screen), config_changed_cb, display);
|
||||
update_display_config (screen);
|
||||
|
||||
return GDK_SCREEN (screen);
|
||||
@@ -162,13 +139,6 @@ gdk_mir_screen_dispose (GObject *object)
|
||||
static void
|
||||
gdk_mir_screen_finalize (GObject *object)
|
||||
{
|
||||
GdkMirScreen *screen = GDK_MIR_SCREEN (object);
|
||||
|
||||
mir_connection_set_display_config_change_callback (get_connection (screen), NULL, NULL);
|
||||
mir_display_config_destroy (screen->display_config);
|
||||
g_clear_object (&screen->visual);
|
||||
g_clear_object (&screen->root_window);
|
||||
|
||||
G_OBJECT_CLASS (gdk_mir_screen_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
@@ -222,18 +192,16 @@ static gint
|
||||
gdk_mir_screen_get_width_mm (GdkScreen *screen)
|
||||
{
|
||||
g_printerr ("gdk_mir_screen_get_width_mm\n");
|
||||
gint width, height;
|
||||
get_screen_size_mm (GDK_MIR_SCREEN (screen)->display_config, &width, &height);
|
||||
return width;
|
||||
// FIXME: A combination of all screens?
|
||||
return get_output (screen, 0)->physical_width_mm;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_mir_screen_get_height_mm (GdkScreen *screen)
|
||||
{
|
||||
g_printerr ("gdk_mir_screen_get_height_mm\n");
|
||||
gint width, height;
|
||||
get_screen_size_mm (GDK_MIR_SCREEN (screen)->display_config, &width, &height);
|
||||
return height;
|
||||
// FIXME: A combination of all screens?
|
||||
return get_output (screen, 0)->physical_height_mm;
|
||||
}
|
||||
|
||||
static gint
|
||||
@@ -285,7 +253,7 @@ gdk_mir_screen_get_n_monitors (GdkScreen *screen)
|
||||
|
||||
for (i = 0; i < config->num_outputs; i++)
|
||||
if (config->outputs[i].used)
|
||||
++count;
|
||||
count++;
|
||||
|
||||
return count;
|
||||
}
|
||||
@@ -302,8 +270,7 @@ gdk_mir_screen_get_monitor_width_mm (GdkScreen *screen,
|
||||
gint monitor_num)
|
||||
{
|
||||
g_printerr ("gdk_mir_screen_get_monitor_width_mm (%d)\n", monitor_num);
|
||||
MirDisplayOutput *output = get_output (screen, monitor_num);
|
||||
return output ? output->physical_width_mm : 0;
|
||||
return get_output (screen, monitor_num)->physical_width_mm;
|
||||
}
|
||||
|
||||
static gint
|
||||
@@ -311,8 +278,7 @@ gdk_mir_screen_get_monitor_height_mm (GdkScreen *screen,
|
||||
gint monitor_num)
|
||||
{
|
||||
g_printerr ("gdk_mir_screen_get_monitor_height_mm (%d)\n", monitor_num);
|
||||
MirDisplayOutput *output = get_output (screen, monitor_num);
|
||||
return output ? output->physical_height_mm : 0;
|
||||
return get_output (screen, monitor_num)->physical_height_mm;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
@@ -320,46 +286,7 @@ gdk_mir_screen_get_monitor_plug_name (GdkScreen *screen,
|
||||
gint monitor_num)
|
||||
{
|
||||
g_printerr ("gdk_mir_screen_get_monitor_plug_name (%d)\n", monitor_num);
|
||||
MirDisplayOutput *output = get_output (screen, monitor_num);
|
||||
|
||||
if (output)
|
||||
{
|
||||
switch (output->type)
|
||||
{
|
||||
case mir_display_output_type_unknown:
|
||||
return g_strdup_printf ("UNKNOWN-%u", output->output_id);
|
||||
case mir_display_output_type_vga:
|
||||
return g_strdup_printf ("VGA-%u", output->output_id);
|
||||
case mir_display_output_type_dvii:
|
||||
return g_strdup_printf ("DVII-%u", output->output_id);
|
||||
case mir_display_output_type_dvid:
|
||||
return g_strdup_printf ("DVID-%u", output->output_id);
|
||||
case mir_display_output_type_dvia:
|
||||
return g_strdup_printf ("DVIA-%u", output->output_id);
|
||||
case mir_display_output_type_composite:
|
||||
return g_strdup_printf ("COMPOSITE-%u", output->output_id);
|
||||
case mir_display_output_type_svideo:
|
||||
return g_strdup_printf ("SVIDEO-%u", output->output_id);
|
||||
case mir_display_output_type_lvds:
|
||||
return g_strdup_printf ("LVDS-%u", output->output_id);
|
||||
case mir_display_output_type_component:
|
||||
return g_strdup_printf ("COMPONENT-%u", output->output_id);
|
||||
case mir_display_output_type_ninepindin:
|
||||
return g_strdup_printf ("NINEPINDIN-%u", output->output_id);
|
||||
case mir_display_output_type_displayport:
|
||||
return g_strdup_printf ("DISPLAYPORT-%u", output->output_id);
|
||||
case mir_display_output_type_hdmia:
|
||||
return g_strdup_printf ("HDMIA-%u", output->output_id);
|
||||
case mir_display_output_type_hdmib:
|
||||
return g_strdup_printf ("HDMIB-%u", output->output_id);
|
||||
case mir_display_output_type_tv:
|
||||
return g_strdup_printf ("TV-%u", output->output_id);
|
||||
case mir_display_output_type_edp:
|
||||
return g_strdup_printf ("EDP-%u", output->output_id);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL; //?
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -372,22 +299,11 @@ gdk_mir_screen_get_monitor_geometry (GdkScreen *screen,
|
||||
MirDisplayMode *mode;
|
||||
|
||||
output = get_output (screen, monitor_num);
|
||||
|
||||
if (output)
|
||||
{
|
||||
mode = &output->modes[output->current_mode];
|
||||
dest->x = output->position_x;
|
||||
dest->y = output->position_y;
|
||||
dest->width = mode->horizontal_resolution;
|
||||
dest->height = mode->vertical_resolution;
|
||||
}
|
||||
else
|
||||
{
|
||||
dest->x = 0;
|
||||
dest->y = 0;
|
||||
dest->width = 0;
|
||||
dest->height = 0;
|
||||
}
|
||||
mode = &output->modes[output->current_mode];
|
||||
dest->x = output->position_x;
|
||||
dest->y = output->position_y;
|
||||
dest->width = mode->horizontal_resolution;
|
||||
dest->height = mode->vertical_resolution;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+72
-457
@@ -25,7 +25,6 @@
|
||||
|
||||
#include "gdkwindowimpl.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkintl.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkdeviceprivate.h"
|
||||
|
||||
@@ -33,8 +32,6 @@
|
||||
#define GDK_IS_WINDOW_IMPL_MIR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WINDOW_IMPL_MIR))
|
||||
#define GDK_MIR_WINDOW_IMPL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW_IMPL_MIR, GdkMirWindowImplClass))
|
||||
|
||||
#define MAX_EGL_ATTRS 30
|
||||
|
||||
typedef struct _GdkMirWindowImplClass GdkMirWindowImplClass;
|
||||
|
||||
struct _GdkMirWindowImpl
|
||||
@@ -50,7 +47,7 @@ struct _GdkMirWindowImpl
|
||||
GList *transient_children;
|
||||
|
||||
/* Desired surface attributes */
|
||||
MirSurfaceType surface_type;
|
||||
MirSurfaceType surface_type; // FIXME
|
||||
MirSurfaceState surface_state;
|
||||
|
||||
/* Pattern for background */
|
||||
@@ -67,13 +64,6 @@ struct _GdkMirWindowImpl
|
||||
/* Cairo context for current frame */
|
||||
cairo_surface_t *cairo_surface;
|
||||
|
||||
/* Egl surface for the current mir surface */
|
||||
EGLSurface egl_surface;
|
||||
|
||||
/* Dummy MIR and EGL surfaces */
|
||||
MirSurface *dummy_surface;
|
||||
EGLSurface dummy_egl_surface;
|
||||
|
||||
/* TRUE if the window can be seen */
|
||||
gboolean visible;
|
||||
|
||||
@@ -102,12 +92,6 @@ _gdk_mir_window_impl_set_surface_state (GdkMirWindowImpl *impl, MirSurfaceState
|
||||
impl->surface_state = state;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_mir_window_impl_set_surface_type (GdkMirWindowImpl *impl, MirSurfaceType type)
|
||||
{
|
||||
impl->surface_type = type;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_mir_window_impl_set_cursor_state (GdkMirWindowImpl *impl,
|
||||
gdouble x,
|
||||
@@ -141,34 +125,23 @@ _gdk_mir_window_impl_get_cursor_state (GdkMirWindowImpl *impl,
|
||||
static void
|
||||
gdk_mir_window_impl_init (GdkMirWindowImpl *impl)
|
||||
{
|
||||
impl->surface_type = mir_surface_type_normal;
|
||||
impl->surface_state = mir_surface_state_unknown;
|
||||
}
|
||||
|
||||
static MirConnection *
|
||||
get_connection (GdkWindow *window)
|
||||
{
|
||||
return gdk_mir_display_get_mir_connection (gdk_window_get_display (window));
|
||||
}
|
||||
|
||||
static void
|
||||
set_surface_state (GdkMirWindowImpl *impl,
|
||||
MirSurfaceState state)
|
||||
{
|
||||
if (impl->surface_state == state)
|
||||
return;
|
||||
|
||||
impl->surface_state = state;
|
||||
if (impl->surface)
|
||||
mir_surface_set_state (impl->surface, state);
|
||||
}
|
||||
|
||||
static void
|
||||
set_surface_type (GdkMirWindowImpl *impl,
|
||||
MirSurfaceType type)
|
||||
{
|
||||
if (impl->surface_type == type)
|
||||
return;
|
||||
|
||||
impl->surface_type = type;
|
||||
if (impl->surface)
|
||||
mir_surface_set_type (impl->surface, type);
|
||||
}
|
||||
|
||||
static void
|
||||
event_cb (MirSurface *surface,
|
||||
const MirEvent *event,
|
||||
@@ -177,32 +150,13 @@ event_cb (MirSurface *surface,
|
||||
_gdk_mir_event_source_queue (context, event);
|
||||
}
|
||||
|
||||
static MirSurface *
|
||||
create_mir_surface (GdkDisplay *display,
|
||||
gint width,
|
||||
gint height,
|
||||
MirBufferUsage buffer_usage)
|
||||
{
|
||||
MirSurfaceParameters parameters;
|
||||
MirConnection *connection;
|
||||
|
||||
parameters.name = "GTK+ Mir";
|
||||
parameters.width = width;
|
||||
parameters.height = height;
|
||||
parameters.pixel_format = _gdk_mir_display_get_pixel_format (display, buffer_usage);
|
||||
parameters.buffer_usage = buffer_usage;
|
||||
parameters.output_id = mir_display_output_id_invalid;
|
||||
|
||||
connection = gdk_mir_display_get_mir_connection (display);
|
||||
|
||||
return mir_connection_create_surface_sync (connection, ¶meters);
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_surface_full (GdkWindow *window,
|
||||
MirBufferUsage buffer_usage)
|
||||
ensure_surface (GdkWindow *window)
|
||||
{
|
||||
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
||||
MirPixelFormat formats[100], pixel_format = mir_pixel_format_invalid;
|
||||
unsigned int n_formats, i;
|
||||
MirSurfaceParameters parameters;
|
||||
MirEventDelegate event_delegate = { event_cb, NULL };
|
||||
GdkMirWindowReference *window_ref;
|
||||
|
||||
@@ -216,33 +170,41 @@ ensure_surface_full (GdkWindow *window,
|
||||
|
||||
event_delegate.context = window_ref;
|
||||
|
||||
impl->surface = create_mir_surface (gdk_window_get_display (window),
|
||||
window->width, window->height,
|
||||
buffer_usage);
|
||||
// Should probably calculate this once?
|
||||
// Should prefer certain formats over others
|
||||
mir_connection_get_available_surface_formats (get_connection (window), formats, 100, &n_formats);
|
||||
for (i = 0; i < n_formats; i++)
|
||||
if (formats[i] == mir_pixel_format_argb_8888)
|
||||
{
|
||||
pixel_format = formats[i];
|
||||
break;
|
||||
}
|
||||
|
||||
parameters.name = "GTK+ Mir";
|
||||
parameters.width = window->width;
|
||||
parameters.height = window->height;
|
||||
parameters.pixel_format = pixel_format;
|
||||
parameters.buffer_usage = mir_buffer_usage_software;
|
||||
parameters.output_id = mir_display_output_id_invalid;
|
||||
impl->surface = mir_connection_create_surface_sync (get_connection (window), ¶meters);
|
||||
|
||||
MirGraphicsRegion region;
|
||||
MirEvent resize_event;
|
||||
|
||||
mir_surface_get_graphics_region (impl->surface, ®ion);
|
||||
|
||||
/* Send the initial configure with the size the server gave... */
|
||||
resize_event.resize.type = mir_event_type_resize;
|
||||
resize_event.resize.surface_id = 0;
|
||||
resize_event.resize.width = window->width;
|
||||
resize_event.resize.height = window->height;
|
||||
resize_event.resize.width = region.width;
|
||||
resize_event.resize.height = region.height;
|
||||
|
||||
_gdk_mir_event_source_queue (window_ref, &resize_event);
|
||||
|
||||
mir_surface_set_event_handler (impl->surface, &event_delegate); // FIXME: Ignore some events until shown
|
||||
set_surface_type (impl, impl->surface_type);
|
||||
set_surface_state (impl, impl->surface_state);
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_surface (GdkWindow *window)
|
||||
{
|
||||
ensure_surface_full (window, window->gl_paint_context ?
|
||||
mir_buffer_usage_hardware :
|
||||
mir_buffer_usage_software);
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_no_surface (GdkWindow *window)
|
||||
{
|
||||
@@ -251,30 +213,15 @@ ensure_no_surface (GdkWindow *window)
|
||||
if (impl->cairo_surface)
|
||||
{
|
||||
cairo_surface_finish (impl->cairo_surface);
|
||||
g_clear_pointer (&impl->cairo_surface, cairo_surface_destroy);
|
||||
cairo_surface_destroy (impl->cairo_surface);
|
||||
impl->cairo_surface = NULL;
|
||||
}
|
||||
|
||||
if (window->gl_paint_context)
|
||||
if (impl->surface)
|
||||
{
|
||||
GdkDisplay *display = gdk_window_get_display (window);
|
||||
EGLDisplay egl_display = _gdk_mir_display_get_egl_display (display);
|
||||
|
||||
if (impl->egl_surface)
|
||||
{
|
||||
eglDestroySurface (egl_display, impl->egl_surface);
|
||||
impl->egl_surface = NULL;
|
||||
}
|
||||
|
||||
if (impl->dummy_egl_surface)
|
||||
{
|
||||
eglDestroySurface (egl_display, impl->dummy_egl_surface);
|
||||
impl->dummy_egl_surface = NULL;
|
||||
}
|
||||
|
||||
g_clear_pointer (&impl->dummy_surface, mir_surface_release_sync);
|
||||
mir_surface_release_sync (impl->surface);
|
||||
impl->surface = NULL;
|
||||
}
|
||||
|
||||
g_clear_pointer(&impl->surface, mir_surface_release_sync);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -332,7 +279,11 @@ send_buffer (GdkWindow *window)
|
||||
mir_surface_swap_buffers_sync (impl->surface);
|
||||
|
||||
/* The Cairo context is no longer valid */
|
||||
g_clear_pointer (&impl->cairo_surface, cairo_surface_destroy);
|
||||
if (impl->cairo_surface)
|
||||
{
|
||||
cairo_surface_destroy (impl->cairo_surface);
|
||||
impl->cairo_surface = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
@@ -341,7 +292,7 @@ gdk_mir_window_impl_ref_cairo_surface (GdkWindow *window)
|
||||
//g_printerr ("gdk_mir_window_impl_ref_cairo_surface window=%p\n", window);
|
||||
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
||||
MirGraphicsRegion region;
|
||||
cairo_format_t pixel_format = CAIRO_FORMAT_ARGB32;
|
||||
cairo_format_t pixel_format = CAIRO_FORMAT_INVALID;
|
||||
cairo_surface_t *cairo_surface;
|
||||
cairo_t *c;
|
||||
|
||||
@@ -352,16 +303,31 @@ gdk_mir_window_impl_ref_cairo_surface (GdkWindow *window)
|
||||
}
|
||||
|
||||
/* Transient windows get rendered into a buffer and copied onto their parent */
|
||||
if (impl->transient_for || window->gl_paint_context)
|
||||
if (impl->transient_for)
|
||||
{
|
||||
cairo_surface = cairo_image_surface_create (pixel_format, window->width, window->height);
|
||||
cairo_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, window->width, window->height);
|
||||
}
|
||||
else
|
||||
{
|
||||
ensure_surface (window);
|
||||
|
||||
mir_surface_get_graphics_region (impl->surface, ®ion);
|
||||
g_assert (region.pixel_format == mir_pixel_format_argb_8888);
|
||||
|
||||
// FIXME: Should calculate this once
|
||||
switch (region.pixel_format)
|
||||
{
|
||||
case mir_pixel_format_argb_8888:
|
||||
pixel_format = CAIRO_FORMAT_ARGB32;
|
||||
break;
|
||||
default:
|
||||
case mir_pixel_format_abgr_8888:
|
||||
case mir_pixel_format_xbgr_8888:
|
||||
case mir_pixel_format_xrgb_8888:
|
||||
case mir_pixel_format_bgr_888:
|
||||
// uh-oh...
|
||||
g_printerr ("Unsupported pixel format %d\n", region.pixel_format);
|
||||
break;
|
||||
}
|
||||
|
||||
cairo_surface = cairo_image_surface_create_for_data ((unsigned char *) region.vaddr,
|
||||
pixel_format,
|
||||
@@ -431,13 +397,10 @@ gdk_mir_window_impl_show (GdkWindow *window,
|
||||
/* Make sure there's a surface to see */
|
||||
ensure_surface (window);
|
||||
|
||||
if (!window->gl_paint_context)
|
||||
{
|
||||
/* Make sure something is rendered and then show first frame */
|
||||
s = gdk_mir_window_impl_ref_cairo_surface (window);
|
||||
send_buffer (window);
|
||||
cairo_surface_destroy (s);
|
||||
}
|
||||
/* Make sure something is rendered and then show first frame */
|
||||
s = gdk_mir_window_impl_ref_cairo_surface (window);
|
||||
send_buffer (window);
|
||||
cairo_surface_destroy (s);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -594,25 +557,8 @@ gdk_mir_window_impl_set_device_cursor (GdkWindow *window,
|
||||
GdkDevice *device,
|
||||
GdkCursor *cursor)
|
||||
{
|
||||
const gchar *cursor_name;
|
||||
MirCursorConfiguration *configuration;
|
||||
|
||||
if (cursor)
|
||||
cursor_name = _gdk_mir_cursor_get_name (cursor);
|
||||
else
|
||||
cursor_name = mir_default_cursor_name;
|
||||
|
||||
configuration = mir_cursor_configuration_from_name (cursor_name);
|
||||
|
||||
if (configuration)
|
||||
{
|
||||
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
||||
|
||||
if (impl->surface)
|
||||
mir_surface_configure_cursor (impl->surface, configuration);
|
||||
|
||||
mir_cursor_configuration_destroy (configuration);
|
||||
}
|
||||
//g_printerr ("gdk_mir_window_impl_set_device_cursor window=%p\n", window);
|
||||
/* We don't support cursors yet... */
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -679,7 +625,7 @@ gdk_mir_window_impl_end_paint (GdkWindow *window)
|
||||
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
||||
|
||||
//g_printerr ("gdk_mir_window_impl_end_paint window=%p\n", window);
|
||||
if (impl->visible && !window->current_paint.use_gl)
|
||||
if (impl->visible)
|
||||
send_buffer (window);
|
||||
}
|
||||
|
||||
@@ -754,70 +700,14 @@ static void
|
||||
gdk_mir_window_impl_set_type_hint (GdkWindow *window,
|
||||
GdkWindowTypeHint hint)
|
||||
{
|
||||
MirSurfaceType mir_type = mir_surface_type_normal;
|
||||
|
||||
switch (hint)
|
||||
{
|
||||
case GDK_WINDOW_TYPE_HINT_NORMAL:
|
||||
case GDK_WINDOW_TYPE_HINT_DOCK:
|
||||
case GDK_WINDOW_TYPE_HINT_DESKTOP:
|
||||
mir_type = mir_surface_type_normal;
|
||||
break;
|
||||
case GDK_WINDOW_TYPE_HINT_DIALOG:
|
||||
mir_type = mir_surface_type_dialog;
|
||||
break;
|
||||
case GDK_WINDOW_TYPE_HINT_UTILITY:
|
||||
mir_type = mir_surface_type_utility;
|
||||
break;
|
||||
case GDK_WINDOW_TYPE_HINT_MENU:
|
||||
case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU:
|
||||
case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
|
||||
case GDK_WINDOW_TYPE_HINT_COMBO:
|
||||
mir_type = mir_surface_type_menu;
|
||||
break;
|
||||
case GDK_WINDOW_TYPE_HINT_TOOLTIP:
|
||||
mir_type = mir_surface_type_tip;
|
||||
break;
|
||||
case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
|
||||
case GDK_WINDOW_TYPE_HINT_DND:
|
||||
case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
|
||||
mir_type = mir_surface_type_overlay;
|
||||
break;
|
||||
case GDK_WINDOW_TYPE_HINT_TOOLBAR:
|
||||
mir_type = mir_surface_type_satellite;
|
||||
break;
|
||||
}
|
||||
|
||||
set_surface_type (GDK_MIR_WINDOW_IMPL (window->impl), mir_type);
|
||||
//g_printerr ("gdk_mir_window_impl_set_type_hint window=%p\n", window);
|
||||
// FIXME: ?
|
||||
}
|
||||
|
||||
static GdkWindowTypeHint
|
||||
gdk_mir_window_impl_get_type_hint (GdkWindow *window)
|
||||
{
|
||||
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
||||
|
||||
switch (impl->surface_type)
|
||||
{
|
||||
case mir_surface_type_normal:
|
||||
case mir_surface_type_freestyle:
|
||||
case mir_surface_type_inputmethod:
|
||||
return GDK_WINDOW_TYPE_HINT_NORMAL;
|
||||
case mir_surface_type_utility:
|
||||
return GDK_WINDOW_TYPE_HINT_UTILITY;
|
||||
case mir_surface_type_dialog:
|
||||
return GDK_WINDOW_TYPE_HINT_DIALOG;
|
||||
case mir_surface_type_tip:
|
||||
return GDK_WINDOW_TYPE_HINT_TOOLTIP;
|
||||
case mir_surface_type_menu:
|
||||
return GDK_WINDOW_TYPE_HINT_MENU;
|
||||
case mir_surface_type_overlay:
|
||||
return GDK_WINDOW_TYPE_HINT_NOTIFICATION;
|
||||
case mir_surface_type_satellite:
|
||||
return GDK_WINDOW_TYPE_HINT_TOOLBAR;
|
||||
case mir_surface_types:
|
||||
break;
|
||||
}
|
||||
|
||||
g_printerr ("gdk_mir_window_impl_get_type_hint window=%p\n", window);
|
||||
return GDK_WINDOW_TYPE_HINT_NORMAL;
|
||||
}
|
||||
|
||||
@@ -1258,279 +1148,6 @@ gdk_mir_window_impl_set_shadow_width (GdkWindow *window,
|
||||
g_printerr ("gdk_mir_window_impl_set_shadow_width window=%p\n", window);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
find_eglconfig_for_window (GdkWindow *window,
|
||||
EGLConfig *egl_config_out,
|
||||
GError **error)
|
||||
{
|
||||
GdkDisplay *display = gdk_window_get_display (window);
|
||||
EGLDisplay *egl_display = _gdk_mir_display_get_egl_display (display);
|
||||
GdkVisual *visual = gdk_window_get_visual (window);
|
||||
EGLint attrs[MAX_EGL_ATTRS];
|
||||
EGLint count;
|
||||
EGLConfig *configs;
|
||||
gboolean use_rgba;
|
||||
|
||||
int i = 0;
|
||||
|
||||
attrs[i++] = EGL_SURFACE_TYPE;
|
||||
attrs[i++] = EGL_WINDOW_BIT;
|
||||
|
||||
attrs[i++] = EGL_COLOR_BUFFER_TYPE;
|
||||
attrs[i++] = EGL_RGB_BUFFER;
|
||||
|
||||
attrs[i++] = EGL_RED_SIZE;
|
||||
attrs[i++] = 1;
|
||||
attrs[i++] = EGL_GREEN_SIZE;
|
||||
attrs[i++] = 1;
|
||||
attrs[i++] = EGL_BLUE_SIZE;
|
||||
attrs[i++] = 1;
|
||||
|
||||
use_rgba = (visual == gdk_screen_get_rgba_visual (gdk_display_get_default_screen (display)));
|
||||
|
||||
if (use_rgba)
|
||||
{
|
||||
attrs[i++] = EGL_ALPHA_SIZE;
|
||||
attrs[i++] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
attrs[i++] = EGL_ALPHA_SIZE;
|
||||
attrs[i++] = 0;
|
||||
}
|
||||
|
||||
attrs[i++] = EGL_NONE;
|
||||
g_assert (i < MAX_EGL_ATTRS);
|
||||
|
||||
if (!eglChooseConfig (egl_display, attrs, NULL, 0, &count) || count < 1)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
|
||||
_("No available configurations for the given pixel format"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
configs = g_new (EGLConfig, count);
|
||||
|
||||
if (!eglChooseConfig (egl_display, attrs, configs, count, &count) || count < 1)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
|
||||
_("No available configurations for the given pixel format"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Pick first valid configuration i guess? */
|
||||
|
||||
if (egl_config_out != NULL)
|
||||
*egl_config_out = configs[0];
|
||||
|
||||
g_free (configs);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GdkGLContext *
|
||||
gdk_mir_window_impl_create_gl_context (GdkWindow *window,
|
||||
gboolean attached,
|
||||
GdkGLProfile profile,
|
||||
GdkGLContext *share,
|
||||
GError **error)
|
||||
{
|
||||
GdkDisplay *display = gdk_window_get_display (window);
|
||||
GdkMirGLContext *context;
|
||||
EGLContext ctx;
|
||||
EGLConfig config;
|
||||
int i;
|
||||
EGLint context_attribs[3];
|
||||
|
||||
if (!_gdk_mir_display_init_egl_display (display))
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("No GL implementation is available"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (profile == GDK_GL_PROFILE_DEFAULT)
|
||||
profile = GDK_GL_PROFILE_LEGACY;
|
||||
|
||||
if (profile == GDK_GL_PROFILE_3_2_CORE &&
|
||||
!_gdk_mir_display_have_egl_khr_create_context (display))
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
|
||||
_("3.2 core GL profile is not available on EGL implementation"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!find_eglconfig_for_window (window, &config, error))
|
||||
return NULL;
|
||||
|
||||
i = 0;
|
||||
if (profile == GDK_GL_PROFILE_3_2_CORE)
|
||||
{
|
||||
context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
|
||||
context_attribs[i++] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
|
||||
}
|
||||
context_attribs[i++] = EGL_NONE;
|
||||
|
||||
ctx = eglCreateContext (_gdk_mir_display_get_egl_display (display),
|
||||
config,
|
||||
share ? GDK_MIR_GL_CONTEXT (share)->egl_context : EGL_NO_CONTEXT,
|
||||
context_attribs);
|
||||
if (ctx == NULL)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("Unable to create a GL context"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GDK_NOTE (OPENGL,
|
||||
g_print ("Created EGL context[%p]\n", ctx));
|
||||
|
||||
context = g_object_new (GDK_TYPE_MIR_GL_CONTEXT,
|
||||
"display", display,
|
||||
"window", window,
|
||||
"profile", profile,
|
||||
"shared-context", share,
|
||||
NULL);
|
||||
|
||||
context->egl_config = config;
|
||||
context->egl_context = ctx;
|
||||
context->is_attached = attached;
|
||||
|
||||
return GDK_GL_CONTEXT (context);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_mir_window_impl_invalidate_for_new_frame (GdkWindow *window,
|
||||
cairo_region_t *update_area)
|
||||
{
|
||||
cairo_rectangle_int_t window_rect;
|
||||
GdkDisplay *display = gdk_window_get_display (window);
|
||||
GdkMirGLContext *context_mir;
|
||||
int buffer_age;
|
||||
gboolean invalidate_all;
|
||||
EGLSurface egl_surface;
|
||||
|
||||
/* Minimal update is ok if we're not drawing with gl */
|
||||
if (window->gl_paint_context == NULL)
|
||||
return;
|
||||
|
||||
context_mir = GDK_MIR_GL_CONTEXT (window->gl_paint_context);
|
||||
buffer_age = 0;
|
||||
|
||||
egl_surface = _gdk_mir_window_get_egl_surface (window, context_mir->egl_config);
|
||||
|
||||
if (_gdk_mir_display_have_egl_buffer_age (display))
|
||||
{
|
||||
gdk_gl_context_make_current (window->gl_paint_context);
|
||||
eglQuerySurface (_gdk_mir_display_get_egl_display (display), egl_surface,
|
||||
EGL_BUFFER_AGE_EXT, &buffer_age);
|
||||
}
|
||||
|
||||
invalidate_all = FALSE;
|
||||
if (buffer_age == 0 || buffer_age >= 4)
|
||||
invalidate_all = TRUE;
|
||||
else
|
||||
{
|
||||
if (buffer_age >= 2)
|
||||
{
|
||||
if (window->old_updated_area[0])
|
||||
cairo_region_union (update_area, window->old_updated_area[0]);
|
||||
else
|
||||
invalidate_all = TRUE;
|
||||
}
|
||||
if (buffer_age >= 3)
|
||||
{
|
||||
if (window->old_updated_area[1])
|
||||
cairo_region_union (update_area, window->old_updated_area[1]);
|
||||
else
|
||||
invalidate_all = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (invalidate_all)
|
||||
{
|
||||
window_rect.x = 0;
|
||||
window_rect.y = 0;
|
||||
window_rect.width = gdk_window_get_width (window);
|
||||
window_rect.height = gdk_window_get_height (window);
|
||||
|
||||
/* If nothing else is known, repaint everything so that the back
|
||||
buffer is fully up-to-date for the swapbuffer */
|
||||
cairo_region_union_rectangle (update_area, &window_rect);
|
||||
}
|
||||
}
|
||||
|
||||
EGLSurface
|
||||
_gdk_mir_window_get_egl_surface (GdkWindow *window,
|
||||
EGLConfig config)
|
||||
{
|
||||
GdkMirWindowImpl *impl;
|
||||
|
||||
impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
||||
|
||||
if (!impl->egl_surface)
|
||||
{
|
||||
EGLDisplay egl_display;
|
||||
EGLNativeWindowType egl_window;
|
||||
|
||||
ensure_no_surface (window);
|
||||
ensure_surface_full (window, mir_buffer_usage_hardware);
|
||||
|
||||
egl_display = _gdk_mir_display_get_egl_display (gdk_window_get_display (window));
|
||||
egl_window = (EGLNativeWindowType) mir_surface_get_egl_native_window (impl->surface);
|
||||
|
||||
impl->egl_surface =
|
||||
eglCreateWindowSurface (egl_display, config, egl_window, NULL);
|
||||
}
|
||||
|
||||
return impl->egl_surface;
|
||||
}
|
||||
|
||||
EGLSurface
|
||||
_gdk_mir_window_get_dummy_egl_surface (GdkWindow *window,
|
||||
EGLConfig config)
|
||||
{
|
||||
GdkMirWindowImpl *impl;
|
||||
|
||||
impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
||||
|
||||
if (!impl->dummy_egl_surface)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
EGLDisplay egl_display;
|
||||
EGLNativeWindowType egl_window;
|
||||
|
||||
display = gdk_window_get_display (window);
|
||||
impl->dummy_surface = create_mir_surface (display, 1, 1,
|
||||
mir_buffer_usage_hardware);
|
||||
|
||||
egl_display = _gdk_mir_display_get_egl_display (display);
|
||||
egl_window = (EGLNativeWindowType) mir_surface_get_egl_native_window (impl->surface);
|
||||
|
||||
impl->dummy_egl_surface =
|
||||
eglCreateWindowSurface (egl_display, config, egl_window, NULL);
|
||||
}
|
||||
|
||||
return impl->dummy_egl_surface;
|
||||
}
|
||||
|
||||
MirSurface *
|
||||
gdk_mir_window_get_mir_surface (GdkWindow *window)
|
||||
{
|
||||
GdkMirWindowImpl *impl;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_MIR_WINDOW (window), NULL);
|
||||
|
||||
impl = GDK_MIR_WINDOW_IMPL (window->impl);
|
||||
|
||||
return impl->surface;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_mir_window_impl_class_init (GdkMirWindowImplClass *klass)
|
||||
{
|
||||
@@ -1619,6 +1236,4 @@ gdk_mir_window_impl_class_init (GdkMirWindowImplClass *klass)
|
||||
impl_class->get_scale_factor = gdk_mir_window_impl_get_scale_factor;
|
||||
impl_class->set_opaque_region = gdk_mir_window_impl_set_opaque_region;
|
||||
impl_class->set_shadow_width = gdk_mir_window_impl_set_shadow_width;
|
||||
impl_class->create_gl_context = gdk_mir_window_impl_create_gl_context;
|
||||
impl_class->invalidate_for_new_frame = gdk_mir_window_impl_invalidate_for_new_frame;
|
||||
}
|
||||
|
||||
@@ -308,9 +308,13 @@ _gdk_wayland_display_get_cursor_for_surface (GdkDisplay *display,
|
||||
|
||||
if (surface)
|
||||
{
|
||||
double sx, sy;
|
||||
cairo_surface_get_device_scale (surface, &sx, &sy);
|
||||
cursor->surface.scale = (int)sx;
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
{
|
||||
double sx, sy;
|
||||
cairo_surface_get_device_scale (surface, &sx, &sy);
|
||||
cursor->surface.scale = (int)sx;
|
||||
}
|
||||
#endif
|
||||
cursor->surface.width = cairo_image_surface_get_width (surface);
|
||||
cursor->surface.height = cairo_image_surface_get_height (surface);
|
||||
}
|
||||
|
||||
@@ -538,48 +538,12 @@ _gdk_wayland_device_get_keymap (GdkDevice *device)
|
||||
return GDK_WAYLAND_DEVICE (device)->device->keymap;
|
||||
}
|
||||
|
||||
static void
|
||||
emit_selection_owner_change (GdkWindow *window,
|
||||
GdkAtom atom)
|
||||
{
|
||||
GdkEvent *event;
|
||||
|
||||
event = gdk_event_new (GDK_OWNER_CHANGE);
|
||||
event->owner_change.window = g_object_ref (window);
|
||||
event->owner_change.owner = NULL;
|
||||
event->owner_change.reason = GDK_OWNER_CHANGE_NEW_OWNER;
|
||||
event->owner_change.selection = atom;
|
||||
event->owner_change.time = GDK_CURRENT_TIME;
|
||||
event->owner_change.selection_time = GDK_CURRENT_TIME;
|
||||
|
||||
gdk_event_put (event);
|
||||
gdk_event_free (event);
|
||||
}
|
||||
|
||||
static void
|
||||
emit_selection_owner_change_forall (GdkAtom atom)
|
||||
{
|
||||
GdkDisplay *display = gdk_display_get_default ();
|
||||
GdkScreen *screen = GDK_WAYLAND_DISPLAY (display)->screen;
|
||||
GList *windows, *l;
|
||||
|
||||
windows = gdk_screen_get_toplevel_windows (screen);
|
||||
|
||||
for (l = windows; l; l = l->next)
|
||||
emit_selection_owner_change (l->data, atom);
|
||||
|
||||
g_list_free (windows);
|
||||
}
|
||||
|
||||
static void
|
||||
data_device_data_offer (void *data,
|
||||
struct wl_data_device *data_device,
|
||||
struct wl_data_offer *_offer)
|
||||
{
|
||||
GdkWaylandDeviceData *device = (GdkWaylandDeviceData *)data;
|
||||
gdk_wayland_selection_set_offer (device->display, _offer);
|
||||
|
||||
emit_selection_owner_change_forall (gdk_atom_intern_static_string ("GdkWaylandSelection"));
|
||||
gdk_wayland_selection_set_offer (_offer);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -609,7 +573,7 @@ data_device_enter (void *data,
|
||||
|
||||
gdk_wayland_drop_context_update_targets (device->drop_context);
|
||||
|
||||
dnd_owner = gdk_selection_owner_get_for_display (device->display, gdk_drag_get_selection (device->drop_context));
|
||||
dnd_owner = gdk_selection_owner_get (gdk_drag_get_selection (device->drop_context));
|
||||
|
||||
if (dnd_owner)
|
||||
_gdk_wayland_drag_context_set_source_window (device->drop_context, dnd_owner);
|
||||
@@ -621,9 +585,7 @@ data_device_enter (void *data,
|
||||
wl_fixed_to_double (y));
|
||||
_gdk_wayland_drag_context_emit_event (device->drop_context, GDK_DRAG_ENTER,
|
||||
GDK_CURRENT_TIME);
|
||||
gdk_wayland_selection_set_offer (device->display, offer);
|
||||
emit_selection_owner_change (dest_window,
|
||||
gdk_atom_intern_static_string ("GdkWaylandSelection"));
|
||||
gdk_wayland_selection_set_offer (offer);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -683,7 +645,7 @@ data_device_drop (void *data,
|
||||
g_debug (G_STRLOC ": %s data_device = %p",
|
||||
G_STRFUNC, data_device);
|
||||
|
||||
local_dnd_owner = gdk_selection_owner_get_for_display (device->display, gdk_drag_get_selection (device->drop_context));
|
||||
local_dnd_owner = gdk_selection_owner_get (gdk_drag_get_selection (device->drop_context));
|
||||
|
||||
if (local_dnd_owner)
|
||||
{
|
||||
@@ -702,13 +664,10 @@ data_device_selection (void *data,
|
||||
struct wl_data_device *wl_data_device,
|
||||
struct wl_data_offer *offer)
|
||||
{
|
||||
GdkWaylandDeviceData *device = (GdkWaylandDeviceData *) data;
|
||||
|
||||
g_debug (G_STRLOC ": %s wl_data_device = %p wl_data_offer = %p",
|
||||
G_STRFUNC, wl_data_device, offer);
|
||||
|
||||
gdk_wayland_selection_set_offer (device->display, offer);
|
||||
emit_selection_owner_change_forall (gdk_atom_intern_static_string ("CLIPBOARD"));
|
||||
gdk_wayland_selection_set_offer (offer);
|
||||
}
|
||||
|
||||
static const struct wl_data_device_listener data_device_listener = {
|
||||
|
||||
@@ -432,6 +432,19 @@ gdk_wayland_display_notify_startup_complete (GdkDisplay *display,
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_display_event_data_copy (GdkDisplay *display,
|
||||
const GdkEvent *src,
|
||||
GdkEvent *dst)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_display_event_data_free (GdkDisplay *display,
|
||||
GdkEvent *event)
|
||||
{
|
||||
}
|
||||
|
||||
static GdkKeymap *
|
||||
_gdk_wayland_display_get_keymap (GdkDisplay *display)
|
||||
{
|
||||
@@ -522,6 +535,8 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass * class)
|
||||
display_class->after_process_all_updates = gdk_wayland_display_after_process_all_updates;
|
||||
display_class->get_next_serial = gdk_wayland_display_get_next_serial;
|
||||
display_class->notify_startup_complete = gdk_wayland_display_notify_startup_complete;
|
||||
display_class->event_data_copy = gdk_wayland_display_event_data_copy;
|
||||
display_class->event_data_free = gdk_wayland_display_event_data_free;
|
||||
display_class->create_window_impl = _gdk_wayland_display_create_window_impl;
|
||||
display_class->get_keymap = _gdk_wayland_display_get_keymap;
|
||||
display_class->push_error_trap = gdk_wayland_display_push_error_trap;
|
||||
@@ -534,6 +549,7 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass * class)
|
||||
display_class->text_property_to_utf8_list = _gdk_wayland_display_text_property_to_utf8_list;
|
||||
display_class->utf8_to_string_target = _gdk_wayland_display_utf8_to_string_target;
|
||||
|
||||
display_class->destroy_gl_context = gdk_wayland_display_destroy_gl_context;
|
||||
display_class->make_gl_context_current = gdk_wayland_display_make_gl_context_current;
|
||||
}
|
||||
|
||||
@@ -800,7 +816,9 @@ _gdk_wayland_display_create_shm_surface (GdkWaylandDisplay *display,
|
||||
cairo_surface_set_user_data (surface, &gdk_wayland_cairo_key,
|
||||
data, gdk_wayland_cairo_surface_destroy);
|
||||
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_set_device_scale (surface, scale, scale);
|
||||
#endif
|
||||
|
||||
status = cairo_surface_status (surface);
|
||||
if (status != CAIRO_STATUS_SUCCESS)
|
||||
|
||||
@@ -65,13 +65,12 @@ gdk_wayland_drag_context_finalize (GObject *object)
|
||||
{
|
||||
GdkWaylandDragContext *wayland_context = GDK_WAYLAND_DRAG_CONTEXT (object);
|
||||
GdkDragContext *context = GDK_DRAG_CONTEXT (object);
|
||||
GdkDisplay *display = gdk_window_get_display (context->source_window);
|
||||
|
||||
contexts = g_list_remove (contexts, context);
|
||||
|
||||
if (context->is_source &&
|
||||
gdk_selection_owner_get_for_display (display, gdk_drag_get_selection (context)) == context->source_window)
|
||||
gdk_wayland_selection_unset_data_source (display, gdk_drag_get_selection (context));
|
||||
gdk_selection_owner_get (gdk_drag_get_selection (context)) == context->source_window)
|
||||
gdk_wayland_selection_unset_data_source (gdk_drag_get_selection (context));
|
||||
|
||||
if (wayland_context->data_source)
|
||||
wl_data_source_destroy (wayland_context->data_source);
|
||||
@@ -192,12 +191,10 @@ gdk_wayland_drop_context_set_status (GdkDragContext *context,
|
||||
gboolean accepted)
|
||||
{
|
||||
GdkWaylandDragContext *context_wayland;
|
||||
GdkDisplay *display;
|
||||
struct wl_data_offer *wl_offer;
|
||||
|
||||
context_wayland = GDK_WAYLAND_DRAG_CONTEXT (context);
|
||||
display = gdk_window_get_display (context->source_window);
|
||||
wl_offer = gdk_wayland_selection_get_offer (display);
|
||||
wl_offer = gdk_wayland_selection_get_offer ();
|
||||
|
||||
if (!wl_offer)
|
||||
return;
|
||||
@@ -244,10 +241,8 @@ gdk_wayland_drag_context_drop_finish (GdkDragContext *context,
|
||||
gboolean success,
|
||||
guint32 time)
|
||||
{
|
||||
GdkDisplay *display = gdk_window_get_display (context->source_window);
|
||||
|
||||
if (gdk_selection_owner_get_for_display (display, gdk_drag_get_selection (context)))
|
||||
gdk_wayland_selection_unset_data_source (display, gdk_drag_get_selection (context));
|
||||
if (gdk_selection_owner_get (gdk_drag_get_selection (context)))
|
||||
gdk_wayland_selection_unset_data_source (gdk_drag_get_selection (context));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -306,11 +301,14 @@ _gdk_wayland_window_register_dnd (GdkWindow *window)
|
||||
}
|
||||
|
||||
static GdkWindow *
|
||||
create_dnd_window (GdkScreen *screen)
|
||||
create_dnd_window (void)
|
||||
{
|
||||
GdkWindowAttr attrs;
|
||||
GdkScreen *screen;
|
||||
guint mask;
|
||||
|
||||
screen = gdk_display_get_default_screen (gdk_display_get_default ());
|
||||
|
||||
attrs.x = attrs.y = 0;
|
||||
attrs.width = attrs.height = 100;
|
||||
attrs.wclass = GDK_INPUT_OUTPUT;
|
||||
@@ -345,7 +343,7 @@ _gdk_wayland_window_drag_begin (GdkWindow *window,
|
||||
gdk_drag_context_set_device (context, device);
|
||||
display_wayland = GDK_WAYLAND_DISPLAY (gdk_device_get_display (device));
|
||||
|
||||
context_wayland->dnd_window = create_dnd_window (gdk_window_get_screen (window));
|
||||
context_wayland->dnd_window = create_dnd_window ();
|
||||
context_wayland->dnd_surface = gdk_wayland_window_get_wl_surface (context_wayland->dnd_window);
|
||||
context_wayland->data_source =
|
||||
gdk_wayland_selection_get_data_source (window,
|
||||
@@ -382,9 +380,8 @@ _gdk_wayland_drop_context_new (GdkDevice *device,
|
||||
void
|
||||
gdk_wayland_drop_context_update_targets (GdkDragContext *context)
|
||||
{
|
||||
GdkDisplay *display = gdk_window_get_display (context->source_window);
|
||||
g_list_free (context->targets);
|
||||
context->targets = g_list_copy (gdk_wayland_selection_get_targets (display));
|
||||
context->targets = g_list_copy (gdk_wayland_selection_get_targets ());
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -35,7 +35,23 @@
|
||||
|
||||
G_DEFINE_TYPE (GdkWaylandGLContext, gdk_wayland_gl_context, GDK_TYPE_GL_CONTEXT)
|
||||
|
||||
static void gdk_x11_gl_context_dispose (GObject *gobject);
|
||||
static void
|
||||
gdk_wayland_gl_context_update (GdkGLContext *context)
|
||||
{
|
||||
GdkWindow *window = gdk_gl_context_get_window (context);
|
||||
int width, height;
|
||||
|
||||
gdk_gl_context_make_current (context);
|
||||
|
||||
width = gdk_window_get_width (window);
|
||||
height = gdk_window_get_height (window);
|
||||
|
||||
GDK_NOTE (OPENGL, g_print ("Updating GL viewport size to { %d, %d } for window %p (context: %p)\n",
|
||||
width, height,
|
||||
window, context));
|
||||
|
||||
glViewport (0, 0, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_wayland_window_invalidate_for_new_frame (GdkWindow *window,
|
||||
@@ -143,10 +159,9 @@ static void
|
||||
gdk_wayland_gl_context_class_init (GdkWaylandGLContextClass *klass)
|
||||
{
|
||||
GdkGLContextClass *context_class = GDK_GL_CONTEXT_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
context_class->update = gdk_wayland_gl_context_update;
|
||||
context_class->end_frame = gdk_wayland_gl_context_end_frame;
|
||||
gobject_class->dispose = gdk_x11_gl_context_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -234,11 +249,11 @@ find_eglconfig_for_window (GdkWindow *window,
|
||||
attrs[i++] = EGL_RGB_BUFFER;
|
||||
|
||||
attrs[i++] = EGL_RED_SIZE;
|
||||
attrs[i++] = 1;
|
||||
attrs[i++] = gdk_visual_get_bits_per_rgb (visual);
|
||||
attrs[i++] = EGL_GREEN_SIZE;
|
||||
attrs[i++] = 1;
|
||||
attrs[i++] = gdk_visual_get_bits_per_rgb (visual);
|
||||
attrs[i++] = EGL_BLUE_SIZE;
|
||||
attrs[i++] = 1;
|
||||
attrs[i++] = gdk_visual_get_bits_per_rgb (visual);
|
||||
|
||||
use_rgba = (visual == gdk_screen_get_rgba_visual (gdk_display_get_default_screen (display)));
|
||||
|
||||
@@ -307,9 +322,6 @@ gdk_wayland_window_create_gl_context (GdkWindow *window,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (profile == GDK_GL_PROFILE_DEFAULT)
|
||||
profile = GDK_GL_PROFILE_LEGACY;
|
||||
|
||||
if (profile == GDK_GL_PROFILE_3_2_CORE &&
|
||||
!display_wayland->have_egl_khr_create_context)
|
||||
{
|
||||
@@ -346,10 +358,8 @@ gdk_wayland_window_create_gl_context (GdkWindow *window,
|
||||
g_print ("Created EGL context[%p]\n", ctx));
|
||||
|
||||
context = g_object_new (GDK_TYPE_WAYLAND_GL_CONTEXT,
|
||||
"display", display,
|
||||
"window", window,
|
||||
"profile", profile,
|
||||
"shared-context", share,
|
||||
"visual", gdk_window_get_visual (window),
|
||||
NULL);
|
||||
|
||||
context->egl_config = config;
|
||||
@@ -359,18 +369,16 @@ gdk_wayland_window_create_gl_context (GdkWindow *window,
|
||||
return GDK_GL_CONTEXT (context);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_gl_context_dispose (GObject *gobject)
|
||||
void
|
||||
gdk_wayland_display_destroy_gl_context (GdkDisplay *display,
|
||||
GdkGLContext *context)
|
||||
{
|
||||
GdkWaylandGLContext *context_wayland = GDK_WAYLAND_GL_CONTEXT (gobject);
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
GdkWaylandGLContext *context_wayland = GDK_WAYLAND_GL_CONTEXT (context);
|
||||
|
||||
/* TODO: Unset as current if current? */
|
||||
if (context_wayland->egl_context != NULL)
|
||||
{
|
||||
GdkGLContext *context = GDK_GL_CONTEXT (gobject);
|
||||
GdkWindow *window = gdk_gl_context_get_window (context);
|
||||
GdkDisplay *display = gdk_window_get_display (window);
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
|
||||
if (eglGetCurrentContext () == context_wayland->egl_context)
|
||||
eglMakeCurrent(display_wayland->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT);
|
||||
@@ -381,11 +389,9 @@ gdk_x11_gl_context_dispose (GObject *gobject)
|
||||
context_wayland->egl_context);
|
||||
context_wayland->egl_context = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gdk_wayland_gl_context_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
gboolean
|
||||
void
|
||||
gdk_wayland_display_make_gl_context_current (GdkDisplay *display,
|
||||
GdkGLContext *context)
|
||||
{
|
||||
@@ -398,7 +404,7 @@ gdk_wayland_display_make_gl_context_current (GdkDisplay *display,
|
||||
{
|
||||
eglMakeCurrent(display_wayland->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT);
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
context_wayland = GDK_WAYLAND_GL_CONTEXT (context);
|
||||
@@ -416,11 +422,6 @@ gdk_wayland_display_make_gl_context_current (GdkDisplay *display,
|
||||
}
|
||||
|
||||
if (!eglMakeCurrent (display_wayland->egl_display, egl_surface,
|
||||
egl_surface, context_wayland->egl_context))
|
||||
{
|
||||
g_warning ("eglMakeCurrent failed");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
egl_surface, context_wayland->egl_context))
|
||||
g_critical ("eglMakeCurrent failed");
|
||||
}
|
||||
|
||||
@@ -55,7 +55,9 @@ GdkGLContext * gdk_wayland_window_create_gl_context (GdkWindow
|
||||
GError **error);
|
||||
void gdk_wayland_window_invalidate_for_new_frame (GdkWindow *window,
|
||||
cairo_region_t *update_area);
|
||||
gboolean gdk_wayland_display_make_gl_context_current (GdkDisplay *display,
|
||||
void gdk_wayland_display_destroy_gl_context (GdkDisplay *display,
|
||||
GdkGLContext *context);
|
||||
void gdk_wayland_display_make_gl_context_current (GdkDisplay *display,
|
||||
GdkGLContext *context);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -224,10 +224,9 @@ GdkWaylandSelection * gdk_wayland_display_get_selection (GdkDisplay *display);
|
||||
GdkWaylandSelection * gdk_wayland_selection_new (void);
|
||||
void gdk_wayland_selection_free (GdkWaylandSelection *selection);
|
||||
|
||||
void gdk_wayland_selection_set_offer (GdkDisplay *display,
|
||||
struct wl_data_offer *wl_offer);
|
||||
struct wl_data_offer * gdk_wayland_selection_get_offer (GdkDisplay *display);
|
||||
GList * gdk_wayland_selection_get_targets (GdkDisplay *display);
|
||||
void gdk_wayland_selection_set_offer (struct wl_data_offer *offer);
|
||||
struct wl_data_offer * gdk_wayland_selection_get_offer (void);
|
||||
GList * gdk_wayland_selection_get_targets (void);
|
||||
|
||||
void gdk_wayland_selection_store (GdkWindow *window,
|
||||
GdkAtom type,
|
||||
@@ -236,7 +235,7 @@ void gdk_wayland_selection_store (GdkWindow *window,
|
||||
gint len);
|
||||
struct wl_data_source * gdk_wayland_selection_get_data_source (GdkWindow *owner,
|
||||
GdkAtom selection);
|
||||
void gdk_wayland_selection_unset_data_source (GdkDisplay *display, GdkAtom selection);
|
||||
void gdk_wayland_selection_unset_data_source (GdkAtom selection);
|
||||
|
||||
EGLSurface gdk_wayland_window_get_egl_surface (GdkWindow *window,
|
||||
EGLConfig config);
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "gdkwayland.h"
|
||||
#include "gdkprivate-wayland.h"
|
||||
#include "gdkdisplay-wayland.h"
|
||||
#include "gdkdndprivate.h"
|
||||
#include "gdkselection.h"
|
||||
#include "gdkproperty.h"
|
||||
#include "gdkprivate.h"
|
||||
@@ -321,9 +320,9 @@ static const struct wl_data_offer_listener data_offer_listener = {
|
||||
};
|
||||
|
||||
void
|
||||
gdk_wayland_selection_set_offer (GdkDisplay *display,
|
||||
struct wl_data_offer *wl_offer)
|
||||
gdk_wayland_selection_set_offer (struct wl_data_offer *wl_offer)
|
||||
{
|
||||
GdkDisplay *display = gdk_display_get_default ();
|
||||
GdkWaylandSelection *selection = gdk_wayland_display_get_selection (display);
|
||||
|
||||
if (selection->offer == wl_offer)
|
||||
@@ -346,16 +345,18 @@ gdk_wayland_selection_set_offer (GdkDisplay *display,
|
||||
}
|
||||
|
||||
struct wl_data_offer *
|
||||
gdk_wayland_selection_get_offer (GdkDisplay *display)
|
||||
gdk_wayland_selection_get_offer (void)
|
||||
{
|
||||
GdkDisplay *display = gdk_display_get_default ();
|
||||
GdkWaylandSelection *selection = gdk_wayland_display_get_selection (display);
|
||||
|
||||
return selection->offer;
|
||||
}
|
||||
|
||||
GList *
|
||||
gdk_wayland_selection_get_targets (GdkDisplay *display)
|
||||
gdk_wayland_selection_get_targets (void)
|
||||
{
|
||||
GdkDisplay *display = gdk_display_get_default ();
|
||||
GdkWaylandSelection *selection = gdk_wayland_display_get_selection (display);
|
||||
|
||||
return selection->targets;
|
||||
@@ -475,7 +476,7 @@ gdk_wayland_selection_store (GdkWindow *window,
|
||||
const guchar *data,
|
||||
gint len)
|
||||
{
|
||||
GdkDisplay *display = gdk_window_get_display (window);
|
||||
GdkDisplay *display = gdk_display_get_default ();
|
||||
GdkWaylandSelection *selection = gdk_wayland_display_get_selection (display);
|
||||
GArray *array;
|
||||
|
||||
@@ -525,7 +526,7 @@ gdk_wayland_selection_store (GdkWindow *window,
|
||||
static SelectionBuffer *
|
||||
gdk_wayland_selection_lookup_requestor_buffer (GdkWindow *requestor)
|
||||
{
|
||||
GdkDisplay *display = gdk_window_get_display (requestor);
|
||||
GdkDisplay *display = gdk_display_get_default ();
|
||||
GdkWaylandSelection *selection = gdk_wayland_display_get_selection (display);
|
||||
SelectionBuffer *buffer_data;
|
||||
GHashTableIter iter;
|
||||
@@ -661,18 +662,16 @@ data_source_cancelled (void *data,
|
||||
{
|
||||
GdkWaylandSelection *wayland_selection = data;
|
||||
GdkDragContext *context;
|
||||
GdkDisplay *display;
|
||||
|
||||
g_debug (G_STRLOC ": %s source = %p",
|
||||
G_STRFUNC, source);
|
||||
|
||||
context = gdk_wayland_drag_context_lookup_by_data_source (source);
|
||||
display = gdk_window_get_display (context->source_window);
|
||||
|
||||
if (source == wayland_selection->dnd_source)
|
||||
gdk_wayland_selection_unset_data_source (display, atoms[ATOM_DND]);
|
||||
gdk_wayland_selection_unset_data_source (atoms[ATOM_DND]);
|
||||
else if (source == wayland_selection->clipboard_source)
|
||||
gdk_wayland_selection_unset_data_source (display, atoms[ATOM_CLIPBOARD]);
|
||||
gdk_wayland_selection_unset_data_source (atoms[ATOM_CLIPBOARD]);
|
||||
|
||||
if (context)
|
||||
gdk_wayland_drag_context_undo_grab (context);
|
||||
@@ -688,7 +687,7 @@ struct wl_data_source *
|
||||
gdk_wayland_selection_get_data_source (GdkWindow *owner,
|
||||
GdkAtom selection)
|
||||
{
|
||||
GdkDisplay *display = gdk_window_get_display (owner);
|
||||
GdkDisplay *display = gdk_display_get_default ();
|
||||
GdkWaylandSelection *wayland_selection = gdk_wayland_display_get_selection (display);
|
||||
struct wl_data_source *source = NULL;
|
||||
GdkWaylandDisplay *display_wayland;
|
||||
@@ -742,15 +741,18 @@ gdk_wayland_selection_get_data_source (GdkWindow *owner,
|
||||
}
|
||||
|
||||
void
|
||||
gdk_wayland_selection_unset_data_source (GdkDisplay *display, GdkAtom selection)
|
||||
gdk_wayland_selection_unset_data_source (GdkAtom selection)
|
||||
{
|
||||
GdkDisplay *display = gdk_display_get_default ();
|
||||
GdkWaylandSelection *wayland_selection = gdk_wayland_display_get_selection (display);
|
||||
|
||||
if (selection == atoms[ATOM_CLIPBOARD])
|
||||
{
|
||||
GdkDeviceManager *device_manager;
|
||||
GdkDisplay *display;
|
||||
GdkDevice *device;
|
||||
|
||||
display = gdk_display_get_default ();
|
||||
device_manager = gdk_display_get_device_manager (display);
|
||||
device = gdk_device_manager_get_client_pointer (device_manager);
|
||||
|
||||
@@ -1021,7 +1023,7 @@ gdk_wayland_selection_add_targets (GdkWindow *window,
|
||||
GdkDisplay *display;
|
||||
GdkDevice *device;
|
||||
|
||||
display = gdk_window_get_display (window);
|
||||
display = gdk_display_get_default ();
|
||||
device_manager = gdk_display_get_device_manager (display);
|
||||
device = gdk_device_manager_get_client_pointer (device_manager);
|
||||
gdk_wayland_device_set_selection (device, data_source);
|
||||
@@ -1029,7 +1031,7 @@ gdk_wayland_selection_add_targets (GdkWindow *window,
|
||||
}
|
||||
|
||||
void
|
||||
gdk_wayland_selection_clear_targets (GdkDisplay *display, GdkAtom selection)
|
||||
gdk_wayland_selection_clear_targets (GdkAtom selection)
|
||||
{
|
||||
gdk_wayland_selection_unset_data_source (display, selection);
|
||||
gdk_wayland_selection_unset_data_source (selection);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ gdk_wayland_selection_add_targets (GdkWindow *window,
|
||||
#define gdk_wayland_selection_clear_targets gdk_wayland_selection_clear_targets_libgtk_only
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void
|
||||
gdk_wayland_selection_clear_targets (GdkDisplay *display, GdkAtom selection);
|
||||
gdk_wayland_selection_clear_targets (GdkAtom selection);
|
||||
|
||||
#define gdk_wayland_drag_context_get_dnd_window gdk_wayland_drag_context_get_dnd_window_libgtk_only
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
||||
@@ -217,7 +217,9 @@ _gdk_wayland_screen_create_root_window (GdkScreen *screen,
|
||||
impl->scale,
|
||||
impl->scale);
|
||||
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_set_device_scale (impl->cairo_surface, impl->scale, impl->scale);
|
||||
#endif
|
||||
|
||||
window->window_type = GDK_WINDOW_ROOT;
|
||||
window->depth = 32;
|
||||
@@ -418,6 +420,11 @@ window_update_scale (GdkWindow *window)
|
||||
scale = MAX (scale, output_scale);
|
||||
}
|
||||
|
||||
#ifndef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
/* Don't announce a scale if we can't support it */
|
||||
scale = 1;
|
||||
#endif
|
||||
|
||||
if (scale != impl->scale)
|
||||
{
|
||||
impl->scale = scale;
|
||||
@@ -1276,32 +1283,6 @@ gdk_window_wayland_restack_toplevel (GdkWindow *window,
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_window_request_transient_parent_commit (GdkWindow *window)
|
||||
{
|
||||
GdkWindowImplWayland *window_impl, *impl;
|
||||
GdkFrameClock *frame_clock;
|
||||
|
||||
window_impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
||||
|
||||
if (!window_impl->transient_for)
|
||||
return;
|
||||
|
||||
impl = GDK_WINDOW_IMPL_WAYLAND (window_impl->transient_for->impl);
|
||||
|
||||
if (!impl->surface || impl->pending_commit)
|
||||
return;
|
||||
|
||||
frame_clock = gdk_window_get_frame_clock (window_impl->transient_for);
|
||||
|
||||
if (!frame_clock)
|
||||
return;
|
||||
|
||||
impl->pending_commit = TRUE;
|
||||
gdk_frame_clock_request_phase (frame_clock,
|
||||
GDK_FRAME_CLOCK_PHASE_AFTER_PAINT);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_window_wayland_move_resize (GdkWindow *window,
|
||||
gboolean with_move,
|
||||
@@ -1324,8 +1305,15 @@ gdk_window_wayland_move_resize (GdkWindow *window,
|
||||
|
||||
if (impl->subsurface)
|
||||
{
|
||||
GdkWindowImplWayland *parent_impl;
|
||||
|
||||
wl_subsurface_set_position (impl->subsurface, x, y);
|
||||
gdk_window_request_transient_parent_commit (window);
|
||||
|
||||
g_assert (impl->transient_for != NULL);
|
||||
parent_impl = GDK_WINDOW_IMPL_WAYLAND (impl->transient_for->impl);
|
||||
|
||||
if (parent_impl->surface && !parent_impl->pending_commit)
|
||||
wl_surface_commit (parent_impl->surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1449,13 +1437,8 @@ gdk_window_wayland_input_shape_combine_region (GdkWindow *window,
|
||||
return;
|
||||
|
||||
g_clear_pointer (&impl->input_region, cairo_region_destroy);
|
||||
|
||||
if (shape_region)
|
||||
{
|
||||
impl->input_region = cairo_region_copy (shape_region);
|
||||
cairo_region_translate (impl->input_region, offset_x, offset_y);
|
||||
}
|
||||
|
||||
impl->input_region = cairo_region_copy (shape_region);
|
||||
cairo_region_translate (impl->input_region, offset_x, offset_y);
|
||||
gdk_wayland_window_sync_input_region (window);
|
||||
}
|
||||
|
||||
|
||||
@@ -600,6 +600,19 @@ gdk_win32_display_notify_startup_complete (GdkDisplay *display,
|
||||
/* nothing */
|
||||
}
|
||||
static void
|
||||
gdk_win32_display_event_data_copy (GdkDisplay *display,
|
||||
const GdkEvent *src,
|
||||
GdkEvent *dst)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
static void
|
||||
gdk_win32_display_event_data_free (GdkDisplay *display,
|
||||
GdkEvent *event)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
static void
|
||||
gdk_win32_display_push_error_trap (GdkDisplay *display)
|
||||
{
|
||||
/* nothing */
|
||||
@@ -652,6 +665,8 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass)
|
||||
display_class->after_process_all_updates = gdk_win32_display_after_process_all_updates;
|
||||
display_class->get_next_serial = gdk_win32_display_get_next_serial;
|
||||
display_class->notify_startup_complete = gdk_win32_display_notify_startup_complete;
|
||||
display_class->event_data_copy = gdk_win32_display_event_data_copy;
|
||||
display_class->event_data_free = gdk_win32_display_event_data_free;
|
||||
display_class->create_window_impl = _gdk_win32_display_create_window_impl;
|
||||
|
||||
display_class->get_keymap = _gdk_win32_display_get_keymap;
|
||||
|
||||
@@ -524,7 +524,9 @@ get_surface_size (cairo_surface_t *surface,
|
||||
|
||||
x_scale = y_scale = 1;
|
||||
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_get_device_scale (surface, &x_scale, &y_scale);
|
||||
#endif
|
||||
|
||||
/* Assume any set scaling is icon scale */
|
||||
*width =
|
||||
@@ -560,7 +562,9 @@ create_cursor_image (cairo_surface_t *source_surface,
|
||||
height,
|
||||
width * 4);
|
||||
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_set_device_scale (surface, scale, scale);
|
||||
#endif
|
||||
|
||||
cr = cairo_create (surface);
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
|
||||
|
||||
+32
-33
@@ -38,7 +38,6 @@
|
||||
#include "gdkprivate-x11.h"
|
||||
#include "gdkscreen-x11.h"
|
||||
#include "gdkglcontext-x11.h"
|
||||
#include "gdk-private.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gprintf.h>
|
||||
@@ -49,7 +48,6 @@
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xlibint.h>
|
||||
#include <X11/Xlib-xcb.h>
|
||||
|
||||
#ifdef HAVE_XKB
|
||||
#include <X11/XKBlib.h>
|
||||
@@ -73,10 +71,6 @@
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PRESENT
|
||||
#include <xcb/present.h>
|
||||
#endif
|
||||
|
||||
typedef struct _GdkErrorTrap GdkErrorTrap;
|
||||
|
||||
struct _GdkErrorTrap
|
||||
@@ -171,8 +165,7 @@ static const char *const precache_atoms[] = {
|
||||
"_NET_WM_USER_TIME_WINDOW",
|
||||
"_NET_VIRTUAL_ROOTS",
|
||||
"GDK_SELECTION",
|
||||
"_NET_WM_STATE_FOCUSED",
|
||||
"GDK_VISUALS"
|
||||
"_NET_WM_STATE_FOCUSED"
|
||||
};
|
||||
|
||||
static char *gdk_sm_client_id;
|
||||
@@ -710,7 +703,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
}
|
||||
|
||||
if (toplevel)
|
||||
gdk_window_freeze_toplevel_updates (window);
|
||||
gdk_window_freeze_toplevel_updates_libgtk_only (window);
|
||||
|
||||
_gdk_x11_window_grab_check_unmap (window, xevent->xany.serial);
|
||||
}
|
||||
@@ -734,7 +727,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
0);
|
||||
|
||||
if (toplevel)
|
||||
gdk_window_thaw_toplevel_updates (window);
|
||||
gdk_window_thaw_toplevel_updates_libgtk_only (window);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -772,13 +765,11 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
: ""));
|
||||
if (window && GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT)
|
||||
{
|
||||
window_impl->unscaled_width = xevent->xconfigure.width;
|
||||
window_impl->unscaled_height = xevent->xconfigure.height;
|
||||
window->width = (xevent->xconfigure.width + window_impl->window_scale - 1) / window_impl->window_scale;
|
||||
window->height = (xevent->xconfigure.height + window_impl->window_scale - 1) / window_impl->window_scale;
|
||||
window->width = xevent->xconfigure.width / window_impl->window_scale;
|
||||
window->height = xevent->xconfigure.height / window_impl->window_scale;
|
||||
|
||||
_gdk_window_update_size (window);
|
||||
_gdk_x11_window_update_size (window_impl);
|
||||
_gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
|
||||
_gdk_x11_screen_size_changed (screen, xevent);
|
||||
}
|
||||
|
||||
@@ -800,8 +791,8 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
{
|
||||
event->configure.type = GDK_CONFIGURE;
|
||||
event->configure.window = window;
|
||||
event->configure.width = (xevent->xconfigure.width + window_impl->window_scale - 1) / window_impl->window_scale;
|
||||
event->configure.height = (xevent->xconfigure.height + window_impl->window_scale - 1) / window_impl->window_scale;
|
||||
event->configure.width = xevent->xconfigure.width / window_impl->window_scale;
|
||||
event->configure.height = xevent->xconfigure.height / window_impl->window_scale;
|
||||
|
||||
if (!xevent->xconfigure.send_event &&
|
||||
!xevent->xconfigure.override_redirect &&
|
||||
@@ -833,13 +824,11 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
{
|
||||
window->x = event->configure.x;
|
||||
window->y = event->configure.y;
|
||||
window_impl->unscaled_width = xevent->xconfigure.width;
|
||||
window_impl->unscaled_height = xevent->xconfigure.height;
|
||||
window->width = event->configure.width;
|
||||
window->height = event->configure.height;
|
||||
window->width = xevent->xconfigure.width / window_impl->window_scale;
|
||||
window->height = xevent->xconfigure.height / window_impl->window_scale;
|
||||
|
||||
_gdk_window_update_size (window);
|
||||
_gdk_x11_window_update_size (window_impl);
|
||||
_gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
|
||||
|
||||
if (window->resize_count >= 1)
|
||||
{
|
||||
@@ -1371,7 +1360,6 @@ _gdk_x11_display_open (const gchar *display_name)
|
||||
GdkWindowAttr attr;
|
||||
gint argc;
|
||||
gchar *argv[1];
|
||||
xcb_connection_t *xcb_conn;
|
||||
|
||||
XClassHint *class_hint;
|
||||
gulong pid;
|
||||
@@ -1392,8 +1380,6 @@ _gdk_x11_display_open (const gchar *display_name)
|
||||
|
||||
_gdk_x11_precache_atoms (display, precache_atoms, G_N_ELEMENTS (precache_atoms));
|
||||
|
||||
xcb_conn = XGetXCBConnection (display_x11->xdisplay);
|
||||
|
||||
/* RandR must be initialized before we initialize the screens */
|
||||
display_x11->have_randr12 = FALSE;
|
||||
display_x11->have_randr13 = FALSE;
|
||||
@@ -1458,14 +1444,6 @@ _gdk_x11_display_open (const gchar *display_name)
|
||||
#endif
|
||||
display_x11->have_xfixes = FALSE;
|
||||
|
||||
#ifdef HAVE_PRESENT
|
||||
if (xcb_get_extension_data (xcb_conn, &xcb_present_id))
|
||||
{
|
||||
(void) xcb_present_query_version (xcb_conn, XCB_PRESENT_MAJOR_VERSION, XCB_PRESENT_MINOR_VERSION);
|
||||
display_x11->have_present = TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XCOMPOSITE
|
||||
if (XCompositeQueryExtension (display_x11->xdisplay,
|
||||
&ignore, &ignore))
|
||||
@@ -2727,6 +2705,11 @@ gdk_x11_display_set_window_scale (GdkDisplay *display,
|
||||
|
||||
scale = MAX (scale, 1);
|
||||
|
||||
#ifndef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
/* Without cairo support we can't support any scale but 1 */
|
||||
scale = 1;
|
||||
#endif
|
||||
|
||||
x11_screen = GDK_X11_SCREEN (GDK_X11_DISPLAY (display)->screen);
|
||||
|
||||
if (!x11_screen->fixed_window_scale)
|
||||
@@ -2827,6 +2810,19 @@ gdk_x11_set_sm_client_id (const gchar *sm_client_id)
|
||||
g_slist_free (displays);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_display_event_data_copy (GdkDisplay *display,
|
||||
const GdkEvent *src,
|
||||
GdkEvent *dst)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_display_event_data_free (GdkDisplay *display,
|
||||
GdkEvent *event)
|
||||
{
|
||||
}
|
||||
|
||||
static gint
|
||||
pop_error_trap (GdkDisplay *display,
|
||||
gboolean ignored)
|
||||
@@ -2898,6 +2894,8 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
|
||||
display_class->after_process_all_updates = _gdk_x11_display_after_process_all_updates;
|
||||
display_class->get_next_serial = gdk_x11_display_get_next_serial;
|
||||
display_class->notify_startup_complete = gdk_x11_display_notify_startup_complete;
|
||||
display_class->event_data_copy = gdk_x11_display_event_data_copy;
|
||||
display_class->event_data_free = gdk_x11_display_event_data_free;
|
||||
display_class->create_window_impl = _gdk_x11_display_create_window_impl;
|
||||
display_class->get_keymap = gdk_x11_display_get_keymap;
|
||||
display_class->push_error_trap = gdk_x11_display_error_trap_push;
|
||||
@@ -2910,6 +2908,7 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
|
||||
display_class->text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list;
|
||||
display_class->utf8_to_string_target = _gdk_x11_display_utf8_to_string_target;
|
||||
|
||||
display_class->destroy_gl_context = gdk_x11_display_destroy_gl_context;
|
||||
display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current;
|
||||
|
||||
_gdk_x11_windowing_init ();
|
||||
|
||||
@@ -68,8 +68,6 @@ struct _GdkX11Display
|
||||
gboolean have_randr13;
|
||||
gint xrandr_event_base;
|
||||
|
||||
gboolean have_present;
|
||||
|
||||
/* If the SECURITY extension is in place, whether this client holds
|
||||
* a trusted authorization and so is allowed to make various requests
|
||||
* (grabs, properties etc.) Otherwise always TRUE.
|
||||
@@ -141,8 +139,6 @@ struct _GdkX11Display
|
||||
guint has_glx_video_sync : 1;
|
||||
guint has_glx_buffer_age : 1;
|
||||
guint has_glx_sync_control : 1;
|
||||
guint has_glx_multisample : 1;
|
||||
guint has_glx_visual_rating : 1;
|
||||
};
|
||||
|
||||
struct _GdkX11DisplayClass
|
||||
|
||||
@@ -62,8 +62,6 @@ _gdk_x11_window_move_resize_child (GdkWindow *window,
|
||||
|
||||
window->x = x;
|
||||
window->y = y;
|
||||
impl->unscaled_width = width * impl->window_scale;
|
||||
impl->unscaled_height = height * impl->window_scale;
|
||||
window->width = width;
|
||||
window->height = height;
|
||||
|
||||
|
||||
+140
-429
@@ -29,9 +29,6 @@
|
||||
#include "gdkx11screen.h"
|
||||
#include "gdkx11window.h"
|
||||
#include "gdkx11visual.h"
|
||||
#include "gdkvisualprivate.h"
|
||||
#include "gdkx11property.h"
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#include "gdkinternals.h"
|
||||
|
||||
@@ -93,6 +90,25 @@ set_glx_drawable_info (GdkWindow *window,
|
||||
drawable_info_free);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_gl_context_update (GdkGLContext *context)
|
||||
{
|
||||
GdkWindow *window = gdk_gl_context_get_window (context);
|
||||
int width, height;
|
||||
|
||||
gdk_gl_context_make_current (context);
|
||||
|
||||
width = gdk_window_get_width (window);
|
||||
height = gdk_window_get_height (window);
|
||||
|
||||
GDK_NOTE (OPENGL, g_print ("Updating GL viewport size to { %d, %d } for window %lu (context: %p)\n",
|
||||
width, height,
|
||||
(unsigned long) gdk_x11_window_get_xid (window),
|
||||
context));
|
||||
|
||||
glViewport (0, 0, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
maybe_wait_for_vblank (GdkDisplay *display,
|
||||
GLXDrawable drawable)
|
||||
@@ -138,8 +154,6 @@ gdk_x11_window_invalidate_for_new_frame (GdkWindow *window,
|
||||
|
||||
buffer_age = 0;
|
||||
|
||||
context_x11->do_blit_swap = FALSE;
|
||||
|
||||
if (display_x11->has_glx_buffer_age)
|
||||
{
|
||||
gdk_gl_context_make_current (window->gl_paint_context);
|
||||
@@ -147,20 +161,9 @@ gdk_x11_window_invalidate_for_new_frame (GdkWindow *window,
|
||||
GLX_BACK_BUFFER_AGE_EXT, &buffer_age);
|
||||
}
|
||||
|
||||
|
||||
invalidate_all = FALSE;
|
||||
if (buffer_age == 0 || buffer_age >= 4)
|
||||
{
|
||||
cairo_rectangle_int_t whole_window = { 0, 0, gdk_window_get_width (window), gdk_window_get_height (window) };
|
||||
|
||||
if (gdk_gl_context_has_framebuffer_blit (window->gl_paint_context) &&
|
||||
cairo_region_contains_rectangle (update_area, &whole_window) != CAIRO_REGION_OVERLAP_IN)
|
||||
{
|
||||
context_x11->do_blit_swap = TRUE;
|
||||
}
|
||||
else
|
||||
invalidate_all = TRUE;
|
||||
}
|
||||
invalidate_all = TRUE;
|
||||
else
|
||||
{
|
||||
if (buffer_age >= 2)
|
||||
@@ -193,25 +196,6 @@ gdk_x11_window_invalidate_for_new_frame (GdkWindow *window,
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gl_blit_region (GdkWindow *window, cairo_region_t *region)
|
||||
{
|
||||
int n_rects, i;
|
||||
int scale = gdk_window_get_scale_factor (window);
|
||||
int wh = gdk_window_get_height (window);
|
||||
cairo_rectangle_int_t rect;
|
||||
|
||||
n_rects = cairo_region_num_rectangles (region);
|
||||
for (i = 0; i < n_rects; i++)
|
||||
{
|
||||
cairo_region_get_rectangle (region, i, &rect);
|
||||
glScissor (rect.x * scale, (wh - rect.y - rect.height) * scale, rect.width * scale, rect.height * scale);
|
||||
glBlitFramebuffer (rect.x * scale, (wh - rect.y - rect.height) * scale, (rect.x + rect.width) * scale, (wh - rect.y) * scale,
|
||||
rect.x * scale, (wh - rect.y - rect.height) * scale, (rect.x + rect.width) * scale, (wh - rect.y) * scale,
|
||||
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_gl_context_end_frame (GdkGLContext *context,
|
||||
cairo_region_t *painted,
|
||||
@@ -219,7 +203,7 @@ gdk_x11_gl_context_end_frame (GdkGLContext *context,
|
||||
{
|
||||
GdkX11GLContext *context_x11 = GDK_X11_GL_CONTEXT (context);
|
||||
GdkWindow *window = gdk_gl_context_get_window (context);
|
||||
GdkDisplay *display = gdk_gl_context_get_display (context);
|
||||
GdkDisplay *display = gdk_window_get_display (window);
|
||||
Display *dpy = gdk_x11_display_get_xdisplay (display);
|
||||
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
|
||||
DrawableInfo *info;
|
||||
@@ -270,19 +254,7 @@ gdk_x11_gl_context_end_frame (GdkGLContext *context,
|
||||
}
|
||||
}
|
||||
|
||||
if (context_x11->do_blit_swap)
|
||||
{
|
||||
glDrawBuffer(GL_FRONT);
|
||||
glReadBuffer(GL_BACK);
|
||||
gdk_gl_blit_region (window, painted);
|
||||
glDrawBuffer(GL_BACK);
|
||||
glFlush();
|
||||
|
||||
if (gdk_gl_context_has_frame_terminator (context))
|
||||
glFrameTerminatorGREMEDY ();
|
||||
}
|
||||
else
|
||||
glXSwapBuffers (dpy, drawable);
|
||||
glXSwapBuffers (dpy, drawable);
|
||||
|
||||
if (context_x11->do_frame_sync && info != NULL && display_x11->has_glx_video_sync)
|
||||
glXGetVideoSyncSGI (&info->last_frame_counter);
|
||||
@@ -305,7 +277,7 @@ glx_pixmap_destroy (void *data)
|
||||
}
|
||||
|
||||
static GdkGLXPixmap *
|
||||
glx_pixmap_get (cairo_surface_t *surface, guint texture_target)
|
||||
glx_pixmap_get (cairo_surface_t *surface)
|
||||
{
|
||||
Display *display = cairo_xlib_surface_get_display (surface);
|
||||
Screen *screen = cairo_xlib_surface_get_screen (surface);
|
||||
@@ -314,7 +286,6 @@ glx_pixmap_get (cairo_surface_t *surface, guint texture_target)
|
||||
GLXFBConfig *fbconfigs;
|
||||
int nfbconfigs;
|
||||
XVisualInfo *visinfo;
|
||||
VisualID visualid;
|
||||
int i, value;
|
||||
gboolean y_inverted;
|
||||
gboolean with_alpha;
|
||||
@@ -333,13 +304,7 @@ glx_pixmap_get (cairo_surface_t *surface, guint texture_target)
|
||||
for (i = 0; i < nfbconfigs; i++)
|
||||
{
|
||||
visinfo = glXGetVisualFromFBConfig (display, fbconfigs[i]);
|
||||
if (!visinfo)
|
||||
continue;
|
||||
|
||||
visualid = visinfo->visualid;
|
||||
XFree (visinfo);
|
||||
|
||||
if (visualid != XVisualIDFromVisual (visual))
|
||||
if (!visinfo || visinfo->visualid != XVisualIDFromVisual (visual))
|
||||
continue;
|
||||
|
||||
glXGetFBConfigAttrib (display, fbconfigs[i], GLX_DRAWABLE_TYPE, &value);
|
||||
@@ -349,22 +314,12 @@ glx_pixmap_get (cairo_surface_t *surface, guint texture_target)
|
||||
glXGetFBConfigAttrib (display, fbconfigs[i],
|
||||
GLX_BIND_TO_TEXTURE_TARGETS_EXT,
|
||||
&value);
|
||||
if (texture_target == GL_TEXTURE_2D)
|
||||
{
|
||||
if (value & GLX_TEXTURE_2D_BIT_EXT)
|
||||
target = GLX_TEXTURE_2D_EXT;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else if (texture_target == GL_TEXTURE_RECTANGLE_ARB)
|
||||
{
|
||||
if (value & GLX_TEXTURE_RECTANGLE_BIT_EXT)
|
||||
target = GLX_TEXTURE_RECTANGLE_EXT;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else
|
||||
if ((value & (GLX_TEXTURE_RECTANGLE_BIT_EXT | GLX_TEXTURE_2D_BIT_EXT)) == 0)
|
||||
continue;
|
||||
if ((value & GLX_TEXTURE_2D_BIT_EXT))
|
||||
target = GLX_TEXTURE_2D_EXT;
|
||||
else
|
||||
target = GLX_TEXTURE_RECTANGLE_EXT;
|
||||
|
||||
if (!with_alpha)
|
||||
{
|
||||
@@ -383,7 +338,6 @@ glx_pixmap_get (cairo_surface_t *surface, guint texture_target)
|
||||
&value);
|
||||
if (!value)
|
||||
continue;
|
||||
|
||||
format = GLX_TEXTURE_FORMAT_RGBA_EXT;
|
||||
}
|
||||
|
||||
@@ -396,8 +350,6 @@ glx_pixmap_get (cairo_surface_t *surface, guint texture_target)
|
||||
break;
|
||||
}
|
||||
|
||||
XFree (fbconfigs);
|
||||
|
||||
if (i == nfbconfigs)
|
||||
return NULL;
|
||||
|
||||
@@ -415,10 +367,11 @@ glx_pixmap_get (cairo_surface_t *surface, guint texture_target)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_x11_gl_context_texture_from_surface (GdkGLContext *paint_context,
|
||||
gdk_x11_gl_context_texture_from_surface (GdkGLContext *context,
|
||||
cairo_surface_t *surface,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkGLContext *current;
|
||||
GdkGLXPixmap *glx_pixmap;
|
||||
double device_x_offset, device_y_offset;
|
||||
cairo_rectangle_int_t rect;
|
||||
@@ -435,22 +388,22 @@ gdk_x11_gl_context_texture_from_surface (GdkGLContext *paint_context,
|
||||
if (cairo_surface_get_type (surface) != CAIRO_SURFACE_TYPE_XLIB)
|
||||
return FALSE;
|
||||
|
||||
use_texture_rectangle = gdk_gl_context_use_texture_rectangle (paint_context);
|
||||
if (use_texture_rectangle)
|
||||
target = GL_TEXTURE_RECTANGLE_ARB;
|
||||
else
|
||||
target = GL_TEXTURE_2D;
|
||||
|
||||
glx_pixmap = glx_pixmap_get (surface, target);
|
||||
glx_pixmap = glx_pixmap_get (surface);
|
||||
if (glx_pixmap == NULL)
|
||||
return FALSE;
|
||||
|
||||
window = gdk_gl_context_get_window (paint_context)->impl_window;
|
||||
current = gdk_gl_context_get_current ();
|
||||
|
||||
use_texture_rectangle = gdk_gl_context_use_texture_rectangle (current);
|
||||
|
||||
window = gdk_gl_context_get_window (current)->impl_window;
|
||||
window_scale = gdk_window_get_scale_factor (window);
|
||||
window_height = gdk_window_get_height (window);
|
||||
|
||||
sx = sy = 1;
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_get_device_scale (window->current_paint.surface, &sx, &sy);
|
||||
#endif
|
||||
|
||||
cairo_surface_get_device_offset (surface,
|
||||
&device_x_offset, &device_y_offset);
|
||||
@@ -458,14 +411,19 @@ gdk_x11_gl_context_texture_from_surface (GdkGLContext *paint_context,
|
||||
/* Ensure all the X stuff are synced before we read it back via texture-from-pixmap */
|
||||
glXWaitX();
|
||||
|
||||
if (use_texture_rectangle)
|
||||
target = GL_TEXTURE_RECTANGLE_ARB;
|
||||
else
|
||||
target = GL_TEXTURE_2D;
|
||||
|
||||
glGenTextures (1, &texture_id);
|
||||
glBindTexture (target, texture_id);
|
||||
glEnable (target);
|
||||
|
||||
glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
glXBindTexImageEXT (glx_pixmap->display, glx_pixmap->drawable,
|
||||
GLX_FRONT_LEFT_EXT, NULL);
|
||||
@@ -498,11 +456,19 @@ gdk_x11_gl_context_texture_from_surface (GdkGLContext *paint_context,
|
||||
vscale = 1.0 / cairo_xlib_surface_get_height (surface);
|
||||
}
|
||||
|
||||
gdk_gl_texture_quad (paint_context, target,
|
||||
rect.x * window_scale, FLIP_Y(rect.y) * window_scale,
|
||||
(rect.x + rect.width) * window_scale, FLIP_Y(rect.y + rect.height) * window_scale,
|
||||
uscale * src_x, vscale * src_y,
|
||||
uscale * (src_x + src_width), vscale * (src_y + src_height));
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2f (uscale * src_x, vscale * (src_y + src_height));
|
||||
glVertex2f (rect.x * window_scale, FLIP_Y(rect.y + rect.height) * window_scale);
|
||||
|
||||
glTexCoord2f (uscale * (src_x + src_width), vscale * (src_y + src_height));
|
||||
glVertex2f ((rect.x + rect.width) * window_scale, FLIP_Y(rect.y + rect.height) * window_scale);
|
||||
|
||||
glTexCoord2f (uscale * (src_x + src_width), vscale * src_y);
|
||||
glVertex2f ((rect.x + rect.width) * window_scale, FLIP_Y(rect.y) * window_scale);
|
||||
|
||||
glTexCoord2f (uscale * src_x, vscale * src_y);
|
||||
glVertex2f (rect.x * window_scale, FLIP_Y(rect.y) * window_scale);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
glXReleaseTexImageEXT (glx_pixmap->display, glx_pixmap->drawable,
|
||||
@@ -516,51 +482,26 @@ gdk_x11_gl_context_texture_from_surface (GdkGLContext *paint_context,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_gl_context_dispose (GObject *gobject)
|
||||
{
|
||||
GdkX11GLContext *context_x11 = GDK_X11_GL_CONTEXT (gobject);
|
||||
|
||||
if (context_x11->glx_context != NULL)
|
||||
{
|
||||
GdkGLContext *context = GDK_GL_CONTEXT (gobject);
|
||||
GdkDisplay *display = gdk_gl_context_get_display (context);
|
||||
Display *dpy = gdk_x11_display_get_xdisplay (display);
|
||||
|
||||
if (glXGetCurrentContext () == context_x11->glx_context)
|
||||
glXMakeContextCurrent (dpy, None, None, NULL);
|
||||
|
||||
GDK_NOTE (OPENGL, g_print ("Destroying GLX context\n"));
|
||||
glXDestroyContext (dpy, context_x11->glx_context);
|
||||
context_x11->glx_context = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gdk_x11_gl_context_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_gl_context_class_init (GdkX11GLContextClass *klass)
|
||||
{
|
||||
GdkGLContextClass *context_class = GDK_GL_CONTEXT_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
context_class->update = gdk_x11_gl_context_update;
|
||||
context_class->end_frame = gdk_x11_gl_context_end_frame;
|
||||
context_class->texture_from_surface = gdk_x11_gl_context_texture_from_surface;
|
||||
|
||||
gobject_class->dispose = gdk_x11_gl_context_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_gl_context_init (GdkX11GLContext *self)
|
||||
{
|
||||
self->do_frame_sync = TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_x11_screen_init_gl (GdkScreen *screen)
|
||||
gdk_x11_display_init_gl (GdkDisplay *display)
|
||||
{
|
||||
GdkDisplay *display = gdk_screen_get_display (screen);
|
||||
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
|
||||
GdkScreen *screen;
|
||||
Display *dpy;
|
||||
int error_base, event_base;
|
||||
int screen_num;
|
||||
@@ -573,6 +514,7 @@ gdk_x11_screen_init_gl (GdkScreen *screen)
|
||||
if (!glXQueryExtension (dpy, &error_base, &event_base))
|
||||
return FALSE;
|
||||
|
||||
screen = gdk_display_get_default_screen (display);
|
||||
screen_num = GDK_X11_SCREEN (screen)->screen_num;
|
||||
|
||||
display_x11->have_glx = TRUE;
|
||||
@@ -593,10 +535,6 @@ gdk_x11_screen_init_gl (GdkScreen *screen)
|
||||
epoxy_has_glx_extension (dpy, screen_num, "GLX_EXT_buffer_age");
|
||||
display_x11->has_glx_sync_control =
|
||||
epoxy_has_glx_extension (dpy, screen_num, "GLX_OML_sync_control");
|
||||
display_x11->has_glx_multisample =
|
||||
epoxy_has_glx_extension (dpy, screen_num, "GLX_ARB_multisample");
|
||||
display_x11->has_glx_visual_rating =
|
||||
epoxy_has_glx_extension (dpy, screen_num, "GLX_EXT_visual_rating");
|
||||
|
||||
GDK_NOTE (OPENGL,
|
||||
g_print ("GLX version %d.%d found\n"
|
||||
@@ -636,7 +574,6 @@ find_fbconfig_for_visual (GdkDisplay *display,
|
||||
int n_configs, i;
|
||||
gboolean use_rgba;
|
||||
gboolean retval = FALSE;
|
||||
VisualID xvisual_id = XVisualIDFromVisual(gdk_x11_visual_get_xvisual (visual));
|
||||
|
||||
i = 0;
|
||||
attrs[i++] = GLX_DRAWABLE_TYPE;
|
||||
@@ -649,13 +586,14 @@ find_fbconfig_for_visual (GdkDisplay *display,
|
||||
attrs[i++] = GL_TRUE;
|
||||
|
||||
attrs[i++] = GLX_RED_SIZE;
|
||||
attrs[i++] = 1;
|
||||
attrs[i++] = gdk_visual_get_bits_per_rgb (visual);
|
||||
attrs[i++] = GLX_GREEN_SIZE;
|
||||
attrs[i++] = 1;
|
||||
attrs[i++] = gdk_visual_get_bits_per_rgb (visual);;
|
||||
attrs[i++] = GLX_BLUE_SIZE;
|
||||
attrs[i++] = 1;
|
||||
attrs[i++] = gdk_visual_get_bits_per_rgb (visual);;
|
||||
|
||||
use_rgba = (visual == gdk_screen_get_rgba_visual (gdk_display_get_default_screen (display)));
|
||||
|
||||
if (use_rgba)
|
||||
{
|
||||
attrs[i++] = GLX_ALPHA_SIZE;
|
||||
@@ -680,27 +618,44 @@ find_fbconfig_for_visual (GdkDisplay *display,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* if we don't care about an alpha channel, then the first
|
||||
* valid configuration is the one we give back
|
||||
*/
|
||||
if (!use_rgba)
|
||||
{
|
||||
if (fb_config_out != NULL)
|
||||
*fb_config_out = configs[0];
|
||||
|
||||
if (visinfo_out != NULL)
|
||||
*visinfo_out = glXGetVisualFromFBConfig (dpy, configs[0]);
|
||||
|
||||
retval = TRUE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (i = 0; i < n_configs; i++)
|
||||
{
|
||||
XVisualInfo *visinfo;
|
||||
unsigned long mask;
|
||||
|
||||
visinfo = glXGetVisualFromFBConfig (dpy, configs[i]);
|
||||
if (visinfo == NULL)
|
||||
continue;
|
||||
|
||||
if (visinfo->visualid != xvisual_id)
|
||||
continue;
|
||||
mask = visinfo->red_mask | visinfo->green_mask | visinfo->blue_mask;
|
||||
if (visinfo->depth == 32 && mask != 0xffffffff)
|
||||
{
|
||||
if (fb_config_out != NULL)
|
||||
*fb_config_out = configs[i];
|
||||
|
||||
if (fb_config_out != NULL)
|
||||
*fb_config_out = configs[i];
|
||||
if (visinfo_out != NULL)
|
||||
*visinfo_out = visinfo;
|
||||
|
||||
if (visinfo_out != NULL)
|
||||
*visinfo_out = visinfo;
|
||||
else
|
||||
XFree (visinfo);
|
||||
retval = TRUE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
retval = TRUE;
|
||||
goto out;
|
||||
XFree (visinfo);
|
||||
}
|
||||
|
||||
g_set_error (error, GDK_GL_ERROR,
|
||||
@@ -754,259 +709,6 @@ create_gl_context (GdkDisplay *display,
|
||||
True);
|
||||
}
|
||||
|
||||
struct glvisualinfo {
|
||||
int supports_gl;
|
||||
int double_buffer;
|
||||
int stereo;
|
||||
int alpha_size;
|
||||
int depth_size;
|
||||
int stencil_size;
|
||||
int num_multisample;
|
||||
int visual_caveat;
|
||||
};
|
||||
|
||||
static gboolean
|
||||
visual_compatible (const GdkVisual *a, const GdkVisual *b)
|
||||
{
|
||||
return a->type == b->type &&
|
||||
a->depth == b->depth &&
|
||||
a->red_mask == b->red_mask &&
|
||||
a->green_mask == b->green_mask &&
|
||||
a->blue_mask == b->blue_mask &&
|
||||
a->colormap_size == b->colormap_size &&
|
||||
a->bits_per_rgb == b->bits_per_rgb;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
visual_is_rgba (const GdkVisual *visual)
|
||||
{
|
||||
return
|
||||
visual->depth == 32 &&
|
||||
visual->red_mask == 0xff0000 &&
|
||||
visual->green_mask == 0x00ff00 &&
|
||||
visual->blue_mask == 0x0000ff;
|
||||
}
|
||||
|
||||
/* This picks a compatible (as in has the same X visual details) visual
|
||||
that has "better" characteristics on the GL side */
|
||||
static GdkVisual *
|
||||
pick_better_visual_for_gl (GdkX11Screen *x11_screen,
|
||||
struct glvisualinfo *gl_info,
|
||||
GdkVisual *compatible)
|
||||
{
|
||||
GdkVisual *visual;
|
||||
int i;
|
||||
gboolean want_alpha = visual_is_rgba (compatible);
|
||||
|
||||
/* First look for "perfect match", i.e:
|
||||
* supports gl
|
||||
* double buffer
|
||||
* alpha iff visual is an rgba visual
|
||||
* no unnecessary stuff
|
||||
*/
|
||||
for (i = 0; i < x11_screen->nvisuals; i++)
|
||||
{
|
||||
visual = x11_screen->visuals[i];
|
||||
if (visual_compatible (visual, compatible) &&
|
||||
gl_info[i].supports_gl &&
|
||||
gl_info[i].double_buffer &&
|
||||
!gl_info[i].stereo &&
|
||||
(want_alpha ? (gl_info[i].alpha_size > 0) : (gl_info[i].alpha_size == 0)) &&
|
||||
(gl_info[i].depth_size == 0) &&
|
||||
(gl_info[i].stencil_size == 0) &&
|
||||
(gl_info[i].num_multisample == 0) &&
|
||||
(gl_info[i].visual_caveat == GLX_NONE_EXT))
|
||||
return visual;
|
||||
}
|
||||
|
||||
if (!want_alpha)
|
||||
{
|
||||
/* Next, allow alpha even if we don't want it: */
|
||||
for (i = 0; i < x11_screen->nvisuals; i++)
|
||||
{
|
||||
visual = x11_screen->visuals[i];
|
||||
if (visual_compatible (visual, compatible) &&
|
||||
gl_info[i].supports_gl &&
|
||||
gl_info[i].double_buffer &&
|
||||
!gl_info[i].stereo &&
|
||||
(gl_info[i].depth_size == 0) &&
|
||||
(gl_info[i].stencil_size == 0) &&
|
||||
(gl_info[i].num_multisample == 0) &&
|
||||
(gl_info[i].visual_caveat == GLX_NONE_EXT))
|
||||
return visual;
|
||||
}
|
||||
}
|
||||
|
||||
/* Next, allow depth and stencil buffers: */
|
||||
for (i = 0; i < x11_screen->nvisuals; i++)
|
||||
{
|
||||
visual = x11_screen->visuals[i];
|
||||
if (visual_compatible (visual, compatible) &&
|
||||
gl_info[i].supports_gl &&
|
||||
gl_info[i].double_buffer &&
|
||||
!gl_info[i].stereo &&
|
||||
(gl_info[i].num_multisample == 0) &&
|
||||
(gl_info[i].visual_caveat == GLX_NONE_EXT))
|
||||
return visual;
|
||||
}
|
||||
|
||||
/* Next, allow multisample: */
|
||||
for (i = 0; i < x11_screen->nvisuals; i++)
|
||||
{
|
||||
visual = x11_screen->visuals[i];
|
||||
if (visual_compatible (visual, compatible) &&
|
||||
gl_info[i].supports_gl &&
|
||||
gl_info[i].double_buffer &&
|
||||
!gl_info[i].stereo &&
|
||||
(gl_info[i].visual_caveat == GLX_NONE_EXT))
|
||||
return visual;
|
||||
}
|
||||
|
||||
return compatible;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
get_cached_gl_visuals (GdkDisplay *display, int *system, int *rgba)
|
||||
{
|
||||
gboolean found;
|
||||
Atom type_return;
|
||||
gint format_return;
|
||||
gulong nitems_return;
|
||||
gulong bytes_after_return;
|
||||
guchar *data = NULL;
|
||||
Display *dpy;
|
||||
|
||||
dpy = gdk_x11_display_get_xdisplay (display);
|
||||
|
||||
found = FALSE;
|
||||
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
if (XGetWindowProperty (dpy, DefaultRootWindow (dpy),
|
||||
gdk_x11_get_xatom_by_name_for_display (display, "GDK_VISUALS"),
|
||||
0, 2, False, XA_INTEGER, &type_return,
|
||||
&format_return, &nitems_return,
|
||||
&bytes_after_return, &data) == Success)
|
||||
{
|
||||
if (type_return == XA_INTEGER &&
|
||||
format_return == 32 &&
|
||||
nitems_return == 2 &&
|
||||
data != NULL)
|
||||
{
|
||||
long *visuals = (long *) data;
|
||||
|
||||
*system = (int)visuals[0];
|
||||
*rgba = (int)visuals[1];
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
gdk_x11_display_error_trap_pop_ignored (display);
|
||||
|
||||
if (data)
|
||||
XFree (data);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
static void
|
||||
save_cached_gl_visuals (GdkDisplay *display, int system, int rgba)
|
||||
{
|
||||
long visualdata[2];
|
||||
Display *dpy;
|
||||
|
||||
dpy = gdk_x11_display_get_xdisplay (display);
|
||||
|
||||
visualdata[0] = system;
|
||||
visualdata[1] = rgba;
|
||||
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
XChangeProperty(dpy, DefaultRootWindow (dpy), gdk_x11_get_xatom_by_name_for_display (display, "GDK_VISUALS"),
|
||||
XA_INTEGER, 32, PropModeReplace, (unsigned char *)visualdata, 2);
|
||||
gdk_x11_display_error_trap_pop_ignored (display);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_gdk_x11_screen_update_visuals_for_gl (GdkScreen *screen)
|
||||
{
|
||||
GdkX11Screen *x11_screen;
|
||||
GdkDisplay *display;
|
||||
GdkX11Display *display_x11;
|
||||
Display *dpy;
|
||||
struct glvisualinfo *gl_info;
|
||||
int i;
|
||||
int system_visual_id, rgba_visual_id;
|
||||
|
||||
x11_screen = GDK_X11_SCREEN (screen);
|
||||
display = x11_screen->display;
|
||||
display_x11 = GDK_X11_DISPLAY (display);
|
||||
dpy = gdk_x11_display_get_xdisplay (display);
|
||||
|
||||
/* We save the default visuals as a property on the root window to avoid
|
||||
having to initialize GL each time, as it may not be used later. */
|
||||
if (get_cached_gl_visuals (display, &system_visual_id, &rgba_visual_id))
|
||||
{
|
||||
for (i = 0; i < x11_screen->nvisuals; i++)
|
||||
{
|
||||
GdkVisual *visual = x11_screen->visuals[i];
|
||||
int visual_id = gdk_x11_visual_get_xvisual (visual)->visualid;
|
||||
|
||||
if (visual_id == system_visual_id)
|
||||
x11_screen->system_visual = visual;
|
||||
if (visual_id == rgba_visual_id)
|
||||
x11_screen->rgba_visual = visual;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gdk_x11_screen_init_gl (screen))
|
||||
return;
|
||||
|
||||
gl_info = g_new0 (struct glvisualinfo, x11_screen->nvisuals);
|
||||
|
||||
for (i = 0; i < x11_screen->nvisuals; i++)
|
||||
{
|
||||
XVisualInfo *visual_list;
|
||||
XVisualInfo visual_template;
|
||||
int nxvisuals;
|
||||
|
||||
visual_template.screen = x11_screen->screen_num;
|
||||
visual_template.visualid = gdk_x11_visual_get_xvisual (x11_screen->visuals[i])->visualid;
|
||||
visual_list = XGetVisualInfo (x11_screen->xdisplay, VisualIDMask| VisualScreenMask, &visual_template, &nxvisuals);
|
||||
|
||||
if (visual_list == NULL)
|
||||
continue;
|
||||
|
||||
glXGetConfig (dpy, &visual_list[0], GLX_USE_GL, &gl_info[i].supports_gl);
|
||||
glXGetConfig (dpy, &visual_list[0], GLX_DOUBLEBUFFER, &gl_info[i].double_buffer);
|
||||
glXGetConfig (dpy, &visual_list[0], GLX_STEREO, &gl_info[i].stereo);
|
||||
glXGetConfig (dpy, &visual_list[0], GLX_ALPHA_SIZE, &gl_info[i].alpha_size);
|
||||
glXGetConfig (dpy, &visual_list[0], GLX_DEPTH_SIZE, &gl_info[i].depth_size);
|
||||
glXGetConfig (dpy, &visual_list[0], GLX_STENCIL_SIZE, &gl_info[i].stencil_size);
|
||||
|
||||
if (display_x11->has_glx_multisample)
|
||||
glXGetConfig(dpy, &visual_list[0], GLX_SAMPLE_BUFFERS_ARB, &gl_info[i].num_multisample);
|
||||
|
||||
if (display_x11->has_glx_visual_rating)
|
||||
glXGetConfig(dpy, &visual_list[0], GLX_VISUAL_CAVEAT_EXT, &gl_info[i].visual_caveat);
|
||||
else
|
||||
gl_info[i].visual_caveat = GLX_NONE_EXT;
|
||||
|
||||
XFree (visual_list);
|
||||
}
|
||||
|
||||
x11_screen->system_visual = pick_better_visual_for_gl (x11_screen, gl_info, x11_screen->system_visual);
|
||||
if (x11_screen->rgba_visual)
|
||||
x11_screen->rgba_visual = pick_better_visual_for_gl (x11_screen, gl_info, x11_screen->rgba_visual);
|
||||
|
||||
g_free (gl_info);
|
||||
|
||||
save_cached_gl_visuals (display,
|
||||
gdk_x11_visual_get_xvisual (x11_screen->system_visual)->visualid,
|
||||
x11_screen->rgba_visual ? gdk_x11_visual_get_xvisual (x11_screen->rgba_visual)->visualid : 0);
|
||||
}
|
||||
|
||||
|
||||
GdkGLContext *
|
||||
gdk_x11_window_create_gl_context (GdkWindow *window,
|
||||
gboolean attached,
|
||||
@@ -1017,6 +719,7 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
|
||||
GdkDisplay *display;
|
||||
GdkX11GLContext *context;
|
||||
GdkVisual *visual;
|
||||
GdkVisual *gdk_visual;
|
||||
GLXFBConfig config;
|
||||
GLXContext glx_context;
|
||||
GLXWindow drawable;
|
||||
@@ -1027,7 +730,7 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
|
||||
|
||||
display = gdk_window_get_display (window);
|
||||
|
||||
if (!gdk_x11_screen_init_gl (gdk_window_get_screen (window)))
|
||||
if (!gdk_x11_display_init_gl (display))
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
@@ -1063,7 +766,6 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
|
||||
/* GDK_GL_PROFILE_DEFAULT is currently
|
||||
* equivalent to the LEGACY profile
|
||||
*/
|
||||
profile = GDK_GL_PROFILE_LEGACY;
|
||||
glx_context = create_gl_context (display, config, share);
|
||||
}
|
||||
|
||||
@@ -1126,6 +828,9 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
|
||||
set_glx_drawable_info (window->impl_window, info);
|
||||
}
|
||||
|
||||
gdk_visual = gdk_x11_screen_lookup_visual (gdk_display_get_default_screen (display),
|
||||
xvisinfo->visualid);
|
||||
|
||||
XFree (xvisinfo);
|
||||
|
||||
if (attached)
|
||||
@@ -1139,10 +844,8 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
|
||||
is_direct ? "direct" : "indirect"));
|
||||
|
||||
context = g_object_new (GDK_TYPE_X11_GL_CONTEXT,
|
||||
"display", display,
|
||||
"window", window,
|
||||
"profile", profile,
|
||||
"shared-context", share,
|
||||
"visual", gdk_visual,
|
||||
NULL);
|
||||
|
||||
context->profile = profile;
|
||||
@@ -1155,7 +858,25 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
|
||||
return GDK_GL_CONTEXT (context);
|
||||
}
|
||||
|
||||
gboolean
|
||||
void
|
||||
gdk_x11_display_destroy_gl_context (GdkDisplay *display,
|
||||
GdkGLContext *context)
|
||||
{
|
||||
GdkX11GLContext *context_x11 = GDK_X11_GL_CONTEXT (context);
|
||||
Display *dpy = gdk_x11_display_get_xdisplay (display);
|
||||
|
||||
if (context_x11->glx_context != NULL)
|
||||
{
|
||||
if (glXGetCurrentContext () == context_x11->glx_context)
|
||||
glXMakeContextCurrent (dpy, None, None, NULL);
|
||||
|
||||
GDK_NOTE (OPENGL, g_print ("Destroying GLX context\n"));
|
||||
glXDestroyContext (dpy, context_x11->glx_context);
|
||||
context_x11->glx_context = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_x11_display_make_gl_context_current (GdkDisplay *display,
|
||||
GdkGLContext *context)
|
||||
{
|
||||
@@ -1168,46 +889,36 @@ gdk_x11_display_make_gl_context_current (GdkDisplay *display,
|
||||
if (context == NULL)
|
||||
{
|
||||
glXMakeContextCurrent (dpy, None, None, NULL);
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
context_x11 = GDK_X11_GL_CONTEXT (context);
|
||||
|
||||
window = gdk_gl_context_get_window (context);
|
||||
|
||||
// If the WM is compositing there is no particular need to delay
|
||||
// the swap when drawing on the offscreen, rendering to the screen
|
||||
// happens later anyway, and its up to the compositor to sync that
|
||||
// to the vblank.
|
||||
screen = gdk_window_get_screen (window);
|
||||
do_frame_sync = ! gdk_screen_is_composited (screen);
|
||||
|
||||
context_x11->do_frame_sync = do_frame_sync;
|
||||
|
||||
GDK_NOTE (OPENGL,
|
||||
g_print ("Making GLX context current to drawable %lu\n",
|
||||
(unsigned long) context_x11->drawable));
|
||||
|
||||
if (!glXMakeContextCurrent (dpy, context_x11->drawable, context_x11->drawable,
|
||||
context_x11->glx_context))
|
||||
{
|
||||
GDK_NOTE (OPENGL,
|
||||
g_print ("Making GLX context current failed\n"));
|
||||
return FALSE;
|
||||
}
|
||||
glXMakeContextCurrent (dpy, context_x11->drawable, context_x11->drawable,
|
||||
context_x11->glx_context);
|
||||
|
||||
if (context_x11->is_attached && GDK_X11_DISPLAY (display)->has_glx_swap_interval)
|
||||
{
|
||||
window = gdk_gl_context_get_window (context);
|
||||
|
||||
/* If the WM is compositing there is no particular need to delay
|
||||
* the swap when drawing on the offscreen, rendering to the screen
|
||||
* happens later anyway, and its up to the compositor to sync that
|
||||
* to the vblank. */
|
||||
screen = gdk_window_get_screen (window);
|
||||
do_frame_sync = ! gdk_screen_is_composited (screen);
|
||||
|
||||
if (do_frame_sync != context_x11->do_frame_sync)
|
||||
{
|
||||
context_x11->do_frame_sync = do_frame_sync;
|
||||
|
||||
if (do_frame_sync)
|
||||
glXSwapIntervalSGI (1);
|
||||
else
|
||||
glXSwapIntervalSGI (0);
|
||||
}
|
||||
if (context_x11->do_frame_sync)
|
||||
glXSwapIntervalSGI (1);
|
||||
else
|
||||
glXSwapIntervalSGI (0);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1232,7 +943,7 @@ gdk_x11_display_get_glx_version (GdkDisplay *display,
|
||||
if (!GDK_IS_X11_DISPLAY (display))
|
||||
return FALSE;
|
||||
|
||||
if (!gdk_x11_screen_init_gl (gdk_display_get_default_screen (display)))
|
||||
if (!gdk_x11_display_init_gl (display))
|
||||
return FALSE;
|
||||
|
||||
if (major != NULL)
|
||||
|
||||
@@ -49,7 +49,6 @@ struct _GdkX11GLContext
|
||||
guint is_direct : 1;
|
||||
guint do_frame_sync : 1;
|
||||
|
||||
guint do_blit_swap : 1;
|
||||
};
|
||||
|
||||
struct _GdkX11GLContextClass
|
||||
@@ -57,7 +56,7 @@ struct _GdkX11GLContextClass
|
||||
GdkGLContextClass parent_class;
|
||||
};
|
||||
|
||||
gboolean gdk_x11_screen_init_gl (GdkScreen *screen);
|
||||
gboolean gdk_x11_display_init_gl (GdkDisplay *display);
|
||||
GdkGLContext * gdk_x11_window_create_gl_context (GdkWindow *window,
|
||||
gboolean attached,
|
||||
GdkGLProfile profile,
|
||||
@@ -65,7 +64,9 @@ GdkGLContext * gdk_x11_window_create_gl_context (GdkWindow
|
||||
GError **error);
|
||||
void gdk_x11_window_invalidate_for_new_frame (GdkWindow *window,
|
||||
cairo_region_t *update_area);
|
||||
gboolean gdk_x11_display_make_gl_context_current (GdkDisplay *display,
|
||||
void gdk_x11_display_destroy_gl_context (GdkDisplay *display,
|
||||
GdkGLContext *context);
|
||||
void gdk_x11_display_make_gl_context_current (GdkDisplay *display,
|
||||
GdkGLContext *context);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -1128,7 +1128,11 @@ _gdk_x11_screen_new (GdkDisplay *display,
|
||||
/* we want this to be always non-null */
|
||||
x11_screen->window_manager_name = g_strdup ("unknown");
|
||||
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
scale_str = g_getenv ("GDK_SCALE");
|
||||
#else
|
||||
scale_str = "1";
|
||||
#endif
|
||||
if (scale_str)
|
||||
{
|
||||
x11_screen->fixed_window_scale = TRUE;
|
||||
|
||||
@@ -113,7 +113,6 @@ GdkScreen * _gdk_x11_screen_new (GdkDisplay *display,
|
||||
gint screen_number);
|
||||
|
||||
void _gdk_x11_screen_setup (GdkScreen *screen);
|
||||
void _gdk_x11_screen_update_visuals_for_gl (GdkScreen *screen);
|
||||
void _gdk_x11_screen_window_manager_changed (GdkScreen *screen);
|
||||
void _gdk_x11_screen_size_changed (GdkScreen *screen,
|
||||
XEvent *event);
|
||||
|
||||
@@ -276,8 +276,7 @@ _gdk_x11_screen_init_visuals (GdkScreen *screen)
|
||||
* Additional formats (like ABGR) could be added later if they
|
||||
* turn up.
|
||||
*/
|
||||
if (x11_screen->rgba_visual == NULL &&
|
||||
visuals[i]->depth == 32 &&
|
||||
if (visuals[i]->depth == 32 &&
|
||||
(visuals[i]->red_mask == 0xff0000 &&
|
||||
visuals[i]->green_mask == 0x00ff00 &&
|
||||
visuals[i]->blue_mask == 0x0000ff))
|
||||
@@ -341,11 +340,6 @@ _gdk_x11_screen_init_visuals (GdkScreen *screen)
|
||||
|
||||
x11_screen->visuals = visuals;
|
||||
x11_screen->nvisuals = nvisuals;
|
||||
|
||||
/* If GL is available we want to pick better default/rgba visuals,
|
||||
as we care about glx details such as alpha/depth/stencil depth,
|
||||
stereo and double buffering */
|
||||
_gdk_x11_screen_update_visuals_for_gl (screen);
|
||||
}
|
||||
|
||||
gint
|
||||
|
||||
+50
-142
@@ -38,7 +38,6 @@
|
||||
#include "gdkdisplay-x11.h"
|
||||
#include "gdkglcontext-x11.h"
|
||||
#include "gdkprivate-x11.h"
|
||||
#include "gdk-private.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -53,7 +52,6 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xlib-xcb.h>
|
||||
|
||||
#include <X11/extensions/shape.h>
|
||||
|
||||
@@ -73,10 +71,6 @@
|
||||
#include <X11/extensions/Xdamage.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PRESENT
|
||||
#include <xcb/present.h>
|
||||
#endif
|
||||
|
||||
const int _gdk_x11_event_mask_table[21] =
|
||||
{
|
||||
ExposureMask,
|
||||
@@ -186,6 +180,8 @@ _gdk_x11_window_get_toplevel (GdkWindow *window)
|
||||
return impl->toplevel;
|
||||
}
|
||||
|
||||
static const cairo_user_data_key_t gdk_x11_cairo_key;
|
||||
|
||||
/**
|
||||
* _gdk_x11_window_update_size:
|
||||
* @impl: a #GdkWindowImplX11.
|
||||
@@ -199,24 +195,11 @@ _gdk_x11_window_update_size (GdkWindowImplX11 *impl)
|
||||
if (impl->cairo_surface)
|
||||
{
|
||||
cairo_xlib_surface_set_size (impl->cairo_surface,
|
||||
impl->unscaled_width, impl->unscaled_height);
|
||||
gdk_window_get_width (impl->wrapper) * impl->window_scale,
|
||||
gdk_window_get_height (impl->wrapper) * impl->window_scale);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_x11_window_get_unscaled_size (GdkWindow *window,
|
||||
int *unscaled_width,
|
||||
int *unscaled_height)
|
||||
{
|
||||
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
|
||||
|
||||
if (unscaled_width)
|
||||
*unscaled_width = impl->unscaled_width;
|
||||
|
||||
if (unscaled_height)
|
||||
*unscaled_height = impl->unscaled_height;
|
||||
}
|
||||
|
||||
static void
|
||||
set_sync_counter(Display *display,
|
||||
XSyncCounter counter,
|
||||
@@ -224,10 +207,10 @@ set_sync_counter(Display *display,
|
||||
{
|
||||
XSyncValue sync_value;
|
||||
|
||||
XSyncIntsToValue (&sync_value,
|
||||
value & G_GINT64_CONSTANT(0xFFFFFFFF),
|
||||
value >> 32);
|
||||
XSyncSetCounter (display, counter, sync_value);
|
||||
XSyncIntsToValue(&sync_value,
|
||||
value & G_GINT64_CONSTANT(0xFFFFFFFF),
|
||||
value >> 32);
|
||||
XSyncSetCounter(display, counter, sync_value);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -245,9 +228,9 @@ window_pre_damage (GdkWindow *window)
|
||||
impl->toplevel->current_counter_value % 2 == 0)
|
||||
{
|
||||
impl->toplevel->current_counter_value += 1;
|
||||
set_sync_counter (GDK_WINDOW_XDISPLAY (impl->wrapper),
|
||||
impl->toplevel->extended_update_counter,
|
||||
impl->toplevel->current_counter_value);
|
||||
set_sync_counter(GDK_WINDOW_XDISPLAY (impl->wrapper),
|
||||
impl->toplevel->extended_update_counter,
|
||||
impl->toplevel->current_counter_value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,6 +441,14 @@ gdk_x11_window_end_frame (GdkWindow *window)
|
||||
* X11 specific implementations of generic functions *
|
||||
*****************************************************/
|
||||
|
||||
static void
|
||||
gdk_x11_cairo_surface_destroy (void *data)
|
||||
{
|
||||
GdkWindowImplX11 *impl = data;
|
||||
|
||||
impl->cairo_surface = NULL;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gdk_x11_create_cairo_surface (GdkWindowImplX11 *impl,
|
||||
int width,
|
||||
@@ -485,13 +476,19 @@ gdk_x11_ref_cairo_surface (GdkWindow *window)
|
||||
impl->cairo_surface = gdk_x11_create_cairo_surface (impl,
|
||||
gdk_window_get_width (window) * impl->window_scale,
|
||||
gdk_window_get_height (window) * impl->window_scale);
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_set_device_scale (impl->cairo_surface, impl->window_scale, impl->window_scale);
|
||||
#endif
|
||||
|
||||
if (impl->cairo_surface)
|
||||
cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key,
|
||||
impl, gdk_x11_cairo_surface_destroy);
|
||||
|
||||
if (WINDOW_IS_TOPLEVEL (window) && impl->toplevel->in_frame)
|
||||
hook_surface_changed (window);
|
||||
}
|
||||
|
||||
cairo_surface_reference (impl->cairo_surface);
|
||||
else
|
||||
cairo_surface_reference (impl->cairo_surface);
|
||||
|
||||
return impl->cairo_surface;
|
||||
}
|
||||
@@ -752,8 +749,6 @@ _gdk_x11_screen_init_root_window (GdkScreen *screen)
|
||||
window->y = 0;
|
||||
window->abs_x = 0;
|
||||
window->abs_y = 0;
|
||||
impl->unscaled_width = WidthOfScreen (x11_screen->xscreen);
|
||||
impl->unscaled_height = HeightOfScreen (x11_screen->xscreen);
|
||||
window->width = WidthOfScreen (x11_screen->xscreen) / impl->window_scale;
|
||||
window->height = HeightOfScreen (x11_screen->xscreen) / impl->window_scale;
|
||||
window->viewable = TRUE;
|
||||
@@ -1100,9 +1095,6 @@ _gdk_x11_display_create_window_impl (GdkDisplay *display,
|
||||
window->height = 32767 / impl->window_scale;
|
||||
}
|
||||
|
||||
impl->unscaled_width = window->width * impl->window_scale;
|
||||
impl->unscaled_height = window->height * impl->window_scale;
|
||||
|
||||
impl->xid = XCreateWindow (xdisplay, xparent,
|
||||
(window->x + window->parent->abs_x) * impl->window_scale,
|
||||
(window->y + window->parent->abs_y) * impl->window_scale,
|
||||
@@ -1151,7 +1143,7 @@ _gdk_x11_display_create_window_impl (GdkDisplay *display,
|
||||
connect_frame_clock (window);
|
||||
|
||||
if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD)
|
||||
gdk_window_freeze_toplevel_updates (window);
|
||||
gdk_window_freeze_toplevel_updates_libgtk_only (window);
|
||||
}
|
||||
|
||||
static GdkEventMask
|
||||
@@ -1252,8 +1244,6 @@ gdk_x11_window_foreign_new_for_display (GdkDisplay *display,
|
||||
|
||||
win->x = attrs.x / impl->window_scale;
|
||||
win->y = attrs.y / impl->window_scale;
|
||||
impl->unscaled_width = attrs.width;
|
||||
impl->unscaled_height = attrs.height;
|
||||
win->width = attrs.width / impl->window_scale;
|
||||
win->height = attrs.height / impl->window_scale;
|
||||
win->window_type = GDK_WINDOW_FOREIGN;
|
||||
@@ -1328,8 +1318,8 @@ gdk_x11_window_destroy (GdkWindow *window,
|
||||
if (impl->cairo_surface)
|
||||
{
|
||||
cairo_surface_finish (impl->cairo_surface);
|
||||
cairo_surface_destroy (impl->cairo_surface);
|
||||
impl->cairo_surface = NULL;
|
||||
cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
if (!recursing && !foreign_destroy)
|
||||
@@ -1814,15 +1804,13 @@ window_x11_resize (GdkWindow *window,
|
||||
|
||||
if (impl->override_redirect)
|
||||
{
|
||||
impl->unscaled_width = width * impl->window_scale;
|
||||
impl->unscaled_height = height * impl->window_scale;
|
||||
window->width = width;
|
||||
window->height = height;
|
||||
_gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (width * impl->window_scale != impl->unscaled_width || height * impl->window_scale != impl->unscaled_height)
|
||||
if (width != window->width || height != window->height)
|
||||
window->resize_count += 1;
|
||||
}
|
||||
}
|
||||
@@ -1862,8 +1850,6 @@ window_x11_move_resize (GdkWindow *window,
|
||||
window->x = x;
|
||||
window->y = y;
|
||||
|
||||
impl->unscaled_width = width * impl->window_scale;
|
||||
impl->unscaled_height = height * impl->window_scale;
|
||||
window->width = width;
|
||||
window->height = height;
|
||||
|
||||
@@ -1871,7 +1857,7 @@ window_x11_move_resize (GdkWindow *window,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (width * impl->window_scale != impl->unscaled_width || height * impl->window_scale != impl->unscaled_height)
|
||||
if (width != window->width || height != window->height)
|
||||
window->resize_count += 1;
|
||||
}
|
||||
}
|
||||
@@ -1927,11 +1913,6 @@ _gdk_x11_window_set_window_scale (GdkWindow *window,
|
||||
impl = GDK_WINDOW_IMPL_X11 (window->impl);
|
||||
|
||||
impl->window_scale = scale;
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
if (impl->cairo_surface)
|
||||
cairo_surface_set_device_scale (impl->cairo_surface, impl->window_scale, impl->window_scale);
|
||||
#endif
|
||||
_gdk_window_update_size (window);
|
||||
|
||||
toplevel = _gdk_x11_window_get_toplevel (window);
|
||||
if (toplevel && window->window_type != GDK_WINDOW_FOREIGN)
|
||||
@@ -1951,30 +1932,17 @@ _gdk_x11_window_set_window_scale (GdkWindow *window,
|
||||
(window->x + window->parent->abs_x) * impl->window_scale,
|
||||
(window->y + window->parent->abs_y) * impl->window_scale);
|
||||
else if (WINDOW_IS_TOPLEVEL(window))
|
||||
{
|
||||
if (impl->override_redirect)
|
||||
{
|
||||
impl->unscaled_width = window->width * impl->window_scale;
|
||||
impl->unscaled_height = window->height * impl->window_scale;
|
||||
}
|
||||
|
||||
XResizeWindow (GDK_WINDOW_XDISPLAY (window),
|
||||
GDK_WINDOW_XID (window),
|
||||
window->width * impl->window_scale,
|
||||
window->height * impl->window_scale);
|
||||
}
|
||||
XResizeWindow (GDK_WINDOW_XDISPLAY (window),
|
||||
GDK_WINDOW_XID (window),
|
||||
window->width * impl->window_scale,
|
||||
window->height * impl->window_scale);
|
||||
else
|
||||
{
|
||||
impl->unscaled_width = window->width * impl->window_scale;
|
||||
impl->unscaled_height = window->height * impl->window_scale;
|
||||
|
||||
XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window),
|
||||
GDK_WINDOW_XID (window),
|
||||
(window->x + window->parent->abs_x) * impl->window_scale,
|
||||
(window->y + window->parent->abs_y) * impl->window_scale,
|
||||
window->width * impl->window_scale,
|
||||
window->height * impl->window_scale);
|
||||
}
|
||||
XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window),
|
||||
GDK_WINDOW_XID (window),
|
||||
(window->x + window->parent->abs_x) * impl->window_scale,
|
||||
(window->y + window->parent->abs_y) * impl->window_scale,
|
||||
window->width * impl->window_scale,
|
||||
window->height * impl->window_scale);
|
||||
|
||||
gdk_window_invalidate_rect (window, NULL, TRUE);
|
||||
|
||||
@@ -3001,7 +2969,9 @@ gdk_window_x11_set_background (GdkWindow *window,
|
||||
|
||||
cairo_surface_get_device_offset (surface, &x, &y);
|
||||
sx = sy = 1.;
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_get_device_scale (surface, &sx, &sy);
|
||||
#endif
|
||||
/* XXX: This still bombs for non-pixmaps, but there's no way to
|
||||
* detect we're not a pixmap in Cairo... */
|
||||
if (x == 0.0 && y == 0.0 &&
|
||||
@@ -3281,14 +3251,10 @@ gdk_x11_window_get_frame_extents (GdkWindow *window,
|
||||
if (vroots)
|
||||
XFree (vroots);
|
||||
|
||||
/* Here we extend the size to include the extra pixels if we round x/y down
|
||||
as well as round the size up when we divide by scale so that the returned
|
||||
size is guaranteed to cover the real pixels, but it may overshoot a bit
|
||||
in case the window is not positioned/sized according to the scale */
|
||||
rect->width = (rect->width + rect->x % impl->window_scale + impl->window_scale - 1) / impl->window_scale;
|
||||
rect->height = (rect->height + rect->y % impl->window_scale + impl->window_scale - 1) / impl->window_scale;
|
||||
rect->x = rect->x / impl->window_scale;
|
||||
rect->y = rect->y / impl->window_scale;
|
||||
rect->x /= impl->window_scale;
|
||||
rect->y /= impl->window_scale;
|
||||
rect->width /= impl->window_scale;
|
||||
rect->height /= impl->window_scale;
|
||||
gdk_x11_display_error_trap_pop_ignored (display);
|
||||
}
|
||||
|
||||
@@ -3403,7 +3369,7 @@ do_shape_combine_region (GdkWindow *window,
|
||||
_gdk_x11_region_get_xrectangles (shape_region,
|
||||
0, 0, impl->window_scale,
|
||||
&xrects, &n_rects);
|
||||
|
||||
|
||||
if (shape == ShapeBounding)
|
||||
{
|
||||
_gdk_x11_window_tmp_unset_parent_bg (window);
|
||||
@@ -3658,14 +3624,8 @@ gdk_x11_window_set_shadow_width (GdkWindow *window,
|
||||
int top,
|
||||
int bottom)
|
||||
{
|
||||
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
|
||||
Atom frame_extents;
|
||||
gulong data[4] = {
|
||||
left * impl->window_scale,
|
||||
right * impl->window_scale,
|
||||
top * impl->window_scale,
|
||||
bottom * impl->window_scale
|
||||
};
|
||||
gulong data[4] = { left, right, top, bottom };
|
||||
|
||||
frame_extents = gdk_x11_get_xatom_by_name_for_display (gdk_window_get_display (window),
|
||||
"_GTK_FRAME_EXTENTS");
|
||||
@@ -5688,56 +5648,6 @@ gdk_x11_window_show_window_menu (GdkWindow *window,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_x11_window_do_composite (GdkWindow *window)
|
||||
{
|
||||
GdkDisplay *display = gdk_window_get_display (window);
|
||||
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
|
||||
|
||||
#ifdef HAVE_PRESENT
|
||||
if (display_x11->have_present)
|
||||
{
|
||||
Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
|
||||
xcb_connection_t *xcb_conn = XGetXCBConnection (xdisplay);
|
||||
XserverRegion update_region;
|
||||
XRectangle *rects;
|
||||
int n_rects;
|
||||
double sx, sy;
|
||||
double offs_x, offs_y;
|
||||
|
||||
cairo_surface_get_device_scale (window->current_paint.surface, &sx, &sy);
|
||||
cairo_surface_get_device_offset (window->current_paint.surface, &offs_x, &offs_y);
|
||||
|
||||
_gdk_x11_region_get_xrectangles (window->current_paint.region,
|
||||
offs_x / sx, offs_y / sy, sx, &rects, &n_rects);
|
||||
update_region = XFixesCreateRegion (xdisplay, rects, n_rects);
|
||||
|
||||
xcb_present_pixmap (xcb_conn,
|
||||
GDK_WINDOW_XID (window),
|
||||
cairo_xlib_surface_get_drawable (window->current_paint.surface),
|
||||
XNextRequest (xdisplay),
|
||||
update_region,
|
||||
update_region,
|
||||
-offs_x,
|
||||
-offs_y,
|
||||
None, /* target_crtc */
|
||||
None, /* wait_fence */
|
||||
None, /* idle_fence */
|
||||
0, /* options */
|
||||
0, /* target_msc */
|
||||
0, /* divisor */
|
||||
0, /* remainder */
|
||||
0, NULL /* notifies */ );
|
||||
|
||||
XFixesDestroyRegion (xdisplay, update_region);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
|
||||
{
|
||||
@@ -5827,6 +5737,4 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
|
||||
impl_class->show_window_menu = gdk_x11_window_show_window_menu;
|
||||
impl_class->create_gl_context = gdk_x11_window_create_gl_context;
|
||||
impl_class->invalidate_for_new_frame = gdk_x11_window_invalidate_for_new_frame;
|
||||
impl_class->get_unscaled_size = gdk_x11_window_get_unscaled_size;
|
||||
impl_class->do_composite = gdk_x11_window_do_composite;
|
||||
}
|
||||
|
||||
@@ -76,14 +76,6 @@ struct _GdkWindowImplX11
|
||||
|
||||
gint window_scale;
|
||||
|
||||
/* Width and height not divided by window_scale - this matters in the
|
||||
* corner-case where the window manager assigns us a size that isn't
|
||||
* a multiple of window_scale - for example for a maximized window
|
||||
* with an odd-sized title-bar.
|
||||
*/
|
||||
gint unscaled_width;
|
||||
gint unscaled_height;
|
||||
|
||||
cairo_surface_t *cairo_surface;
|
||||
|
||||
#if defined (HAVE_XCOMPOSITE) && defined(HAVE_XDAMAGE) && defined (HAVE_XFIXES)
|
||||
|
||||
+3
-16
@@ -393,7 +393,6 @@ gtk_public_h_sources = \
|
||||
gtkmenushell.h \
|
||||
gtkmenutoolbutton.h \
|
||||
gtkmessagedialog.h \
|
||||
gtkmodelbutton.h \
|
||||
gtkmodules.h \
|
||||
gtkmountoperation.h \
|
||||
gtknotebook.h \
|
||||
@@ -406,7 +405,6 @@ gtk_public_h_sources = \
|
||||
gtkplacessidebar.h \
|
||||
gtkplug.h \
|
||||
gtkpopover.h \
|
||||
gtkpopovermenu.h \
|
||||
gtkprintcontext.h \
|
||||
gtkprintoperation.h \
|
||||
gtkprintoperationpreview.h \
|
||||
@@ -626,6 +624,7 @@ gtk_private_h_sources = \
|
||||
gtkmenutrackeritem.h \
|
||||
gtkmnemonichash.h \
|
||||
gtkmodelmenuitem.h \
|
||||
gtkmodelbutton.h \
|
||||
gtkmodifierstyle.h \
|
||||
gtkmodulesprivate.h \
|
||||
gtkmountoperationprivate.h \
|
||||
@@ -1009,7 +1008,6 @@ gtk_base_c_sources = \
|
||||
gtkprogressbar.c \
|
||||
gtkpixelcache.c \
|
||||
gtkpopover.c \
|
||||
gtkpopovermenu.c \
|
||||
gtkradiobutton.c \
|
||||
gtkradiomenuitem.c \
|
||||
gtkradiotoolbutton.c \
|
||||
@@ -1405,7 +1403,6 @@ gtk.gresource.xml: Makefile.am
|
||||
n=`basename $$f`; \
|
||||
$(ECHO) " <file preprocess=\"to-pixdata\">theme/Adwaita/assets/$$n</file>" >> $@; \
|
||||
done; \
|
||||
$(ECHO) " <file alias=\"theme/HighContrast.css\">theme/HighContrast/gtk.css</file>" >> $@; \
|
||||
if test "$(win32_theme)" = "yes"; then \
|
||||
for f in $(srcdir)/resources/theme/win32/*.css; do \
|
||||
n=`basename $$f`; \
|
||||
@@ -1453,16 +1450,7 @@ adwaita_sources = \
|
||||
resources/theme/Adwaita/gtk.css \
|
||||
resources/theme/Adwaita/gtk-dark.css
|
||||
|
||||
highcontrast_sources = \
|
||||
resources/theme/HighContrast/_colors.scss \
|
||||
resources/theme/HighContrast/_common.scss \
|
||||
resources/theme/HighContrast/_drawing.scss \
|
||||
resources/theme/HighContrast/Gemfile \
|
||||
resources/theme/HighContrast/gtk.css \
|
||||
resources/theme/HighContrast/gtk.scss \
|
||||
resources/theme/HighContrast/parse-sass.sh
|
||||
|
||||
raleigh_sources = \
|
||||
Raleigh_sources = \
|
||||
resources/theme/Raleigh/gtk-default.css
|
||||
|
||||
resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)/resources --generate-dependencies $(builddir)/gtk.gresource.xml)
|
||||
@@ -1741,8 +1729,7 @@ gsettings_SCHEMAS = \
|
||||
EXTRA_DIST += \
|
||||
$(resource_files) \
|
||||
$(adwaita_sources) \
|
||||
$(highcontrast_sources) \
|
||||
$(raleigh_sources) \
|
||||
$(Raleigh_sources) \
|
||||
$(win32_theme_sources) \
|
||||
$(gsettings_SCHEMAS) \
|
||||
$(template_headers) \
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
<glade-widget-classes>
|
||||
<!-- base GTK+ private widgets -->
|
||||
<glade-widget-class name="GtkPathBar" generic-name="pathbar" title="Path Bar" icon-name="widget-gtk-toolbar"/>
|
||||
<glade-widget-class name="GtkColorEditor" generic-name="coloreditor" title="Color Editor" icon-name="widget-gtk-colorselection"/>
|
||||
<glade-widget-class name="GtkColorSwatch" generic-name="colorswatch" title="Color Swatch" icon-name="widget-gtk-colorselection"/>
|
||||
<glade-widget-class name="GtkColorPlane" generic-name="colorplane" title="Color Plane" icon-name="widget-gtk-colorselection"/>
|
||||
<glade-widget-class name="GtkColorScale" generic-name="colorscale" title="Color Scale" icon-name="widget-gtk-colorselection"/>
|
||||
<glade-widget-class name="GtkScaleButtonScale" generic-name="scalebuttonscale" title="Scale Button Scale"/>
|
||||
|
||||
<!-- gtkunixprint private widgets -->
|
||||
<glade-widget-class name="GtkPrinterOptionWidget" generic-name="printeroptionwidget" title="Printer Option Widget"
|
||||
@@ -24,10 +24,10 @@
|
||||
|
||||
<glade-widget-group name="gtk-private" title="Private GTK+ Classes">
|
||||
<glade-widget-class-ref name="GtkPathBar"/>
|
||||
<glade-widget-class-ref name="GtkColorEditor"/>
|
||||
<glade-widget-class-ref name="GtkColorSwatch"/>
|
||||
<glade-widget-class-ref name="GtkColorPlane"/>
|
||||
<glade-widget-class-ref name="GtkColorScale"/>
|
||||
<glade-widget-class-ref name="GtkScaleButtonScale"/>
|
||||
<glade-widget-class-ref name="GtkPrinterOptionWidget"/>
|
||||
</glade-widget-group>
|
||||
</glade-catalog>
|
||||
|
||||
@@ -141,7 +141,6 @@
|
||||
#include <gtk/gtkmenushell.h>
|
||||
#include <gtk/gtkmenutoolbutton.h>
|
||||
#include <gtk/gtkmessagedialog.h>
|
||||
#include <gtk/gtkmodelbutton.h>
|
||||
#include <gtk/gtkmodules.h>
|
||||
#include <gtk/gtkmountoperation.h>
|
||||
#include <gtk/gtknotebook.h>
|
||||
@@ -153,7 +152,6 @@
|
||||
#include <gtk/gtkpaned.h>
|
||||
#include <gtk/gtkplacessidebar.h>
|
||||
#include <gtk/gtkpopover.h>
|
||||
#include <gtk/gtkpopovermenu.h>
|
||||
#include <gtk/gtkprintcontext.h>
|
||||
#include <gtk/gtkprintoperation.h>
|
||||
#include <gtk/gtkprintoperationpreview.h>
|
||||
|
||||
+6
-31
@@ -219,9 +219,7 @@ static void gtk_about_dialog_set_property (GObject
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_about_dialog_realize (GtkWidget *widget);
|
||||
static void gtk_about_dialog_unrealize (GtkWidget *widget);
|
||||
static void gtk_about_dialog_show (GtkWidget *widget);
|
||||
static void gtk_about_dialog_show (GtkWidget *widge);
|
||||
static void update_name_version (GtkAboutDialog *about);
|
||||
static void follow_if_link (GtkAboutDialog *about,
|
||||
GtkTextView *text_view,
|
||||
@@ -306,8 +304,6 @@ gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
|
||||
object_class->finalize = gtk_about_dialog_finalize;
|
||||
|
||||
widget_class->show = gtk_about_dialog_show;
|
||||
widget_class->realize = gtk_about_dialog_realize;
|
||||
widget_class->unrealize = gtk_about_dialog_unrealize;
|
||||
|
||||
klass->activate_link = gtk_about_dialog_activate_link;
|
||||
|
||||
@@ -740,6 +736,8 @@ gtk_about_dialog_init (GtkAboutDialog *about)
|
||||
priv->documenters = NULL;
|
||||
priv->artists = NULL;
|
||||
|
||||
priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
|
||||
priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
|
||||
priv->hovering_over_link = FALSE;
|
||||
priv->wrap_license = FALSE;
|
||||
|
||||
@@ -793,35 +791,12 @@ gtk_about_dialog_finalize (GObject *object)
|
||||
g_slist_foreach (priv->visited_links, (GFunc)g_free, NULL);
|
||||
g_slist_free (priv->visited_links);
|
||||
|
||||
g_object_unref (priv->hand_cursor);
|
||||
g_object_unref (priv->regular_cursor);
|
||||
|
||||
G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_about_dialog_realize (GtkWidget *widget)
|
||||
{
|
||||
GtkAboutDialog *about = GTK_ABOUT_DIALOG (widget);
|
||||
GtkAboutDialogPrivate *priv = about->priv;
|
||||
GdkDisplay *display;
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->realize (widget);
|
||||
|
||||
display = gtk_widget_get_display (widget);
|
||||
priv->hand_cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
|
||||
priv->regular_cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_about_dialog_unrealize (GtkWidget *widget)
|
||||
{
|
||||
GtkAboutDialog *about = GTK_ABOUT_DIALOG (widget);
|
||||
GtkAboutDialogPrivate *priv = about->priv;
|
||||
|
||||
g_clear_object (&priv->hand_cursor);
|
||||
g_clear_object (&priv->regular_cursor);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->unrealize (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_about_dialog_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
|
||||
+17
-17
@@ -47,7 +47,7 @@
|
||||
|
||||
struct _GtkActionBarPrivate
|
||||
{
|
||||
GtkWidget *box;
|
||||
GtkWidget *center_box;
|
||||
GtkWidget *revealer;
|
||||
};
|
||||
|
||||
@@ -101,13 +101,13 @@ gtk_action_bar_add (GtkContainer *container,
|
||||
/* When constructing the widget, we want the revealer to be added
|
||||
* as the first child of the bar, as an implementation detail.
|
||||
* After that, the child added by the application should be added
|
||||
* to box.
|
||||
* to center_box.
|
||||
*/
|
||||
|
||||
if (priv->box == NULL)
|
||||
if (priv->center_box == NULL)
|
||||
GTK_CONTAINER_CLASS (gtk_action_bar_parent_class)->add (container, child);
|
||||
else
|
||||
gtk_container_add (GTK_CONTAINER (priv->box), child);
|
||||
gtk_container_add (GTK_CONTAINER (priv->center_box), child);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -119,7 +119,7 @@ gtk_action_bar_remove (GtkContainer *container,
|
||||
if (child == priv->revealer)
|
||||
GTK_CONTAINER_CLASS (gtk_action_bar_parent_class)->remove (container, child);
|
||||
else
|
||||
gtk_container_remove (GTK_CONTAINER (priv->box), child);
|
||||
gtk_container_remove (GTK_CONTAINER (priv->center_box), child);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -133,8 +133,8 @@ gtk_action_bar_forall (GtkContainer *container,
|
||||
if (include_internals)
|
||||
(* callback) (priv->revealer, callback_data);
|
||||
|
||||
if (priv->box)
|
||||
gtk_container_forall (GTK_CONTAINER (priv->box), callback, callback_data);
|
||||
if (priv->center_box)
|
||||
gtk_container_forall (GTK_CONTAINER (priv->center_box), callback, callback_data);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -187,7 +187,7 @@ gtk_action_bar_get_child_property (GtkContainer *container,
|
||||
if (child == priv->revealer)
|
||||
g_param_value_set_default (pspec, value);
|
||||
else
|
||||
gtk_container_child_get_property (GTK_CONTAINER (priv->box),
|
||||
gtk_container_child_get_property (GTK_CONTAINER (priv->center_box),
|
||||
child,
|
||||
pspec->name,
|
||||
value);
|
||||
@@ -203,7 +203,7 @@ gtk_action_bar_set_child_property (GtkContainer *container,
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (container));
|
||||
|
||||
if (child != priv->revealer)
|
||||
gtk_container_child_set_property (GTK_CONTAINER (priv->box),
|
||||
gtk_container_child_set_property (GTK_CONTAINER (priv->center_box),
|
||||
child,
|
||||
pspec->name,
|
||||
value);
|
||||
@@ -218,7 +218,7 @@ gtk_action_bar_get_path_for_child (GtkContainer *container,
|
||||
if (child == priv->revealer)
|
||||
return GTK_CONTAINER_CLASS (gtk_action_bar_parent_class)->get_path_for_child (container, child);
|
||||
else
|
||||
return gtk_container_get_path_for_child (GTK_CONTAINER (priv->box), child);
|
||||
return gtk_container_get_path_for_child (GTK_CONTAINER (priv->center_box), child);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -257,10 +257,10 @@ gtk_action_bar_class_init (GtkActionBarClass *klass)
|
||||
P_("Position"),
|
||||
P_("The index of the child in the parent"),
|
||||
-1, G_MAXINT, 0,
|
||||
G_PARAM_READWRITE));
|
||||
G_PARAM_READABLE));
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/ui/gtkactionbar.ui");
|
||||
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkActionBar, box);
|
||||
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkActionBar, center_box);
|
||||
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkActionBar, revealer);
|
||||
|
||||
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_PANEL);
|
||||
@@ -289,7 +289,7 @@ gtk_action_bar_buildable_add_child (GtkBuildable *buildable,
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
||||
|
||||
if (type && strcmp (type, "center") == 0)
|
||||
gtk_box_set_center_widget (GTK_BOX (priv->box), GTK_WIDGET (child));
|
||||
gtk_box_set_center_widget (GTK_BOX (priv->center_box), GTK_WIDGET (child));
|
||||
else if (!type)
|
||||
gtk_container_add (GTK_CONTAINER (buildable), GTK_WIDGET (child));
|
||||
else
|
||||
@@ -321,7 +321,7 @@ gtk_action_bar_pack_start (GtkActionBar *action_bar,
|
||||
{
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (priv->box), child, FALSE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (priv->center_box), child, FALSE, TRUE, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -340,7 +340,7 @@ gtk_action_bar_pack_end (GtkActionBar *action_bar,
|
||||
{
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
||||
|
||||
gtk_box_pack_end (GTK_BOX (priv->box), child, FALSE, TRUE, 0);
|
||||
gtk_box_pack_end (GTK_BOX (priv->center_box), child, FALSE, TRUE, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -358,7 +358,7 @@ gtk_action_bar_set_center_widget (GtkActionBar *action_bar,
|
||||
{
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
||||
|
||||
gtk_box_set_center_widget (GTK_BOX (priv->box), center_widget);
|
||||
gtk_box_set_center_widget (GTK_BOX (priv->center_box), center_widget);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -378,7 +378,7 @@ gtk_action_bar_get_center_widget (GtkActionBar *action_bar)
|
||||
|
||||
g_return_val_if_fail (GTK_IS_ACTION_BAR (action_bar), NULL);
|
||||
|
||||
return gtk_box_get_center_widget (GTK_BOX (priv->box));
|
||||
return gtk_box_get_center_widget (GTK_BOX (priv->center_box));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-38
@@ -23,8 +23,6 @@
|
||||
#include "gtkwidget.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkdebug.h"
|
||||
#include "gtkmodelbutton.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -68,8 +66,6 @@ struct _GtkActionHelper
|
||||
gboolean enabled;
|
||||
gboolean active;
|
||||
|
||||
GtkButtonRole role;
|
||||
|
||||
gint reporting;
|
||||
};
|
||||
|
||||
@@ -78,7 +74,6 @@ enum
|
||||
PROP_0,
|
||||
PROP_ENABLED,
|
||||
PROP_ACTIVE,
|
||||
PROP_ROLE,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
@@ -112,17 +107,6 @@ gtk_action_helper_report_change (GtkActionHelper *helper,
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_ROLE:
|
||||
{
|
||||
GParamSpec *pspec;
|
||||
|
||||
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (helper->widget), "role");
|
||||
|
||||
if (pspec && G_PARAM_SPEC_VALUE_TYPE (pspec) == GTK_TYPE_BUTTON_ROLE)
|
||||
g_object_set (G_OBJECT (helper->widget), "role", helper->role, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
@@ -162,19 +146,10 @@ gtk_action_helper_action_added (GtkActionHelper *helper,
|
||||
GTK_NOTE(ACTIONS, g_message("actionhelper: %s found and enabled", helper->action_name));
|
||||
|
||||
if (helper->target != NULL && state != NULL)
|
||||
{
|
||||
helper->active = g_variant_equal (state, helper->target);
|
||||
helper->role = GTK_BUTTON_ROLE_RADIO;
|
||||
}
|
||||
helper->active = g_variant_equal (state, helper->target);
|
||||
|
||||
else if (state != NULL && g_variant_is_of_type (state, G_VARIANT_TYPE_BOOLEAN))
|
||||
{
|
||||
helper->active = g_variant_get_boolean (state);
|
||||
helper->role = GTK_BUTTON_ROLE_CHECK;
|
||||
}
|
||||
else
|
||||
{
|
||||
helper->role = GTK_BUTTON_ROLE_NORMAL;
|
||||
}
|
||||
helper->active = g_variant_get_boolean (state);
|
||||
|
||||
if (should_emit_signals)
|
||||
{
|
||||
@@ -183,8 +158,6 @@ gtk_action_helper_action_added (GtkActionHelper *helper,
|
||||
|
||||
if (helper->active)
|
||||
gtk_action_helper_report_change (helper, PROP_ACTIVE);
|
||||
|
||||
gtk_action_helper_report_change (helper, PROP_ROLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,10 +242,6 @@ gtk_action_helper_get_property (GObject *object, guint prop_id,
|
||||
g_value_set_boolean (value, helper->active);
|
||||
break;
|
||||
|
||||
case PROP_ROLE:
|
||||
g_value_set_enum (value, helper->role);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
@@ -344,10 +313,6 @@ gtk_action_helper_class_init (GtkActionHelperClass *class)
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||
gtk_action_helper_pspecs[PROP_ACTIVE] = g_param_spec_boolean ("active", "active", "active", FALSE,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||
gtk_action_helper_pspecs[PROP_ROLE] = g_param_spec_enum ("role", "role", "role",
|
||||
GTK_TYPE_BUTTON_ROLE,
|
||||
GTK_BUTTON_ROLE_NORMAL,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_properties (class, N_PROPS, gtk_action_helper_pspecs);
|
||||
}
|
||||
|
||||
|
||||
@@ -334,7 +334,6 @@ gtk_application_impl_dbus_inhibit (GtkApplicationImpl *impl,
|
||||
GVariant *res;
|
||||
GError *error = NULL;
|
||||
guint cookie;
|
||||
static gboolean warned = FALSE;
|
||||
|
||||
if (dbus->sm_proxy == NULL)
|
||||
return 0;
|
||||
@@ -353,11 +352,7 @@ gtk_application_impl_dbus_inhibit (GtkApplicationImpl *impl,
|
||||
|
||||
if (error)
|
||||
{
|
||||
if (!warned)
|
||||
{
|
||||
g_warning ("Calling Inhibit failed: %s", error->message);
|
||||
warned = TRUE;
|
||||
}
|
||||
g_warning ("Calling Inhibit failed: %s", error->message);
|
||||
g_error_free (error);
|
||||
return 0;
|
||||
}
|
||||
@@ -395,7 +390,6 @@ gtk_application_impl_dbus_is_inhibited (GtkApplicationImpl *impl,
|
||||
GVariant *res;
|
||||
GError *error = NULL;
|
||||
gboolean inhibited;
|
||||
static gboolean warned = FALSE;
|
||||
|
||||
if (dbus->sm_proxy == NULL)
|
||||
return FALSE;
|
||||
@@ -409,11 +403,7 @@ gtk_application_impl_dbus_is_inhibited (GtkApplicationImpl *impl,
|
||||
&error);
|
||||
if (error)
|
||||
{
|
||||
if (!warned)
|
||||
{
|
||||
g_warning ("Calling IsInhibited failed: %s", error->message);
|
||||
warned = TRUE;
|
||||
}
|
||||
g_warning ("Calling IsInhibited failed: %s", error->message);
|
||||
g_error_free (error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+2
-9
@@ -51,7 +51,6 @@
|
||||
#include "gtkwidgetpath.h"
|
||||
#include "a11y/gtkcontaineraccessible.h"
|
||||
#include "a11y/gtkcontaineraccessibleprivate.h"
|
||||
#include "gtkpopovermenu.h"
|
||||
|
||||
/**
|
||||
* SECTION:gtkcontainer
|
||||
@@ -609,10 +608,7 @@ gtk_container_buildable_set_child_property (GtkContainer *container,
|
||||
GValue gvalue = G_VALUE_INIT;
|
||||
GError *error = NULL;
|
||||
|
||||
if (gtk_widget_get_parent (child) != (GtkWidget *)container &&
|
||||
!GTK_IS_ASSISTANT (container) &&
|
||||
!GTK_IS_ACTION_BAR (container) &&
|
||||
!GTK_IS_POPOVER_MENU (container))
|
||||
if (gtk_widget_get_parent (child) != (GtkWidget *)container && !GTK_IS_ASSISTANT (container) && !GTK_IS_ACTION_BAR (container))
|
||||
{
|
||||
/* This can happen with internal children of complex widgets.
|
||||
* Silently ignore the child properties in this case. We explicitly
|
||||
@@ -1722,10 +1718,7 @@ gtk_container_remove (GtkContainer *container,
|
||||
{
|
||||
g_return_if_fail (GTK_IS_CONTAINER (container));
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (container) ||
|
||||
GTK_IS_ASSISTANT (container) ||
|
||||
GTK_IS_ACTION_BAR (container) ||
|
||||
GTK_IS_POPOVER_MENU (container));
|
||||
g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (container) || GTK_IS_ASSISTANT (container) || GTK_IS_ACTION_BAR (container));
|
||||
|
||||
g_object_ref (container);
|
||||
g_object_ref (widget);
|
||||
|
||||
+40
-94
@@ -44,7 +44,6 @@
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkversion.h"
|
||||
|
||||
/**
|
||||
* SECTION:gtkcssprovider
|
||||
@@ -2948,6 +2947,7 @@ _gtk_css_provider_get_theme_dir (void)
|
||||
gchar *path;
|
||||
|
||||
var = g_getenv ("GTK_DATA_PREFIX");
|
||||
|
||||
if (var)
|
||||
path = g_build_filename (var, "share", "themes", NULL);
|
||||
else
|
||||
@@ -2956,96 +2956,6 @@ _gtk_css_provider_get_theme_dir (void)
|
||||
return path;
|
||||
}
|
||||
|
||||
#if (GTK_MINOR_VERSION % 2)
|
||||
#define MINOR (GTK_MINOR_VERSION + 1)
|
||||
#else
|
||||
#define MINOR GTK_MINOR_VERSION
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Look for
|
||||
* $dir/$subdir/gtk-3.16/gtk-$variant.css
|
||||
* $dir/$subdir/gtk-3.14/gtk-$variant.css
|
||||
* ...
|
||||
* $dir/$subdir/gtk-3.0/gtk-$variant.css
|
||||
* and return the first found file.
|
||||
* We don't check versions before 3.14,
|
||||
* since those GTK+ versions didn't have
|
||||
* the versioned loading mechanism.
|
||||
*/
|
||||
static gchar *
|
||||
_gtk_css_find_theme_dir (const gchar *dir,
|
||||
const gchar *subdir,
|
||||
const gchar *name,
|
||||
const gchar *variant)
|
||||
{
|
||||
gchar *file;
|
||||
gchar *base;
|
||||
gchar *subsubdir;
|
||||
gint i;
|
||||
gchar *path;
|
||||
|
||||
if (variant)
|
||||
file = g_strconcat ("gtk-", variant, ".css", NULL);
|
||||
else
|
||||
file = g_strdup ("gtk.css");
|
||||
|
||||
if (subdir)
|
||||
base = g_build_filename (dir, subdir, name, NULL);
|
||||
else
|
||||
base = g_build_filename (dir, name, NULL);
|
||||
|
||||
for (i = MINOR; i >= 0; i = i - 2)
|
||||
{
|
||||
if (i < 14)
|
||||
i = 0;
|
||||
|
||||
subsubdir = g_strdup_printf ("gtk-3.%d", i);
|
||||
path = g_build_filename (base, subsubdir, file, NULL);
|
||||
g_free (subsubdir);
|
||||
|
||||
if (g_file_test (path, G_FILE_TEST_EXISTS))
|
||||
break;
|
||||
|
||||
g_free (path);
|
||||
path = NULL;
|
||||
}
|
||||
|
||||
g_free (file);
|
||||
g_free (base);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
#undef MINOR
|
||||
|
||||
static gchar *
|
||||
_gtk_css_find_theme (const gchar *name,
|
||||
const gchar *variant)
|
||||
{
|
||||
gchar *path;
|
||||
const gchar *var;
|
||||
|
||||
/* First look in the user's config directory */
|
||||
path = _gtk_css_find_theme_dir (g_get_user_data_dir (), "themes", name, variant);
|
||||
if (path)
|
||||
return path;
|
||||
|
||||
/* Next look in the user's home directory */
|
||||
path = _gtk_css_find_theme_dir (g_get_home_dir (), ".themes", name, variant);
|
||||
if (path)
|
||||
return path;
|
||||
|
||||
/* Finally, try in the default theme directory */
|
||||
var = g_getenv ("GTK_DATA_PREFIX");
|
||||
if (!var)
|
||||
var = _gtk_get_data_prefix ();
|
||||
|
||||
path = _gtk_css_find_theme_dir (var, "share" G_DIR_SEPARATOR_S "themes", name, variant);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* _gtk_css_provider_load_named:
|
||||
* @provider: a #GtkCssProvider
|
||||
@@ -3063,7 +2973,7 @@ _gtk_css_provider_load_named (GtkCssProvider *provider,
|
||||
const gchar *name,
|
||||
const gchar *variant)
|
||||
{
|
||||
gchar *path;
|
||||
gchar *subpath, *path;
|
||||
gchar *resource_path;
|
||||
|
||||
g_return_if_fail (GTK_IS_CSS_PROVIDER (provider));
|
||||
@@ -3087,8 +2997,44 @@ _gtk_css_provider_load_named (GtkCssProvider *provider,
|
||||
}
|
||||
g_free (resource_path);
|
||||
|
||||
/* Next try looking for files in the various theme directories. */
|
||||
path = _gtk_css_find_theme (name, variant);
|
||||
|
||||
/* Next try looking for files in the various theme directories.
|
||||
*/
|
||||
if (variant)
|
||||
subpath = g_strdup_printf ("gtk-3.0" G_DIR_SEPARATOR_S "gtk-%s.css", variant);
|
||||
else
|
||||
subpath = g_strdup ("gtk-3.0" G_DIR_SEPARATOR_S "gtk.css");
|
||||
|
||||
/* First look in the user's config directory
|
||||
*/
|
||||
path = g_build_filename (g_get_user_data_dir (), "themes", name, subpath, NULL);
|
||||
if (!g_file_test (path, G_FILE_TEST_EXISTS))
|
||||
{
|
||||
g_free (path);
|
||||
/* Next look in the user's home directory
|
||||
*/
|
||||
path = g_build_filename (g_get_home_dir (), ".themes", name, subpath, NULL);
|
||||
if (!g_file_test (path, G_FILE_TEST_EXISTS))
|
||||
{
|
||||
gchar *theme_dir;
|
||||
|
||||
g_free (path);
|
||||
|
||||
/* Finally, try in the default theme directory */
|
||||
theme_dir = _gtk_css_provider_get_theme_dir ();
|
||||
path = g_build_filename (theme_dir, name, subpath, NULL);
|
||||
g_free (theme_dir);
|
||||
|
||||
if (!g_file_test (path, G_FILE_TEST_EXISTS))
|
||||
{
|
||||
g_free (path);
|
||||
path = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_free (subpath);
|
||||
|
||||
if (path)
|
||||
{
|
||||
char *dir, *resource_file;
|
||||
|
||||
@@ -431,7 +431,9 @@ make_blurred_pango_surface (cairo_t *existing_cr,
|
||||
pango_layout_get_pixel_extents (layout, &ink_rect, NULL);
|
||||
clip_radius = _gtk_cairo_blur_compute_pixels (radius);
|
||||
x_scale = y_scale = 1;
|
||||
cairo_surface_get_device_scale (cairo_get_target (existing_cr), &x_scale, &y_scale);
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_get_device_scale (cairo_get_target (existing_cr), &x_scale, &y_scale);
|
||||
#endif
|
||||
|
||||
surface = cairo_surface_create_similar_image (cairo_get_target (existing_cr),
|
||||
CAIRO_FORMAT_A8,
|
||||
|
||||
+1
-1
@@ -1840,7 +1840,7 @@ gtk_dialog_buildable_custom_finished (GtkBuildable *buildable,
|
||||
else
|
||||
signal_id = GTK_WIDGET_GET_CLASS (object)->activate_signal;
|
||||
|
||||
if (signal_id && !is_action)
|
||||
if (signal_id)
|
||||
{
|
||||
GClosure *closure;
|
||||
|
||||
|
||||
@@ -844,7 +844,9 @@ get_surface_size (cairo_surface_t *surface,
|
||||
|
||||
x_scale = y_scale = 1;
|
||||
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_get_device_scale (surface, &x_scale, &y_scale);
|
||||
#endif
|
||||
|
||||
/* Assume any set scaling is icon scale */
|
||||
*width =
|
||||
|
||||
@@ -9724,6 +9724,8 @@ bubble_targets_received (GtkClipboard *clipboard,
|
||||
gtk_widget_destroy (priv->selection_bubble);
|
||||
|
||||
priv->selection_bubble = gtk_popover_new (GTK_WIDGET (entry));
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (priv->selection_bubble),
|
||||
GTK_STYLE_CLASS_OSD);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (priv->selection_bubble),
|
||||
GTK_STYLE_CLASS_TOUCH_SELECTION);
|
||||
gtk_popover_set_position (GTK_POPOVER (priv->selection_bubble),
|
||||
|
||||
@@ -216,7 +216,6 @@ struct _GtkFileChooserWidgetPrivate {
|
||||
GtkWidget *browse_files_popup_menu_size_column_item;
|
||||
GtkWidget *browse_files_popup_menu_copy_file_location_item;
|
||||
GtkWidget *browse_files_popup_menu_visit_file_item;
|
||||
GtkWidget *browse_files_popup_menu_sort_directories_item;
|
||||
GtkWidget *browse_new_folder_button;
|
||||
GtkWidget *browse_path_bar_hbox;
|
||||
GtkSizeGroup *browse_path_bar_size_group;
|
||||
@@ -1428,28 +1427,6 @@ show_size_column_toggled_cb (GtkCheckMenuItem *item,
|
||||
priv->show_size_column);
|
||||
}
|
||||
|
||||
static void
|
||||
sort_directories_toggled_cb (GtkCheckMenuItem *item,
|
||||
GtkFileChooserWidget *impl)
|
||||
{
|
||||
GtkFileChooserWidgetPrivate *priv = impl->priv;
|
||||
GtkTreeSortable *sortable;
|
||||
|
||||
priv->sort_directories_first = gtk_check_menu_item_get_active (item);
|
||||
|
||||
/* force resorting */
|
||||
sortable = GTK_TREE_SORTABLE (priv->browse_files_model);
|
||||
if (sortable == NULL)
|
||||
return;
|
||||
|
||||
gtk_tree_sortable_set_sort_column_id (sortable,
|
||||
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID,
|
||||
priv->sort_order);
|
||||
gtk_tree_sortable_set_sort_column_id (sortable,
|
||||
priv->sort_column,
|
||||
priv->sort_order);
|
||||
}
|
||||
|
||||
/* Shows an error dialog about not being able to select a dragged file */
|
||||
static void
|
||||
error_selecting_dragged_file_dialog (GtkFileChooserWidget *impl,
|
||||
@@ -1706,9 +1683,6 @@ file_list_build_popup_menu (GtkFileChooserWidget *impl)
|
||||
priv->browse_files_popup_menu_size_column_item = file_list_add_check_menu_item (impl, _("Show _Size Column"),
|
||||
G_CALLBACK (show_size_column_toggled_cb));
|
||||
|
||||
priv->browse_files_popup_menu_sort_directories_item = file_list_add_check_menu_item (impl, _("Sort _Folders before Files"),
|
||||
G_CALLBACK (sort_directories_toggled_cb));
|
||||
|
||||
check_file_list_menu_sensitivity (impl);
|
||||
}
|
||||
|
||||
@@ -1742,13 +1716,6 @@ file_list_update_popup_menu (GtkFileChooserWidget *impl)
|
||||
priv->show_size_column);
|
||||
g_signal_handlers_unblock_by_func (priv->browse_files_popup_menu_size_column_item,
|
||||
G_CALLBACK (show_size_column_toggled_cb), impl);
|
||||
|
||||
g_signal_handlers_block_by_func (priv->browse_files_popup_menu_sort_directories_item,
|
||||
G_CALLBACK (sort_directories_toggled_cb), impl);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (priv->browse_files_popup_menu_sort_directories_item),
|
||||
priv->sort_directories_first);
|
||||
g_signal_handlers_unblock_by_func (priv->browse_files_popup_menu_sort_directories_item,
|
||||
G_CALLBACK (sort_directories_toggled_cb), impl);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3095,11 +3062,10 @@ settings_save (GtkFileChooserWidget *impl)
|
||||
g_settings_set_boolean (settings, SETTINGS_KEY_SHOW_HIDDEN,
|
||||
gtk_file_chooser_get_show_hidden (GTK_FILE_CHOOSER (impl)));
|
||||
g_settings_set_boolean (settings, SETTINGS_KEY_SHOW_SIZE_COLUMN, priv->show_size_column);
|
||||
g_settings_set_boolean (settings, SETTINGS_KEY_SORT_DIRECTORIES_FIRST, priv->sort_directories_first);
|
||||
g_settings_set_enum (settings, SETTINGS_KEY_SORT_COLUMN, priv->sort_column);
|
||||
g_settings_set_enum (settings, SETTINGS_KEY_SORT_ORDER, priv->sort_order);
|
||||
g_settings_set_int (settings, SETTINGS_KEY_SIDEBAR_WIDTH,
|
||||
gtk_paned_get_position (GTK_PANED (priv->browse_widgets_hpaned)));
|
||||
gtk_paned_get_position (GTK_PANED (priv->browse_widgets_hpaned)));
|
||||
|
||||
/* Now apply the settings */
|
||||
g_settings_apply (settings);
|
||||
|
||||
+97
-743
File diff suppressed because it is too large
Load Diff
@@ -68,10 +68,6 @@ struct _GtkGLAreaClass
|
||||
/*< public >*/
|
||||
gboolean (* render) (GtkGLArea *area,
|
||||
GdkGLContext *context);
|
||||
void (* resize) (GtkGLArea *area,
|
||||
int width,
|
||||
int height);
|
||||
GdkGLContext * (* create_context) (GtkGLArea *area);
|
||||
|
||||
/*< private >*/
|
||||
gpointer _padding[6];
|
||||
@@ -83,11 +79,6 @@ GType gtk_gl_area_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GtkWidget * gtk_gl_area_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GdkGLProfile gtk_gl_area_get_profile (GtkGLArea *area);
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
void gtk_gl_area_set_profile (GtkGLArea *area,
|
||||
GdkGLProfile profile);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
gboolean gtk_gl_area_get_has_alpha (GtkGLArea *area);
|
||||
@@ -103,35 +94,11 @@ GDK_AVAILABLE_IN_3_16
|
||||
void gtk_gl_area_set_has_depth_buffer (GtkGLArea *area,
|
||||
gboolean has_depth_buffer);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
gboolean gtk_gl_area_get_has_stencil_buffer (GtkGLArea *area);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
void gtk_gl_area_set_has_stencil_buffer (GtkGLArea *area,
|
||||
gboolean has_stencil_buffer);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
gboolean gtk_gl_area_get_auto_render (GtkGLArea *area);
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
void gtk_gl_area_set_auto_render (GtkGLArea *area,
|
||||
gboolean auto_render);
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
void gtk_gl_area_queue_render (GtkGLArea *area);
|
||||
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GdkGLContext * gtk_gl_area_get_context (GtkGLArea *area);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
void gtk_gl_area_make_current (GtkGLArea *area);
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
void gtk_gl_area_attach_buffers (GtkGLArea *area);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
void gtk_gl_area_set_error (GtkGLArea *area,
|
||||
const GError *error);
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GError * gtk_gl_area_get_error (GtkGLArea *area);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+7
-53
@@ -1515,23 +1515,17 @@ gtk_header_bar_add (GtkContainer *container,
|
||||
|
||||
static GList *
|
||||
find_child_link (GtkHeaderBar *bar,
|
||||
GtkWidget *widget,
|
||||
gint *position)
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
|
||||
GList *l;
|
||||
Child *child;
|
||||
gint i;
|
||||
|
||||
for (l = priv->children, i = 0; l; l = l->next, i++)
|
||||
for (l = priv->children; l; l = l->next)
|
||||
{
|
||||
child = l->data;
|
||||
if (child->widget == widget)
|
||||
{
|
||||
if (position)
|
||||
*position = i;
|
||||
return l;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -1546,7 +1540,7 @@ gtk_header_bar_remove (GtkContainer *container,
|
||||
GList *l;
|
||||
Child *child;
|
||||
|
||||
l = find_child_link (bar, widget, NULL);
|
||||
l = find_child_link (bar, widget);
|
||||
if (l)
|
||||
{
|
||||
child = l->data;
|
||||
@@ -1601,37 +1595,6 @@ gtk_header_bar_forall (GtkContainer *container,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_header_bar_reorder_child (GtkHeaderBar *bar,
|
||||
GtkWidget *widget,
|
||||
gint position)
|
||||
{
|
||||
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
|
||||
GList *l;
|
||||
gint old_position;
|
||||
Child *child;
|
||||
|
||||
l = find_child_link (bar, widget, &old_position);
|
||||
|
||||
if (l == NULL)
|
||||
return;
|
||||
|
||||
if (old_position == position)
|
||||
return;
|
||||
|
||||
child = l->data;
|
||||
priv->children = g_list_delete_link (priv->children, l);
|
||||
|
||||
if (position < 0)
|
||||
l = NULL;
|
||||
else
|
||||
l = g_list_nth (priv->children, position);
|
||||
|
||||
priv->children = g_list_insert_before (priv->children, l, child);
|
||||
gtk_widget_child_notify (widget, "position");
|
||||
gtk_widget_queue_resize (widget);
|
||||
}
|
||||
|
||||
static GType
|
||||
gtk_header_bar_child_type (GtkContainer *container)
|
||||
{
|
||||
@@ -1650,7 +1613,7 @@ gtk_header_bar_get_child_property (GtkContainer *container,
|
||||
GList *l;
|
||||
Child *child;
|
||||
|
||||
l = find_child_link (bar, widget, NULL);
|
||||
l = find_child_link (bar, widget);
|
||||
if (l == NULL)
|
||||
{
|
||||
g_param_value_set_default (pspec, value);
|
||||
@@ -1686,10 +1649,7 @@ gtk_header_bar_set_child_property (GtkContainer *container,
|
||||
GList *l;
|
||||
Child *child;
|
||||
|
||||
l = find_child_link (bar, widget, NULL);
|
||||
if (l == NULL)
|
||||
return;
|
||||
|
||||
l = find_child_link (bar, widget);
|
||||
child = l->data;
|
||||
|
||||
switch (property_id)
|
||||
@@ -1697,13 +1657,7 @@ gtk_header_bar_set_child_property (GtkContainer *container,
|
||||
case CHILD_PROP_PACK_TYPE:
|
||||
child->pack_type = g_value_get_enum (value);
|
||||
_gtk_header_bar_update_separator_visibility (bar);
|
||||
gtk_widget_queue_resize (widget);
|
||||
break;
|
||||
|
||||
case CHILD_PROP_POSITION:
|
||||
gtk_header_bar_reorder_child (bar, widget, g_value_get_int (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
|
||||
break;
|
||||
@@ -1849,7 +1803,7 @@ gtk_header_bar_class_init (GtkHeaderBarClass *class)
|
||||
P_("Position"),
|
||||
P_("The index of the child in the parent"),
|
||||
-1, G_MAXINT, 0,
|
||||
GTK_PARAM_READWRITE));
|
||||
GTK_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_TITLE,
|
||||
|
||||
@@ -335,7 +335,9 @@ get_surface_size (GtkIconHelper *self,
|
||||
{
|
||||
x_scale = y_scale = 1;
|
||||
|
||||
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
|
||||
cairo_surface_get_device_scale (surface, &x_scale, &y_scale);
|
||||
#endif
|
||||
|
||||
/* Assume any set scaling is icon scale */
|
||||
*width =
|
||||
|
||||
+2
-2
@@ -2305,7 +2305,7 @@ gtk_icon_theme_load_icon_for_scale (GtkIconTheme *icon_theme,
|
||||
if (!icon_info)
|
||||
{
|
||||
g_set_error (error, GTK_ICON_THEME_ERROR, GTK_ICON_THEME_NOT_FOUND,
|
||||
_("Icon '%s' not present in theme %s"), icon_name, icon_theme->priv->current_theme);
|
||||
_("Icon '%s' not present in theme"), icon_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -2369,7 +2369,7 @@ gtk_icon_theme_load_surface (GtkIconTheme *icon_theme,
|
||||
if (!icon_info)
|
||||
{
|
||||
g_set_error (error, GTK_ICON_THEME_ERROR, GTK_ICON_THEME_NOT_FOUND,
|
||||
_("Icon '%s' not present in theme %s"), icon_name, icon_theme->priv->current_theme);
|
||||
_("Icon '%s' not present in theme"), icon_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -1449,8 +1449,6 @@ gtk_list_box_unselect_all_internal (GtkListBox *box)
|
||||
dirty |= gtk_list_box_row_set_selected (row, FALSE);
|
||||
}
|
||||
|
||||
BOX_PRIV (box)->selected_row = NULL;
|
||||
|
||||
return dirty;
|
||||
}
|
||||
|
||||
|
||||
+12
-7
@@ -91,7 +91,6 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gdk/gdk.h"
|
||||
#include "gdk/gdk-private.h"
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
@@ -643,7 +642,7 @@ do_pre_parse_initialization (int *argc,
|
||||
if (_gtk_module_has_mixed_deps (NULL))
|
||||
g_error ("GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported");
|
||||
|
||||
GDK_PRIVATE_CALL (gdk_pre_parse) ();
|
||||
gdk_pre_parse_libgtk_only ();
|
||||
gdk_event_handler_set ((GdkEventFunc)gtk_main_do_event, NULL, NULL);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
@@ -756,7 +755,7 @@ post_parse_hook (GOptionContext *context,
|
||||
|
||||
if (info->open_default_display)
|
||||
{
|
||||
if (GDK_PRIVATE_CALL (gdk_display_open_default) () == NULL)
|
||||
if (gdk_display_open_default_libgtk_only () == NULL)
|
||||
{
|
||||
const char *display_name = gdk_get_display_arg_name ();
|
||||
g_set_error (error,
|
||||
@@ -831,7 +830,7 @@ gtk_get_option_group (gboolean open_default_display)
|
||||
group = g_option_group_new ("gtk", _("GTK+ Options"), _("Show GTK+ Options"), info, g_free);
|
||||
g_option_group_set_parse_hooks (group, pre_parse_hook, post_parse_hook);
|
||||
|
||||
GDK_PRIVATE_CALL (gdk_add_option_entries) (group);
|
||||
gdk_add_option_entries_libgtk_only (group);
|
||||
g_option_group_add_entries (group, gtk_args);
|
||||
g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
|
||||
|
||||
@@ -880,7 +879,7 @@ gtk_init_with_args (gint *argc,
|
||||
gboolean retval;
|
||||
|
||||
if (gtk_initialized)
|
||||
return GDK_PRIVATE_CALL (gdk_display_open_default) () != NULL;
|
||||
return gdk_display_open_default_libgtk_only () != NULL;
|
||||
|
||||
gettext_initialization ();
|
||||
|
||||
@@ -986,7 +985,7 @@ gtk_init_check (int *argc,
|
||||
if (!gtk_parse_args (argc, argv))
|
||||
return FALSE;
|
||||
|
||||
ret = GDK_PRIVATE_CALL (gdk_display_open_default) () != NULL;
|
||||
ret = gdk_display_open_default_libgtk_only () != NULL;
|
||||
|
||||
if (debug_flags & GTK_DEBUG_INTERACTIVE)
|
||||
gtk_window_set_interactive_debugging (TRUE);
|
||||
@@ -1339,6 +1338,12 @@ gtk_main_iteration_do (gboolean blocking)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* private libgtk to libgdk interfaces */
|
||||
gboolean gdk_device_grab_info_libgtk_only (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
GdkWindow **grab_window,
|
||||
gboolean *owner_events);
|
||||
|
||||
static void
|
||||
rewrite_events_translate (GdkWindow *old_window,
|
||||
GdkWindow *new_window,
|
||||
@@ -1441,7 +1446,7 @@ rewrite_event_for_grabs (GdkEvent *event)
|
||||
display = gdk_window_get_display (event->any.window);
|
||||
device = gdk_event_get_device (event);
|
||||
|
||||
if (!GDK_PRIVATE_CALL (gdk_device_grab_info) (display, device, &grab_window, &owner_events) ||
|
||||
if (!gdk_device_grab_info_libgtk_only (display, device, &grab_window, &owner_events) ||
|
||||
!owner_events)
|
||||
return NULL;
|
||||
break;
|
||||
|
||||
+3
-6
@@ -3339,7 +3339,6 @@ gtk_menu_get_preferred_height_for_width (GtkWidget *widget,
|
||||
{
|
||||
GdkScreen *screen = gtk_widget_get_screen (priv->toplevel);
|
||||
GdkRectangle monitor;
|
||||
GtkBorder border;
|
||||
|
||||
gdk_screen_get_monitor_workarea (screen, priv->monitor_num, &monitor);
|
||||
|
||||
@@ -3349,12 +3348,10 @@ gtk_menu_get_preferred_height_for_width (GtkWidget *widget,
|
||||
if (priv->position_y + nat_height > monitor.y + monitor.height)
|
||||
nat_height = monitor.y + monitor.height - priv->position_y;
|
||||
|
||||
_gtk_window_get_shadow_width (GTK_WINDOW (priv->toplevel), &border);
|
||||
|
||||
if (priv->position_y + border.top < monitor.y)
|
||||
if (priv->position_y < monitor.y)
|
||||
{
|
||||
min_height -= monitor.y - (priv->position_y + border.top);
|
||||
nat_height -= monitor.y - (priv->position_y + border.top);
|
||||
min_height -= monitor.y - priv->position_y;
|
||||
nat_height -= monitor.y - priv->position_y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+29
-29
@@ -56,14 +56,13 @@ typedef struct
|
||||
|
||||
G_DEFINE_TYPE (GtkMenuSectionBox, gtk_menu_section_box, GTK_TYPE_BOX)
|
||||
|
||||
static void gtk_menu_section_box_sync_separators (GtkMenuSectionBox *box,
|
||||
MenuData *data);
|
||||
static void gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item,
|
||||
GtkMenuSectionBox *toplevel,
|
||||
GtkWidget *focus,
|
||||
const gchar *name);
|
||||
static GtkWidget * gtk_menu_section_box_new_section (GtkMenuTrackerItem *item,
|
||||
GtkMenuSectionBox *parent);
|
||||
void gtk_menu_section_box_sync_separators (GtkMenuSectionBox *box,
|
||||
MenuData *data);
|
||||
void gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item,
|
||||
GtkMenuSectionBox *toplevel,
|
||||
GtkWidget *focus);
|
||||
GtkWidget * gtk_menu_section_box_new_section (GtkMenuTrackerItem *item,
|
||||
GtkMenuSectionBox *parent);
|
||||
|
||||
static void
|
||||
gtk_menu_section_box_sync_item (GtkWidget *widget,
|
||||
@@ -87,10 +86,11 @@ gtk_menu_section_box_sync_item (GtkWidget *widget,
|
||||
* rule 5: never show separators directly above or below an iconic box
|
||||
* (rule 6: these rules don't apply exactly the same way for subsections)
|
||||
*/
|
||||
static void
|
||||
void
|
||||
gtk_menu_section_box_sync_separators (GtkMenuSectionBox *box,
|
||||
MenuData *data)
|
||||
{
|
||||
GtkWidget *parent_widget;
|
||||
gboolean previous_section_is_iconic;
|
||||
gboolean should_have_separator;
|
||||
gboolean should_have_top_margin = FALSE;
|
||||
@@ -235,12 +235,16 @@ close_submenu (GtkWidget *button,
|
||||
gpointer data)
|
||||
{
|
||||
GtkMenuTrackerItem *item = data;
|
||||
GtkWidget *stack;
|
||||
GtkWidget *parent;
|
||||
GtkWidget *focus;
|
||||
|
||||
if (gtk_menu_tracker_item_get_should_request_show (item))
|
||||
gtk_menu_tracker_item_request_submenu_shown (item, FALSE);
|
||||
|
||||
focus = GTK_WIDGET (g_object_get_data (G_OBJECT (button), "focus"));
|
||||
get_ancestors (focus, GTK_TYPE_STACK, &stack, &parent);
|
||||
gtk_stack_set_visible_child (GTK_STACK (stack), parent);
|
||||
gtk_widget_grab_focus (focus);
|
||||
}
|
||||
|
||||
@@ -249,12 +253,16 @@ open_submenu (GtkWidget *button,
|
||||
gpointer data)
|
||||
{
|
||||
GtkMenuTrackerItem *item = data;
|
||||
GtkWidget *stack;
|
||||
GtkWidget *child;
|
||||
GtkWidget *focus;
|
||||
|
||||
if (gtk_menu_tracker_item_get_should_request_show (item))
|
||||
gtk_menu_tracker_item_request_submenu_shown (item, TRUE);
|
||||
|
||||
focus = GTK_WIDGET (g_object_get_data (G_OBJECT (button), "focus"));
|
||||
get_ancestors (focus, GTK_TYPE_STACK, &stack, &child);
|
||||
gtk_stack_set_visible_child (GTK_STACK (stack), child);
|
||||
gtk_widget_grab_focus (focus);
|
||||
}
|
||||
|
||||
@@ -272,25 +280,17 @@ gtk_menu_section_box_insert_func (GtkMenuTrackerItem *item,
|
||||
}
|
||||
else if (gtk_menu_tracker_item_get_has_link (item, G_MENU_LINK_SUBMENU))
|
||||
{
|
||||
GtkWidget *stack = NULL;
|
||||
GtkWidget *parent = NULL;
|
||||
gchar *name;
|
||||
|
||||
widget = g_object_new (GTK_TYPE_MODEL_BUTTON,
|
||||
"menu-name", gtk_menu_tracker_item_get_label (item),
|
||||
NULL);
|
||||
widget = g_object_new (GTK_TYPE_MODEL_BUTTON, "has-submenu", TRUE, NULL);
|
||||
g_object_bind_property (item, "label", widget, "text", G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (item, "icon", widget, "icon", G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (item, "sensitive", widget, "sensitive", G_BINDING_SYNC_CREATE);
|
||||
|
||||
get_ancestors (GTK_WIDGET (box->toplevel), GTK_TYPE_STACK, &stack, &parent);
|
||||
gtk_container_child_get (GTK_CONTAINER (stack), parent, "name", &name, NULL);
|
||||
gtk_menu_section_box_new_submenu (item, box->toplevel, widget, name);
|
||||
g_free (name);
|
||||
gtk_menu_section_box_new_submenu (item, box->toplevel, widget);
|
||||
gtk_widget_show (widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
widget = gtk_model_button_new ();
|
||||
|
||||
g_object_bind_property (item, "label", widget, "text", G_BINDING_SYNC_CREATE);
|
||||
|
||||
if (box->iconic)
|
||||
@@ -302,8 +302,10 @@ gtk_menu_section_box_insert_func (GtkMenuTrackerItem *item,
|
||||
g_object_bind_property (item, "icon", widget, "icon", G_BINDING_SYNC_CREATE);
|
||||
|
||||
g_object_bind_property (item, "sensitive", widget, "sensitive", G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (item, "role", widget, "role", G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (item, "toggled", widget, "active", G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (item, "role", widget, "action-role", G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (item, "toggled", widget, "toggled", G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (item, "accel", widget, "accel", G_BINDING_SYNC_CREATE);
|
||||
|
||||
g_signal_connect (widget, "clicked", G_CALLBACK (gtk_popover_item_activate), item);
|
||||
}
|
||||
|
||||
@@ -387,11 +389,10 @@ gtk_menu_section_box_new_toplevel (GtkStack *stack,
|
||||
gtk_widget_show (GTK_WIDGET (box));
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item,
|
||||
GtkMenuSectionBox *toplevel,
|
||||
GtkWidget *focus,
|
||||
const gchar *name)
|
||||
GtkWidget *focus)
|
||||
{
|
||||
GtkMenuSectionBox *box;
|
||||
GtkWidget *button;
|
||||
@@ -399,11 +400,10 @@ gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item,
|
||||
box = g_object_new (GTK_TYPE_MENU_SECTION_BOX, "margin", 10, NULL);
|
||||
|
||||
button = g_object_new (GTK_TYPE_MODEL_BUTTON,
|
||||
"menu-name", name,
|
||||
"has-submenu", TRUE,
|
||||
"inverted", TRUE,
|
||||
"centered", TRUE,
|
||||
NULL);
|
||||
|
||||
g_object_bind_property (item, "label", button, "text", G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (item, "icon", button, "icon", G_BINDING_SYNC_CREATE);
|
||||
|
||||
@@ -426,7 +426,7 @@ gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item,
|
||||
box);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
GtkWidget *
|
||||
gtk_menu_section_box_new_section (GtkMenuTrackerItem *item,
|
||||
GtkMenuSectionBox *parent)
|
||||
{
|
||||
|
||||
+102
-360
@@ -31,92 +31,19 @@
|
||||
#include "gtkrender.h"
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkstack.h"
|
||||
#include "gtkpopover.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
/**
|
||||
* SECTION:gtkmodelbutton
|
||||
* @Short_description: A button that uses a GAction as model
|
||||
* @Title: GtkModelButton
|
||||
*
|
||||
* GtkModelButton is a button class that can use a #GAction as its model.
|
||||
* In contrast to #GtkToggleButton or #GtkRadioButton, which can also
|
||||
* be backed by a #Gaction via the #GtkActionable:action-name property,
|
||||
* GtkModelButton will adapt its appearance according to the kind of
|
||||
* action it is backed by, and appear either as a plain, check or
|
||||
* radio button.
|
||||
*
|
||||
* Model buttons are used when popovers from a menu model with
|
||||
* gtk_popover_new_from_model(); they can also be used manually in
|
||||
* a #GtkPopoverMenu.
|
||||
*
|
||||
* When the action is specified via the #GtkActionable:action-name
|
||||
* and #GtkActionable:action-target properties, the role of the button
|
||||
* (i.e. whether it is a plain, check or radio button) is determined by
|
||||
* the type of the action and doesn't have to be explicitly specified
|
||||
* with the #GtkModelButton:role property.
|
||||
*
|
||||
* The content of the button is specified by the #GtkModelButton:text
|
||||
* and #GtkModelButton:icon properties.
|
||||
*
|
||||
* The appearance of model buttons can be influenced with the
|
||||
* #GtkModelButton:centered and #GtkModelButton:iconic properties.
|
||||
*
|
||||
* Model buttons have built-in support for submenus in #GtkPopoverMenu.
|
||||
* To make a GtkModelButton that opens a submenu when activated, set
|
||||
* the #GtkModelButton:menu-name property. To make a button that goes
|
||||
* back to the parent menu, you should set the #GtkModelButton:inverted
|
||||
* property to place the submenu indicator at the opposite side.
|
||||
*
|
||||
* # Example
|
||||
*
|
||||
* |[
|
||||
* <object class="GtkPopoverMenu">
|
||||
* <child>
|
||||
* <object class="GtkBox">
|
||||
* <property name="visible">True</property>
|
||||
* <property name="margin">10</property>
|
||||
* <child>
|
||||
* <object class="GtkModelButton">
|
||||
* <property name="visible">True</property>
|
||||
* <property name="action-name">view.cut</property>
|
||||
* <property name="text" translatable="yes">Cut</property>
|
||||
* </object>
|
||||
* </child>
|
||||
* <child>
|
||||
* <object class="GtkModelButton">
|
||||
* <property name="visible">True</property>
|
||||
* <property name="action-name">view.copy</property>
|
||||
* <property name="text" translatable="yes">Copy</property>
|
||||
* </object>
|
||||
* </child>
|
||||
* <child>
|
||||
* <object class="GtkModelButton">
|
||||
* <property name="visible">True</property>
|
||||
* <property name="action-name">view.paste</property>
|
||||
* <property name="text" translatable="yes">Paste</property>
|
||||
* </object>
|
||||
* </child>
|
||||
* </object>
|
||||
* </child>
|
||||
* </object>
|
||||
* ]|
|
||||
*/
|
||||
|
||||
struct _GtkModelButton
|
||||
{
|
||||
GtkButton parent_instance;
|
||||
|
||||
GtkWidget *box;
|
||||
GtkWidget *image;
|
||||
GtkWidget *label;
|
||||
gboolean active;
|
||||
gboolean toggled;
|
||||
gboolean has_submenu;
|
||||
gboolean centered;
|
||||
gboolean inverted;
|
||||
gboolean iconic;
|
||||
gchar *menu_name;
|
||||
GtkButtonRole role;
|
||||
GtkMenuTrackerItemRole role;
|
||||
};
|
||||
|
||||
typedef GtkButtonClass GtkModelButtonClass;
|
||||
@@ -126,41 +53,20 @@ G_DEFINE_TYPE (GtkModelButton, gtk_model_button, GTK_TYPE_BUTTON)
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_ROLE,
|
||||
PROP_ACTION_ROLE,
|
||||
PROP_ICON,
|
||||
PROP_TEXT,
|
||||
PROP_ACTIVE,
|
||||
PROP_MENU_NAME,
|
||||
PROP_TOGGLED,
|
||||
PROP_ACCEL,
|
||||
PROP_HAS_SUBMENU,
|
||||
PROP_INVERTED,
|
||||
PROP_CENTERED,
|
||||
PROP_ICONIC,
|
||||
LAST_PROPERTY
|
||||
PROP_ICONIC
|
||||
};
|
||||
|
||||
static GParamSpec *properties[LAST_PROPERTY] = { NULL, };
|
||||
|
||||
static void
|
||||
gtk_model_button_update_state (GtkModelButton *button)
|
||||
{
|
||||
GtkStateFlags state;
|
||||
|
||||
if (button->role == GTK_BUTTON_ROLE_NORMAL)
|
||||
return;
|
||||
|
||||
state = gtk_widget_get_state_flags (GTK_WIDGET (button));
|
||||
|
||||
state &= ~GTK_STATE_FLAG_CHECKED;
|
||||
|
||||
if (button->active && !button->menu_name)
|
||||
state |= GTK_STATE_FLAG_CHECKED;
|
||||
|
||||
gtk_widget_set_state_flags (GTK_WIDGET (button), state, TRUE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_model_button_set_role (GtkModelButton *button,
|
||||
GtkButtonRole role)
|
||||
gtk_model_button_set_action_role (GtkModelButton *button,
|
||||
GtkMenuTrackerItemRole role)
|
||||
{
|
||||
AtkObject *accessible;
|
||||
AtkRole a11y_role;
|
||||
@@ -169,19 +75,20 @@ gtk_model_button_set_role (GtkModelButton *button,
|
||||
return;
|
||||
|
||||
button->role = role;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (button));
|
||||
|
||||
accessible = gtk_widget_get_accessible (GTK_WIDGET (button));
|
||||
switch (role)
|
||||
{
|
||||
case GTK_BUTTON_ROLE_NORMAL:
|
||||
case GTK_MENU_TRACKER_ITEM_ROLE_NORMAL:
|
||||
a11y_role = ATK_ROLE_PUSH_BUTTON;
|
||||
break;
|
||||
|
||||
case GTK_BUTTON_ROLE_CHECK:
|
||||
case GTK_MENU_TRACKER_ITEM_ROLE_CHECK:
|
||||
a11y_role = ATK_ROLE_CHECK_BOX;
|
||||
break;
|
||||
|
||||
case GTK_BUTTON_ROLE_RADIO:
|
||||
case GTK_MENU_TRACKER_ITEM_ROLE_RADIO:
|
||||
a11y_role = ATK_ROLE_RADIO_BUTTON;
|
||||
break;
|
||||
|
||||
@@ -190,10 +97,6 @@ gtk_model_button_set_role (GtkModelButton *button,
|
||||
}
|
||||
|
||||
atk_object_set_role (accessible, a11y_role);
|
||||
|
||||
gtk_model_button_update_state (button);
|
||||
gtk_widget_queue_draw (GTK_WIDGET (button));
|
||||
g_object_notify_by_pspec (G_OBJECT (button), properties[PROP_ROLE]);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -205,7 +108,7 @@ update_visibility (GtkModelButton *button)
|
||||
has_icon = gtk_image_get_storage_type (GTK_IMAGE (button->image)) != GTK_IMAGE_EMPTY;
|
||||
has_text = gtk_label_get_text (GTK_LABEL (button->label))[0] != '\0';
|
||||
|
||||
gtk_widget_set_visible (button->image, has_icon && (button->iconic || !has_text));
|
||||
gtk_widget_set_visible (button->image, has_icon);
|
||||
gtk_widget_set_visible (button->label, has_text && (!button->iconic || !has_icon));
|
||||
}
|
||||
|
||||
@@ -215,7 +118,6 @@ gtk_model_button_set_icon (GtkModelButton *button,
|
||||
{
|
||||
gtk_image_set_from_gicon (GTK_IMAGE (button->image), icon, GTK_ICON_SIZE_MENU);
|
||||
update_visibility (button);
|
||||
g_object_notify_by_pspec (G_OBJECT (button), properties[PROP_ICON]);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -224,56 +126,64 @@ gtk_model_button_set_text (GtkModelButton *button,
|
||||
{
|
||||
gtk_label_set_text_with_mnemonic (GTK_LABEL (button->label), text);
|
||||
update_visibility (button);
|
||||
g_object_notify_by_pspec (G_OBJECT (button), properties[PROP_TEXT]);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_model_button_set_active (GtkModelButton *button,
|
||||
gboolean active)
|
||||
gtk_model_button_set_accel (GtkModelButton *button,
|
||||
const gchar *accel)
|
||||
{
|
||||
if (button->active == active)
|
||||
return;
|
||||
/* ignore */
|
||||
}
|
||||
|
||||
button->active = active;
|
||||
static void
|
||||
gtk_model_button_update_state (GtkModelButton *button)
|
||||
{
|
||||
GtkStateFlags state;
|
||||
|
||||
state = gtk_widget_get_state_flags (GTK_WIDGET (button));
|
||||
|
||||
state &= ~GTK_STATE_FLAG_CHECKED;
|
||||
|
||||
if (button->toggled && !button->has_submenu)
|
||||
state |= GTK_STATE_FLAG_CHECKED;
|
||||
|
||||
gtk_widget_set_state_flags (GTK_WIDGET (button), state, TRUE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_model_button_set_toggled (GtkModelButton *button,
|
||||
gboolean toggled)
|
||||
{
|
||||
button->toggled = toggled;
|
||||
gtk_model_button_update_state (button);
|
||||
gtk_widget_queue_draw (GTK_WIDGET (button));
|
||||
g_object_notify_by_pspec (G_OBJECT (button), properties[PROP_ACTIVE]);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_model_button_set_menu_name (GtkModelButton *button,
|
||||
const gchar *menu_name)
|
||||
gtk_model_button_set_has_submenu (GtkModelButton *button,
|
||||
gboolean has_submenu)
|
||||
{
|
||||
g_free (button->menu_name);
|
||||
button->menu_name = g_strdup (menu_name);
|
||||
button->has_submenu = has_submenu;
|
||||
gtk_model_button_update_state (button);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (button));
|
||||
g_object_notify_by_pspec (G_OBJECT (button), properties[PROP_MENU_NAME]);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_model_button_set_inverted (GtkModelButton *button,
|
||||
gboolean inverted)
|
||||
{
|
||||
if (button->inverted == inverted)
|
||||
return;
|
||||
|
||||
button->inverted = inverted;
|
||||
gtk_widget_queue_resize (GTK_WIDGET (button));
|
||||
g_object_notify_by_pspec (G_OBJECT (button), properties[PROP_INVERTED]);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_model_button_set_centered (GtkModelButton *button,
|
||||
gboolean centered)
|
||||
{
|
||||
if (button->centered == centered)
|
||||
return;
|
||||
|
||||
button->centered = centered;
|
||||
gtk_widget_set_halign (button->box, button->centered ? GTK_ALIGN_CENTER : GTK_ALIGN_FILL);
|
||||
gtk_widget_queue_draw (GTK_WIDGET (button));
|
||||
g_object_notify_by_pspec (G_OBJECT (button), properties[PROP_CENTERED]);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -282,9 +192,6 @@ gtk_model_button_set_iconic (GtkModelButton *button,
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
|
||||
if (button->iconic == iconic)
|
||||
return;
|
||||
|
||||
button->iconic = iconic;
|
||||
|
||||
context = gtk_widget_get_style_context (GTK_WIDGET (button));
|
||||
@@ -303,58 +210,6 @@ gtk_model_button_set_iconic (GtkModelButton *button,
|
||||
|
||||
update_visibility (button);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (button));
|
||||
g_object_notify_by_pspec (G_OBJECT (button), properties[PROP_ICONIC]);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_model_button_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkModelButton *button = GTK_MODEL_BUTTON (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ROLE:
|
||||
g_value_set_enum (value, button->role);
|
||||
break;
|
||||
|
||||
case PROP_ICON:
|
||||
{
|
||||
GIcon *icon;
|
||||
gtk_image_get_gicon (GTK_IMAGE (button->image), &icon, NULL);
|
||||
g_value_set_object (value, icon);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_TEXT:
|
||||
g_value_set_string (value, gtk_label_get_text (GTK_LABEL (button->label)));
|
||||
break;
|
||||
|
||||
case PROP_ACTIVE:
|
||||
g_value_set_boolean (value, button->active);
|
||||
break;
|
||||
|
||||
case PROP_MENU_NAME:
|
||||
g_value_set_string (value, button->menu_name);
|
||||
break;
|
||||
|
||||
case PROP_INVERTED:
|
||||
g_value_set_boolean (value, button->inverted);
|
||||
break;
|
||||
|
||||
case PROP_CENTERED:
|
||||
g_value_set_boolean (value, button->centered);
|
||||
break;
|
||||
|
||||
case PROP_ICONIC:
|
||||
g_value_set_boolean (value, button->iconic);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -367,8 +222,8 @@ gtk_model_button_set_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ROLE:
|
||||
gtk_model_button_set_role (button, g_value_get_enum (value));
|
||||
case PROP_ACTION_ROLE:
|
||||
gtk_model_button_set_action_role (button, g_value_get_enum (value));
|
||||
break;
|
||||
|
||||
case PROP_ICON:
|
||||
@@ -379,12 +234,16 @@ gtk_model_button_set_property (GObject *object,
|
||||
gtk_model_button_set_text (button, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_ACTIVE:
|
||||
gtk_model_button_set_active (button, g_value_get_boolean (value));
|
||||
case PROP_TOGGLED:
|
||||
gtk_model_button_set_toggled (button, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
case PROP_MENU_NAME:
|
||||
gtk_model_button_set_menu_name (button, g_value_get_string (value));
|
||||
case PROP_ACCEL:
|
||||
gtk_model_button_set_accel (button, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_HAS_SUBMENU:
|
||||
gtk_model_button_set_has_submenu (button, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
case PROP_INVERTED:
|
||||
@@ -452,7 +311,7 @@ has_sibling_with_indicator (GtkWidget *button)
|
||||
continue;
|
||||
|
||||
if (!sibling->centered &&
|
||||
(sibling->menu_name || sibling->role != GTK_BUTTON_ROLE_NORMAL))
|
||||
(sibling->has_submenu || sibling->role != GTK_MENU_TRACKER_ITEM_ROLE_NORMAL))
|
||||
{
|
||||
has_indicator = TRUE;
|
||||
break;
|
||||
@@ -467,7 +326,7 @@ has_sibling_with_indicator (GtkWidget *button)
|
||||
static gboolean
|
||||
needs_indicator (GtkModelButton *button)
|
||||
{
|
||||
if (button->role != GTK_BUTTON_ROLE_NORMAL)
|
||||
if (button->role != GTK_MENU_TRACKER_ITEM_ROLE_NORMAL)
|
||||
return TRUE;
|
||||
|
||||
return has_sibling_with_indicator (GTK_WIDGET (button));
|
||||
@@ -529,12 +388,12 @@ gtk_model_button_get_preferred_width (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_model_button_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
|
||||
gint width,
|
||||
gint *minimum,
|
||||
gint *natural,
|
||||
gint *minimum_baseline,
|
||||
gint *natural_baseline)
|
||||
gtk_model_button_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
|
||||
gint width,
|
||||
gint *minimum,
|
||||
gint *natural,
|
||||
gint *minimum_baseline,
|
||||
gint *natural_baseline)
|
||||
{
|
||||
GtkModelButton *button = GTK_MODEL_BUTTON (widget);
|
||||
GtkWidget *child;
|
||||
@@ -711,7 +570,9 @@ gtk_model_button_draw (GtkWidget *widget,
|
||||
gint baseline;
|
||||
|
||||
if (model_button->iconic)
|
||||
return GTK_WIDGET_CLASS (gtk_model_button_parent_class)->draw (widget, cr);
|
||||
{
|
||||
return GTK_WIDGET_CLASS (gtk_model_button_parent_class)->draw (widget, cr);
|
||||
}
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
width = gtk_widget_get_allocated_width (widget);
|
||||
@@ -742,7 +603,7 @@ gtk_model_button_draw (GtkWidget *widget,
|
||||
width - 2 * border_width,
|
||||
height - 2 * border_width);
|
||||
|
||||
if (model_button->menu_name)
|
||||
if (model_button->has_submenu)
|
||||
{
|
||||
GtkStateFlags state;
|
||||
|
||||
@@ -759,14 +620,14 @@ gtk_model_button_draw (GtkWidget *widget,
|
||||
gtk_render_expander (context, cr, x, y, indicator_size, indicator_size);
|
||||
gtk_style_context_restore (context);
|
||||
}
|
||||
else if (model_button->role == GTK_BUTTON_ROLE_CHECK)
|
||||
else if (model_button->role == GTK_MENU_TRACKER_ITEM_ROLE_CHECK)
|
||||
{
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_CHECK);
|
||||
gtk_render_check (context, cr, x, y, indicator_size, indicator_size);
|
||||
gtk_style_context_restore (context);
|
||||
}
|
||||
else if (model_button->role == GTK_BUTTON_ROLE_RADIO)
|
||||
else if (model_button->role == GTK_MENU_TRACKER_ITEM_ROLE_RADIO)
|
||||
{
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_RADIO);
|
||||
@@ -794,36 +655,12 @@ gtk_model_button_draw (GtkWidget *widget,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_model_button_clicked (GtkButton *button)
|
||||
{
|
||||
GtkModelButton *model_button = GTK_MODEL_BUTTON (button);
|
||||
if (model_button->menu_name != NULL)
|
||||
{
|
||||
GtkWidget *stack;
|
||||
|
||||
stack = gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_STACK);
|
||||
if (stack != NULL)
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (stack), model_button->menu_name);
|
||||
}
|
||||
else if (model_button->role == GTK_BUTTON_ROLE_NORMAL)
|
||||
{
|
||||
GtkWidget *popover;
|
||||
|
||||
popover = gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_POPOVER);
|
||||
if (popover != NULL)
|
||||
gtk_widget_hide (popover);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_model_button_class_init (GtkModelButtonClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
GtkButtonClass *button_class = GTK_BUTTON_CLASS (class);
|
||||
|
||||
object_class->get_property = gtk_model_button_get_property;
|
||||
object_class->set_property = gtk_model_button_set_property;
|
||||
|
||||
widget_class->get_preferred_width = gtk_model_button_get_preferred_width;
|
||||
@@ -834,131 +671,36 @@ gtk_model_button_class_init (GtkModelButtonClass *class)
|
||||
widget_class->size_allocate = gtk_model_button_size_allocate;
|
||||
widget_class->draw = gtk_model_button_draw;
|
||||
|
||||
button_class->clicked = gtk_model_button_clicked;
|
||||
g_object_class_install_property (object_class, PROP_ACTION_ROLE,
|
||||
g_param_spec_enum ("action-role", "", "",
|
||||
GTK_TYPE_MENU_TRACKER_ITEM_ROLE,
|
||||
GTK_MENU_TRACKER_ITEM_ROLE_NORMAL,
|
||||
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (object_class, PROP_ICON,
|
||||
g_param_spec_object ("icon", "", "", G_TYPE_ICON,
|
||||
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (object_class, PROP_TEXT,
|
||||
g_param_spec_string ("text", "", "", NULL,
|
||||
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (object_class, PROP_TOGGLED,
|
||||
g_param_spec_boolean ("toggled", "", "", FALSE,
|
||||
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (object_class, PROP_ACCEL,
|
||||
g_param_spec_string ("accel", "", "", NULL,
|
||||
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (object_class, PROP_HAS_SUBMENU,
|
||||
g_param_spec_boolean ("has-submenu", "", "", FALSE,
|
||||
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (object_class, PROP_INVERTED,
|
||||
g_param_spec_boolean ("inverted", "", "", FALSE,
|
||||
|
||||
/**
|
||||
* GtkModelButton:role:
|
||||
*
|
||||
* Specifies whether the button is a plain, check or radio button.
|
||||
* When #GtkActionable:action-name is set, the role will be determined
|
||||
* from the action and does not have to be set explicitly.
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
properties[PROP_ROLE] =
|
||||
g_param_spec_enum ("role",
|
||||
P_("Role"),
|
||||
P_("The role of this button"),
|
||||
GTK_TYPE_BUTTON_ROLE,
|
||||
GTK_BUTTON_ROLE_NORMAL,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GtkModelButton:icon:
|
||||
*
|
||||
* A #GIcon that will be used if iconic appearance for the button is
|
||||
* desired.
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
properties[PROP_ICON] =
|
||||
g_param_spec_object ("icon",
|
||||
P_("Icon"),
|
||||
P_("The icon"),
|
||||
G_TYPE_ICON,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GtkModelButton:text:
|
||||
*
|
||||
* The label for the button.
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
properties[PROP_TEXT] =
|
||||
g_param_spec_string ("text",
|
||||
P_("Text"),
|
||||
P_("The text"),
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GtkModelButton:active:
|
||||
*
|
||||
* The state of the button. This is reflecting the state of the associated
|
||||
* #GAction.
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
properties[PROP_ACTIVE] =
|
||||
g_param_spec_boolean ("active",
|
||||
P_("Active"),
|
||||
P_("Active"),
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GtkModelButton:menu-name:
|
||||
*
|
||||
* The name of a submenu to open when the button is activated.
|
||||
* If this is set, the button should not have an action associated with it.
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
properties[PROP_MENU_NAME] =
|
||||
g_param_spec_string ("menu-name",
|
||||
P_("Menu name"),
|
||||
P_("The name of the menu to open"),
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GtkModelButton:inverted:
|
||||
*
|
||||
* Whether to show the submenu indicator at the opposite side than normal.
|
||||
* This property should be set for model buttons that 'go back' to a parent
|
||||
* menu.
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
properties[PROP_INVERTED] =
|
||||
g_param_spec_boolean ("inverted",
|
||||
P_("Inverted"),
|
||||
P_("Whether the menu is a parent"),
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GtkModelButton:centered:
|
||||
*
|
||||
* Wether to render the button contents centered instead of left-aligned.
|
||||
* This property should be set for title-like items.
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
properties[PROP_CENTERED] =
|
||||
g_param_spec_boolean ("centered",
|
||||
P_("Centered"),
|
||||
P_("Whether to center the contents"),
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GtkModelButton:iconic:
|
||||
*
|
||||
* If this property is set, the button will show an icon if one is set.
|
||||
* If no icon is set, the text will be used. This is typically used for
|
||||
* horizontal sections of linked buttons.
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
properties[PROP_ICONIC] =
|
||||
g_param_spec_boolean ("iconic",
|
||||
P_("Iconic"),
|
||||
P_("Whether to prefer the icon over text"),
|
||||
TRUE,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_properties (object_class, LAST_PROPERTY, properties);
|
||||
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (object_class, PROP_CENTERED,
|
||||
g_param_spec_boolean ("centered", "", "", FALSE,
|
||||
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (object_class, PROP_ICONIC,
|
||||
g_param_spec_boolean ("iconic", "", "", TRUE,
|
||||
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
gtk_widget_class_set_accessible_role (GTK_WIDGET_CLASS (class), ATK_ROLE_PUSH_BUTTON);
|
||||
}
|
||||
@@ -968,17 +710,17 @@ gtk_model_button_init (GtkModelButton *button)
|
||||
{
|
||||
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
|
||||
button->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
gtk_widget_set_margin_start (button->box, 12);
|
||||
gtk_widget_set_margin_end (button->box, 12);
|
||||
gtk_widget_set_margin_top (button->box, 3);
|
||||
gtk_widget_set_margin_bottom (button->box, 3);
|
||||
g_object_set (button->box,
|
||||
"margin-start", 12,
|
||||
"margin-end", 12,
|
||||
"margin-top", 3,
|
||||
"margin-bottom", 3,
|
||||
NULL);
|
||||
gtk_widget_set_halign (button->box, GTK_ALIGN_FILL);
|
||||
gtk_widget_show (button->box);
|
||||
button->image = gtk_image_new ();
|
||||
gtk_widget_set_no_show_all (button->image, TRUE);
|
||||
g_object_set (button->image, "margin", 4, NULL);
|
||||
button->label = gtk_label_new ("");
|
||||
gtk_widget_set_no_show_all (button->label, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (button->box), button->image);
|
||||
gtk_container_add (GTK_CONTAINER (button->box), button->label);
|
||||
gtk_container_add (GTK_CONTAINER (button), button->box);
|
||||
|
||||
+8
-28
@@ -20,41 +20,21 @@
|
||||
#ifndef __GTK_MODEL_BUTTON_H__
|
||||
#define __GTK_MODEL_BUTTON_H__
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_MODEL_BUTTON (gtk_model_button_get_type ())
|
||||
#define GTK_MODEL_BUTTON(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
|
||||
GTK_TYPE_MODEL_BUTTON, GtkModelButton))
|
||||
#define GTK_IS_MODEL_BUTTON(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
|
||||
GTK_TYPE_MODEL_BUTTON))
|
||||
#define GTK_TYPE_MODEL_BUTTON (gtk_model_button_get_type ())
|
||||
#define GTK_MODEL_BUTTON(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
|
||||
GTK_TYPE_MODEL_BUTTON, GtkModelButton))
|
||||
#define GTK_IS_MODEL_BUTTON(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
|
||||
GTK_TYPE_MODEL_BUTTON))
|
||||
|
||||
typedef struct _GtkModelButton GtkModelButton;
|
||||
typedef struct _GtkModelButton GtkModelButton;
|
||||
|
||||
/**
|
||||
* GtkButtonRole:
|
||||
* @GTK_BUTTON_ROLE_NORMAL: A plain button
|
||||
* @GTK_BUTTON_ROLE_CHECK: A check button
|
||||
* @GTK_BUTTON_ROLE_RADIO: A radio button
|
||||
*
|
||||
* The role specifies the desired appearance of a #GtkModelButton.
|
||||
*/
|
||||
typedef enum {
|
||||
GTK_BUTTON_ROLE_NORMAL,
|
||||
GTK_BUTTON_ROLE_CHECK,
|
||||
GTK_BUTTON_ROLE_RADIO
|
||||
} GtkButtonRole;
|
||||
GType gtk_model_button_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GType gtk_model_button_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GtkWidget * gtk_model_button_new (void);
|
||||
GtkWidget * gtk_model_button_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+39
-34
@@ -598,7 +598,9 @@ gtk_popover_get_rect_coords (GtkPopover *popover,
|
||||
gint *y2_out)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (popover);
|
||||
GtkPopoverPrivate *priv = popover->priv;
|
||||
GtkAllocation allocation;
|
||||
GtkPositionType pos;
|
||||
gint x1, x2, y1, y2;
|
||||
GtkBorder margin;
|
||||
|
||||
@@ -616,10 +618,25 @@ gtk_popover_get_rect_coords (GtkPopover *popover,
|
||||
y2 = allocation.height -
|
||||
gtk_widget_get_margin_bottom (widget) + y1;
|
||||
|
||||
x1 += MAX (TAIL_HEIGHT, margin.left);
|
||||
y1 += MAX (TAIL_HEIGHT, margin.top);
|
||||
x2 -= MAX (TAIL_HEIGHT, margin.right);
|
||||
y2 -= MAX (TAIL_HEIGHT, margin.bottom);
|
||||
pos = get_effective_position (popover, priv->final_position);
|
||||
|
||||
if (pos == GTK_POS_TOP)
|
||||
y2 -= MAX (TAIL_HEIGHT, margin.bottom);
|
||||
else if (pos == GTK_POS_BOTTOM)
|
||||
y1 += MAX (TAIL_HEIGHT, margin.top);
|
||||
else if (pos == GTK_POS_LEFT)
|
||||
x2 -= MAX (TAIL_HEIGHT, margin.right);
|
||||
else if (pos == GTK_POS_RIGHT)
|
||||
x1 += MAX (TAIL_HEIGHT, margin.left);
|
||||
|
||||
if (pos != GTK_POS_BOTTOM)
|
||||
y1 += margin.top;
|
||||
if (pos != GTK_POS_TOP)
|
||||
y2 -= margin.bottom;
|
||||
if (pos != GTK_POS_RIGHT)
|
||||
x1 += margin.left;
|
||||
if (pos != GTK_POS_LEFT)
|
||||
x2 -= margin.right;
|
||||
|
||||
if (x1_out)
|
||||
*x1_out = x1;
|
||||
@@ -639,9 +656,6 @@ gtk_popover_apply_tail_path (GtkPopover *popover,
|
||||
gint tip_x, tip_y;
|
||||
gint final_x, final_y;
|
||||
|
||||
if (!popover->priv->widget)
|
||||
return;
|
||||
|
||||
cairo_set_line_width (cr, 1);
|
||||
gtk_popover_get_gap_coords (popover,
|
||||
&initial_x, &initial_y,
|
||||
@@ -846,39 +860,30 @@ gtk_popover_draw (GtkWidget *widget,
|
||||
rect_x2 - rect_x1,
|
||||
rect_y2 - rect_y1);
|
||||
|
||||
if (popover->priv->widget)
|
||||
gtk_popover_get_gap_coords (popover,
|
||||
&initial_x, &initial_y,
|
||||
NULL, NULL,
|
||||
&final_x, &final_y,
|
||||
&gap_side);
|
||||
|
||||
if (POS_IS_VERTICAL (gap_side))
|
||||
{
|
||||
gtk_popover_get_gap_coords (popover,
|
||||
&initial_x, &initial_y,
|
||||
NULL, NULL,
|
||||
&final_x, &final_y,
|
||||
&gap_side);
|
||||
|
||||
if (POS_IS_VERTICAL (gap_side))
|
||||
{
|
||||
gap_start = initial_x - rect_x1;
|
||||
gap_end = final_x - rect_x1;
|
||||
}
|
||||
else
|
||||
{
|
||||
gap_start = initial_y - rect_y1;
|
||||
gap_end = final_y - rect_y1;
|
||||
}
|
||||
|
||||
/* Now render the frame, without the gap for the arrow tip */
|
||||
gtk_render_frame_gap (context, cr,
|
||||
rect_x1, rect_y1,
|
||||
rect_x2 - rect_x1, rect_y2 - rect_y1,
|
||||
gap_side,
|
||||
gap_start, gap_end);
|
||||
gap_start = initial_x - rect_x1;
|
||||
gap_end = final_x - rect_x1;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_render_frame (context, cr,
|
||||
rect_x1, rect_y1,
|
||||
rect_x2 - rect_x1, rect_y2 - rect_y1);
|
||||
gap_start = initial_y - rect_y1;
|
||||
gap_end = final_y - rect_y1;
|
||||
}
|
||||
|
||||
/* Now render the frame, without the gap for the arrow tip */
|
||||
gtk_render_frame_gap (context, cr,
|
||||
rect_x1, rect_y1,
|
||||
rect_x2 - rect_x1, rect_y2 - rect_y1,
|
||||
gap_side,
|
||||
gap_start, gap_end);
|
||||
|
||||
/* Clip to the arrow shape */
|
||||
cairo_save (cr);
|
||||
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ void gtk_popover_set_pointing_to (GtkPopover *popover,
|
||||
const GdkRectangle *rect);
|
||||
GDK_AVAILABLE_IN_3_12
|
||||
gboolean gtk_popover_get_pointing_to (GtkPopover *popover,
|
||||
GdkRectangle *rect);
|
||||
GdkRectangle *rect);
|
||||
GDK_AVAILABLE_IN_3_12
|
||||
void gtk_popover_set_position (GtkPopover *popover,
|
||||
GtkPositionType position);
|
||||
|
||||
@@ -1,423 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright © 2014 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "gtkpopovermenu.h"
|
||||
#include "gtkstack.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
|
||||
/**
|
||||
* SECTION:gtkpopovermenu
|
||||
* @Short_description: Popovers to use as menus
|
||||
* @Title: GtkPopoverMenu
|
||||
*
|
||||
* GtkPopoverMenu is a subclass of #GtkPopover that treats its
|
||||
* childen like menus and allows switching between them. It is
|
||||
* meant to be used primarily together with #GtkModelButton, but
|
||||
* any widget can be used, such as #GtkSpinButton or #GtkScale.
|
||||
* In this respect, GtkPopoverMenu is more flexible than popovers
|
||||
* that are created from a #GMenuModel with gtk_popover_new_from_model().
|
||||
*
|
||||
* To add a child as a submenu, set the #GtkPopoverMenu:submenu
|
||||
* child property to the name of the submenu. To let the user open
|
||||
* this submenu, add a #GtkModelButton whose #GtkModelButton:menu-name
|
||||
* property is set to the name you've given to the submenu.
|
||||
*
|
||||
* By convention, the first child of a submenu should be a #GtkModelButton
|
||||
* to switch back to the parent menu. Such a button should use the
|
||||
* #GtkModelButton:inverted and #GtkModelButton:centered properties
|
||||
* to achieve a title-like appearance and place the submenu indicator
|
||||
* at the opposite side. To switch back to the main menu, use "main"
|
||||
* as the menu name.
|
||||
*
|
||||
* # Example
|
||||
*
|
||||
* |[
|
||||
* <object class="GtkPopoverMenu">
|
||||
* <child>
|
||||
* <object class="GtkBox">
|
||||
* <property name="visible">True</property>
|
||||
* <property name="margin">10</property>
|
||||
* <child>
|
||||
* <object class="GtkModelButton">
|
||||
* <property name="visible">True</property>
|
||||
* <property name="action-name">win.frob</property>
|
||||
* <property name="text" translatable="yes">Frob</property>
|
||||
* </object>
|
||||
* </child>
|
||||
* <child>
|
||||
* <object class="GtkModelButton">
|
||||
* <property name="visible">True</property>
|
||||
* <property name="menu-name">more</property>
|
||||
* <property name="text" translatable="yes">More</property>
|
||||
* </object>
|
||||
* </child>
|
||||
* </object>
|
||||
* </child>
|
||||
* <child>
|
||||
* <object class="GtkBox">
|
||||
* <property name="visible">True</property>
|
||||
* <property name="margin">10</property>
|
||||
* <child>
|
||||
* <object class="GtkModelButton">
|
||||
* <property name="visible">True</property>
|
||||
* <property name="action-name">win.foo</property>
|
||||
* <property name="text" translatable="yes">Foo</property>
|
||||
* </object>
|
||||
* </child>
|
||||
* <child>
|
||||
* <object class="GtkModelButton">
|
||||
* <property name="visible">True</property>
|
||||
* <property name="action-name">win.bar</property>
|
||||
* <property name="text" translatable="yes">Bar</property>
|
||||
* </object>
|
||||
* </child>
|
||||
* </object>
|
||||
* <packing>
|
||||
* <property name="submenu">more</property>
|
||||
* </packing>
|
||||
* </child>
|
||||
* </object>
|
||||
* ]|
|
||||
*
|
||||
*/
|
||||
|
||||
struct _GtkPopoverMenu
|
||||
{
|
||||
GtkPopover parent_instance;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_VISIBLE_SUBMENU = 1
|
||||
};
|
||||
|
||||
enum {
|
||||
CHILD_PROP_SUBMENU = 1,
|
||||
CHILD_PROP_POSITION
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkPopoverMenu, gtk_popover_menu, GTK_TYPE_POPOVER)
|
||||
|
||||
static void
|
||||
visible_submenu_changed (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
GtkPopoverMenu *popover)
|
||||
{
|
||||
g_object_notify (G_OBJECT (popover), "visible-submenu");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_popover_menu_init (GtkPopoverMenu *popover)
|
||||
{
|
||||
GtkWidget *stack;
|
||||
|
||||
stack = gtk_stack_new ();
|
||||
gtk_stack_set_vhomogeneous (GTK_STACK (stack), FALSE);
|
||||
gtk_stack_set_transition_type (GTK_STACK (stack), GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
|
||||
gtk_widget_show (stack);
|
||||
gtk_container_add (GTK_CONTAINER (popover), stack);
|
||||
g_signal_connect (stack, "notify::visible-child-name",
|
||||
G_CALLBACK (visible_submenu_changed), popover);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_popover_menu_map (GtkWidget *widget)
|
||||
{
|
||||
GTK_WIDGET_CLASS (gtk_popover_menu_parent_class)->map (widget);
|
||||
gtk_popover_menu_open_submenu (GTK_POPOVER_MENU (widget), "main");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_popover_menu_unmap (GtkWidget *widget)
|
||||
{
|
||||
gtk_popover_menu_open_submenu (GTK_POPOVER_MENU (widget), "main");
|
||||
GTK_WIDGET_CLASS (gtk_popover_menu_parent_class)->unmap (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_popover_menu_add (GtkContainer *container,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkWidget *stack;
|
||||
|
||||
stack = gtk_bin_get_child (GTK_BIN (container));
|
||||
|
||||
if (stack == NULL)
|
||||
{
|
||||
gtk_widget_set_parent (child, GTK_WIDGET (container));
|
||||
_gtk_bin_set_child (GTK_BIN (container), child);
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *name;
|
||||
|
||||
if (gtk_stack_get_child_by_name (GTK_STACK (stack), "main"))
|
||||
name = "submenu";
|
||||
else
|
||||
name = "main";
|
||||
|
||||
gtk_stack_add_named (GTK_STACK (stack), child, name);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_popover_menu_remove (GtkContainer *container,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkWidget *stack;
|
||||
|
||||
stack = gtk_bin_get_child (GTK_BIN (container));
|
||||
|
||||
if (child == stack)
|
||||
GTK_CONTAINER_CLASS (gtk_popover_menu_parent_class)->remove (container, child);
|
||||
else
|
||||
gtk_container_remove (GTK_CONTAINER (stack), child);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_popover_menu_forall (GtkContainer *container,
|
||||
gboolean include_internals,
|
||||
GtkCallback callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
GtkWidget *stack;
|
||||
|
||||
stack = gtk_bin_get_child (GTK_BIN (container));
|
||||
|
||||
if (include_internals)
|
||||
(* callback) (stack, callback_data);
|
||||
|
||||
gtk_container_forall (GTK_CONTAINER (stack), callback, callback_data);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_popover_menu_get_child_property (GtkContainer *container,
|
||||
GtkWidget *child,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkWidget *stack;
|
||||
|
||||
stack = gtk_bin_get_child (GTK_BIN (container));
|
||||
|
||||
if (child == stack)
|
||||
return;
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case CHILD_PROP_SUBMENU:
|
||||
{
|
||||
gchar *name;
|
||||
gtk_container_child_get (GTK_CONTAINER (stack), child, "name", &name, NULL);
|
||||
g_value_set_string (value, name);
|
||||
}
|
||||
break;
|
||||
|
||||
case CHILD_PROP_POSITION:
|
||||
{
|
||||
gint position;
|
||||
gtk_container_child_get (GTK_CONTAINER (stack), child, "position", &position, NULL);
|
||||
g_value_set_int (value, position);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_popover_menu_set_child_property (GtkContainer *container,
|
||||
GtkWidget *child,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkWidget *stack;
|
||||
|
||||
stack = gtk_bin_get_child (GTK_BIN (container));
|
||||
|
||||
if (child == stack)
|
||||
return;
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case CHILD_PROP_SUBMENU:
|
||||
{
|
||||
const gchar *name;
|
||||
name = g_value_get_string (value);
|
||||
gtk_container_child_set (GTK_CONTAINER (stack), child, "name", name, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
case CHILD_PROP_POSITION:
|
||||
{
|
||||
gint position;
|
||||
position = g_value_get_int (value);
|
||||
gtk_container_child_set (GTK_CONTAINER (stack), child, "position", position, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_popover_menu_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkWidget *stack;
|
||||
|
||||
stack = gtk_bin_get_child (GTK_BIN (object));
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_VISIBLE_SUBMENU:
|
||||
g_value_set_string (value, gtk_stack_get_visible_child_name (GTK_STACK (stack)));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_popover_menu_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkWidget *stack;
|
||||
|
||||
stack = gtk_bin_get_child (GTK_BIN (object));
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_VISIBLE_SUBMENU:
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (stack), g_value_get_string (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_popover_menu_class_init (GtkPopoverMenuClass *klass)
|
||||
{
|
||||
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->set_property = gtk_popover_menu_set_property;
|
||||
object_class->get_property = gtk_popover_menu_get_property;
|
||||
|
||||
widget_class->map = gtk_popover_menu_map;
|
||||
widget_class->unmap = gtk_popover_menu_unmap;
|
||||
|
||||
container_class->add = gtk_popover_menu_add;
|
||||
container_class->remove = gtk_popover_menu_remove;
|
||||
container_class->forall = gtk_popover_menu_forall;
|
||||
container_class->set_child_property = gtk_popover_menu_set_child_property;
|
||||
container_class->get_child_property = gtk_popover_menu_get_child_property;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_VISIBLE_SUBMENU,
|
||||
g_param_spec_string ("visible-submenu",
|
||||
P_("Visible submenu"),
|
||||
P_("The name of the visible submenu"),
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* GtkPopoverMenu:submenu:
|
||||
*
|
||||
* The submenu child property specifies the name of the submenu
|
||||
* If it is %NULL or "main", the child is used as the main menu,
|
||||
* which is shown initially when the popover is mapped.
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
gtk_container_class_install_child_property (container_class,
|
||||
CHILD_PROP_SUBMENU,
|
||||
g_param_spec_string ("submenu",
|
||||
P_("Submenu"),
|
||||
P_("The name of the submenu"),
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
gtk_container_class_install_child_property (container_class,
|
||||
CHILD_PROP_POSITION,
|
||||
g_param_spec_int ("position",
|
||||
P_("Position"),
|
||||
P_("The index of the child in the parent"),
|
||||
-1, G_MAXINT, 0,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_popover_menu_new:
|
||||
*
|
||||
* Creates a new popover menu.
|
||||
*
|
||||
* Returns: a new #GtkPopoverMenu
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_popover_menu_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_POPOVER_MENU, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_popover_menu_open_submenu:
|
||||
* @popover: a #GtkPopoverMenu
|
||||
* @name: the name of the menu to switch to
|
||||
*
|
||||
* Opens a submenu of the @popover. The @name
|
||||
* must be one of the names given to the submenus
|
||||
* of @popover with #GtkPopoverMenu:submenu, or
|
||||
* "main" to switch back to the main menu.
|
||||
*
|
||||
* #GtkModelButton will open submenus automatically
|
||||
* when the #GtkModelButton:menu-name property is set,
|
||||
* so this function is only needed when you are using
|
||||
* other kinds of widgets to initiate menu changes.
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
void
|
||||
gtk_popover_menu_open_submenu (GtkPopoverMenu *popover,
|
||||
const gchar *name)
|
||||
{
|
||||
GtkWidget *stack;
|
||||
|
||||
g_return_if_fail (GTK_IS_POPOVER_MENU (popover));
|
||||
|
||||
stack = gtk_bin_get_child (GTK_BIN (popover));
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (stack), name);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user