зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1617002 - Remove checks for unsupported GTK3 versions. r=stransky
Cleans up the code a bit to make actually used fallback code easier to spot and update the required GTK version so deprecation warnings are more accurate. Also make `gdk_window_set_opaque_region` always available - we can now assume it to be present in all supported versions. Differential Revision: https://phabricator.services.mozilla.com/D82804
This commit is contained in:
Родитель
52ac7a4727
Коммит
0d74f2d95f
|
@ -55,8 +55,8 @@ GLIB_VERSION=2.22
|
|||
GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26
|
||||
CAIRO_VERSION=1.10
|
||||
GTK2_VERSION=2.18.0
|
||||
GTK3_VERSION=3.4.0
|
||||
GDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_4
|
||||
GTK3_VERSION=3.14.0
|
||||
GDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_14
|
||||
W32API_VERSION=3.14
|
||||
DBUS_VERSION=0.60
|
||||
|
||||
|
|
|
@ -2752,9 +2752,6 @@ static void MOZ_gdk_display_close(GdkDisplay* display) {
|
|||
g_free(theme_name);
|
||||
}
|
||||
|
||||
// A workaround for https://bugzilla.gnome.org/show_bug.cgi?id=703257
|
||||
if (gtk_check_version(3, 9, 8) != NULL) skip_display_close = true;
|
||||
|
||||
bool buggyCairoShutdown = cairo_version() < CAIRO_VERSION_ENCODE(1, 4, 0);
|
||||
|
||||
if (!buggyCairoShutdown) {
|
||||
|
|
|
@ -1294,8 +1294,7 @@ void IMContextWrapper::SetInputContext(nsWindow* aCaller,
|
|||
mInputContext = *aContext;
|
||||
|
||||
if (changingEnabledState) {
|
||||
static bool sInputPurposeSupported = !gtk_check_version(3, 6, 0);
|
||||
if (sInputPurposeSupported && mInputContext.mIMEState.MaybeEditable()) {
|
||||
if (mInputContext.mIMEState.MaybeEditable()) {
|
||||
GtkIMContext* currentContext = GetCurrentContext();
|
||||
if (currentContext) {
|
||||
GtkInputPurpose purpose = GTK_INPUT_PURPOSE_FREE_FORM;
|
||||
|
|
|
@ -16,11 +16,9 @@
|
|||
|
||||
#define STATE_FLAG_DIR_LTR (1U << 7)
|
||||
#define STATE_FLAG_DIR_RTL (1U << 8)
|
||||
#if GTK_CHECK_VERSION(3, 8, 0)
|
||||
static_assert(GTK_STATE_FLAG_DIR_LTR == STATE_FLAG_DIR_LTR &&
|
||||
GTK_STATE_FLAG_DIR_RTL == STATE_FLAG_DIR_RTL,
|
||||
"incorrect direction state flags");
|
||||
#endif
|
||||
|
||||
static GtkWidget* sWidgetStorage[MOZ_GTK_WIDGET_NODE_COUNT];
|
||||
static GtkStyleContext* sStyleStorage[MOZ_GTK_WIDGET_NODE_COUNT];
|
||||
|
@ -440,8 +438,6 @@ static GtkWidget* CreateNotebookWidget() {
|
|||
}
|
||||
|
||||
static void CreateHeaderBarWidget(WidgetNodeType aAppearance) {
|
||||
MOZ_ASSERT(gtk_check_version(3, 10, 0) == nullptr,
|
||||
"GtkHeaderBar is only available on GTK 3.10+.");
|
||||
MOZ_ASSERT(sWidgetStorage[aAppearance] == nullptr,
|
||||
"Header bar widget is already created!");
|
||||
|
||||
|
@ -619,9 +615,6 @@ static bool IsToolbarButtonEnabled(ButtonLayout* aButtonLayout,
|
|||
}
|
||||
|
||||
static void CreateHeaderBarButtons() {
|
||||
MOZ_ASSERT(gtk_check_version(3, 10, 0) == nullptr,
|
||||
"GtkHeaderBar is only available on GTK 3.10+.");
|
||||
|
||||
GtkWidget* headerBar = sWidgetStorage[MOZ_GTK_HEADER_BAR];
|
||||
MOZ_ASSERT(headerBar != nullptr, "We're missing header bar widget!");
|
||||
|
||||
|
@ -1414,19 +1407,17 @@ GtkStyleContext* CreateStyleContextWithStates(WidgetNodeType aNodeType,
|
|||
GetStyleContext(aNodeType, aScale, aDirection, aStateFlags);
|
||||
GtkWidgetPath* path = gtk_widget_path_copy(gtk_style_context_get_path(style));
|
||||
|
||||
if (gtk_check_version(3, 14, 0) == nullptr) {
|
||||
static auto sGtkWidgetPathIterGetState =
|
||||
(GtkStateFlags(*)(const GtkWidgetPath*, gint))dlsym(
|
||||
RTLD_DEFAULT, "gtk_widget_path_iter_get_state");
|
||||
static auto sGtkWidgetPathIterSetState =
|
||||
(void (*)(GtkWidgetPath*, gint, GtkStateFlags))dlsym(
|
||||
RTLD_DEFAULT, "gtk_widget_path_iter_set_state");
|
||||
static auto sGtkWidgetPathIterGetState =
|
||||
(GtkStateFlags(*)(const GtkWidgetPath*, gint))dlsym(
|
||||
RTLD_DEFAULT, "gtk_widget_path_iter_get_state");
|
||||
static auto sGtkWidgetPathIterSetState =
|
||||
(void (*)(GtkWidgetPath*, gint, GtkStateFlags))dlsym(
|
||||
RTLD_DEFAULT, "gtk_widget_path_iter_set_state");
|
||||
|
||||
int pathLength = gtk_widget_path_length(path);
|
||||
for (int i = 0; i < pathLength; i++) {
|
||||
unsigned state = aStateFlags | sGtkWidgetPathIterGetState(path, i);
|
||||
sGtkWidgetPathIterSetState(path, i, GtkStateFlags(state));
|
||||
}
|
||||
int pathLength = gtk_widget_path_length(path);
|
||||
for (int i = 0; i < pathLength; i++) {
|
||||
unsigned state = aStateFlags | sGtkWidgetPathIterGetState(path, i);
|
||||
sGtkWidgetPathIterSetState(path, i, GtkStateFlags(state));
|
||||
}
|
||||
|
||||
style = gtk_style_context_new();
|
||||
|
|
|
@ -12,7 +12,6 @@ namespace mozilla {
|
|||
namespace widget {
|
||||
|
||||
int32_t WidgetUtilsGTK::IsTouchDeviceSupportPresent() {
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
int32_t result = 0;
|
||||
GdkDisplay* display = gdk_display_get_default();
|
||||
if (!display) {
|
||||
|
@ -42,9 +41,6 @@ int32_t WidgetUtilsGTK::IsTouchDeviceSupportPresent() {
|
|||
}
|
||||
|
||||
return result;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
|
|
|
@ -20,15 +20,10 @@
|
|||
* GDK_UNAVAILABLE() warnings, which are useful.
|
||||
*/
|
||||
|
||||
#define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_0
|
||||
#define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_14
|
||||
|
||||
#include_next <gdk/gdkversionmacros.h>
|
||||
|
||||
/* GDK_AVAILABLE_IN_ALL was introduced in 3.10 */
|
||||
#ifndef GDK_AVAILABLE_IN_ALL
|
||||
# define GDK_AVAILABLE_IN_ALL
|
||||
#endif
|
||||
|
||||
#undef GDK_DEPRECATED
|
||||
#define GDK_DEPRECATED GDK_AVAILABLE_IN_ALL
|
||||
#undef GDK_DEPRECATED_FOR
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef GTKENUMS_WRAPPER_H
|
||||
#define GTKENUMS_WRAPPER_H
|
||||
|
||||
#include_next <gtk/gtkenums.h>
|
||||
|
||||
#include <gtk/gtkversion.h>
|
||||
|
||||
#if !GTK_CHECK_VERSION(3, 6, 0)
|
||||
enum GtkInputPurpose {
|
||||
GTK_INPUT_PURPOSE_FREE_FORM,
|
||||
GTK_INPUT_PURPOSE_ALPHA,
|
||||
GTK_INPUT_PURPOSE_DIGITS,
|
||||
GTK_INPUT_PURPOSE_NUMBER,
|
||||
GTK_INPUT_PURPOSE_PHONE,
|
||||
GTK_INPUT_PURPOSE_URL,
|
||||
GTK_INPUT_PURPOSE_EMAIL,
|
||||
GTK_INPUT_PURPOSE_NAME,
|
||||
GTK_INPUT_PURPOSE_PASSWORD,
|
||||
GTK_INPUT_PURPOSE_PIN
|
||||
};
|
||||
|
||||
enum GtkInputHints {
|
||||
GTK_INPUT_HINT_NONE = 0,
|
||||
GTK_INPUT_HINT_SPELLCHECK = 1 << 0,
|
||||
GTK_INPUT_HINT_NO_SPELLCHECK = 1 << 1,
|
||||
GTK_INPUT_HINT_WORD_COMPLETION = 1 << 2,
|
||||
GTK_INPUT_HINT_LOWERCASE = 1 << 3,
|
||||
GTK_INPUT_HINT_UPPERCASE_CHARS = 1 << 4,
|
||||
GTK_INPUT_HINT_UPPERCASE_WORDS = 1 << 5,
|
||||
GTK_INPUT_HINT_UPPERCASE_SENTENCES = 1 << 6,
|
||||
GTK_INPUT_HINT_INHIBIT_OSK = 1 << 7
|
||||
};
|
||||
#endif // 3.6.0
|
||||
|
||||
#endif /* GTKENUMS_WRAPPER_H */
|
|
@ -42,10 +42,6 @@ using mozilla::Span;
|
|||
#define ARROW_RIGHT G_PI_2
|
||||
#define ARROW_LEFT (G_PI + G_PI_2)
|
||||
|
||||
#if !GTK_CHECK_VERSION(3, 14, 0)
|
||||
# define GTK_STATE_FLAG_CHECKED (1 << 11)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// It's used for debugging only to compare Gecko widget style with
|
||||
// the ones used by Gtk+ applications.
|
||||
|
@ -217,8 +213,7 @@ gint moz_gtk_init() {
|
|||
}
|
||||
|
||||
void moz_gtk_refresh() {
|
||||
if (gtk_check_version(3, 12, 0) == nullptr &&
|
||||
gtk_check_version(3, 20, 0) != nullptr) {
|
||||
if (gtk_check_version(3, 20, 0) != nullptr) {
|
||||
// Deprecated for Gtk >= 3.20+
|
||||
GtkStyleContext* style = GetStyleContext(MOZ_GTK_TAB_TOP);
|
||||
gtk_style_context_get_style(style, "has-tab-gap", ¬ebook_has_tab_gap,
|
||||
|
@ -459,13 +454,6 @@ static void EnsureToolbarMetrics(void) {
|
|||
// Make sure we have clean cache after theme reset, etc.
|
||||
memset(&sToolbarMetrics, 0, sizeof(sToolbarMetrics));
|
||||
|
||||
// We're running on old Gtk+ version. Leave the cache empty
|
||||
// which means all buttons are disabled.
|
||||
if (gtk_check_version(3, 10, 0) != nullptr) {
|
||||
sToolbarMetrics.initialized = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate titlebar button visibility and positions.
|
||||
ButtonLayout aButtonLayout[TOOLBAR_BUTTONS];
|
||||
size_t activeButtonNums =
|
||||
|
@ -918,9 +906,9 @@ static void moz_gtk_draw_styled_frame(GtkStyleContext* style, cairo_t* cr,
|
|||
const GdkRectangle* aRect,
|
||||
bool drawFocus) {
|
||||
GdkRectangle rect = *aRect;
|
||||
if (gtk_check_version(3, 6, 0) == nullptr) {
|
||||
InsetByMargin(&rect, style);
|
||||
}
|
||||
|
||||
InsetByMargin(&rect, style);
|
||||
|
||||
gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height);
|
||||
gtk_render_frame(style, cr, rect.x, rect.y, rect.width, rect.height);
|
||||
if (drawFocus) {
|
||||
|
@ -1703,15 +1691,8 @@ static gint moz_gtk_progress_chunk_paint(cairo_t* cr, GdkRectangle* rect,
|
|||
}
|
||||
}
|
||||
|
||||
// gtk_render_activity was used to render progress chunks on GTK versions
|
||||
// before 3.13.7, see bug 1173907.
|
||||
if (!gtk_check_version(3, 13, 7)) {
|
||||
gtk_render_background(style, cr, rect->x, rect->y, rect->width,
|
||||
rect->height);
|
||||
gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
|
||||
} else {
|
||||
gtk_render_activity(style, cr, rect->x, rect->y, rect->width, rect->height);
|
||||
}
|
||||
gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
|
||||
gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
|
||||
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -528,6 +528,7 @@ STUB(gtk_window_set_focus_on_map)
|
|||
STUB(gtk_window_set_geometry_hints)
|
||||
STUB(gtk_window_set_icon_name)
|
||||
STUB(gtk_window_set_modal)
|
||||
STUB(gdk_window_set_opaque_region)
|
||||
STUB(gtk_window_set_skip_taskbar_hint)
|
||||
STUB(gtk_window_set_startup_id)
|
||||
STUB(gtk_window_set_title)
|
||||
|
|
|
@ -62,22 +62,6 @@ static gint PollWrapper(GPollFD* ufds, guint nfsd, gint timeout_) {
|
|||
return result;
|
||||
}
|
||||
|
||||
// For bug 726483.
|
||||
static decltype(GtkContainerClass::check_resize) sReal_gtk_window_check_resize;
|
||||
|
||||
static void wrap_gtk_window_check_resize(GtkContainer* container) {
|
||||
GdkWindow* gdk_window = gtk_widget_get_window(&container->widget);
|
||||
if (gdk_window) {
|
||||
g_object_ref(gdk_window);
|
||||
}
|
||||
|
||||
sReal_gtk_window_check_resize(container);
|
||||
|
||||
if (gdk_window) {
|
||||
g_object_unref(gdk_window);
|
||||
}
|
||||
}
|
||||
|
||||
// Emit resume-events on GdkFrameClock if flush-events has not been
|
||||
// balanced by resume-events at dispose.
|
||||
// For https://bugzilla.gnome.org/show_bug.cgi?id=742636
|
||||
|
@ -186,16 +170,6 @@ nsresult nsAppShell::Init() {
|
|||
}
|
||||
}
|
||||
|
||||
if (!sReal_gtk_window_check_resize &&
|
||||
gtk_check_version(3, 8, 0) != nullptr) { // GTK 3.0 to GTK 3.6.
|
||||
// GtkWindow is a static class and so will leak anyway but this ref
|
||||
// makes sure it isn't recreated.
|
||||
gpointer gtk_plug_class = g_type_class_ref(GTK_TYPE_WINDOW);
|
||||
auto check_resize = >K_CONTAINER_CLASS(gtk_plug_class)->check_resize;
|
||||
sReal_gtk_window_check_resize = *check_resize;
|
||||
*check_resize = wrap_gtk_window_check_resize;
|
||||
}
|
||||
|
||||
if (!sPendingResumeQuark &&
|
||||
gtk_check_version(3, 14, 7) != nullptr) { // GTK 3.0 to GTK 3.14.7.
|
||||
// GTK 3.8 - 3.14 registered this type when creating the frame clock
|
||||
|
|
|
@ -38,44 +38,12 @@ bool nsRetrievalContextX11::HasSelectionSupport(void) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static GdkFilterReturn selection_request_filter(GdkXEvent* gdk_xevent,
|
||||
GdkEvent* event,
|
||||
gpointer data) {
|
||||
XEvent* xevent = static_cast<XEvent*>(gdk_xevent);
|
||||
if (xevent->xany.type == SelectionRequest) {
|
||||
if (xevent->xselectionrequest.requestor == X11None)
|
||||
return GDK_FILTER_REMOVE;
|
||||
|
||||
GdkDisplay* display =
|
||||
gdk_x11_lookup_xdisplay(xevent->xselectionrequest.display);
|
||||
if (!display) return GDK_FILTER_REMOVE;
|
||||
|
||||
GdkWindow* window = gdk_x11_window_foreign_new_for_display(
|
||||
display, xevent->xselectionrequest.requestor);
|
||||
if (!window) return GDK_FILTER_REMOVE;
|
||||
|
||||
g_object_unref(window);
|
||||
}
|
||||
return GDK_FILTER_CONTINUE;
|
||||
}
|
||||
|
||||
nsRetrievalContextX11::nsRetrievalContextX11()
|
||||
: mState(INITIAL),
|
||||
mClipboardRequestNumber(0),
|
||||
mClipboardData(nullptr),
|
||||
mClipboardDataLength(0),
|
||||
mTargetMIMEType(gdk_atom_intern("TARGETS", FALSE)) {
|
||||
// A custom event filter to workaround attempting to dereference a null
|
||||
// selection requestor in GTK3 versions before 3.11.3. See bug 1178799.
|
||||
#if defined(MOZ_X11)
|
||||
if (gtk_check_version(3, 11, 3))
|
||||
gdk_window_add_filter(nullptr, selection_request_filter, nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
nsRetrievalContextX11::~nsRetrievalContextX11() {
|
||||
gdk_window_remove_filter(nullptr, selection_request_filter, nullptr);
|
||||
}
|
||||
mTargetMIMEType(gdk_atom_intern("TARGETS", FALSE)) {}
|
||||
|
||||
static void DispatchSelectionNotifyEvent(GtkWidget* widget, XEvent* xevent) {
|
||||
GdkEvent event = {};
|
||||
|
|
|
@ -32,7 +32,6 @@ class nsRetrievalContextX11 : public nsRetrievalContext {
|
|||
int aDataRequestNumber);
|
||||
|
||||
nsRetrievalContextX11();
|
||||
virtual ~nsRetrievalContextX11() override;
|
||||
|
||||
private:
|
||||
bool WaitForClipboardData(ClipboardDataType aDataType,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
NS_IMPL_ISUPPORTS(nsColorPicker, nsIColorPicker)
|
||||
|
||||
#if defined(ACTIVATE_GTK3_COLOR_PICKER) && GTK_CHECK_VERSION(3, 4, 0)
|
||||
#if defined(ACTIVATE_GTK3_COLOR_PICKER)
|
||||
int nsColorPicker::convertGdkRgbaComponent(gdouble color_component) {
|
||||
// GdkRGBA value is in range [0.0..1.0]. We need something in range [0..255]
|
||||
return color_component * 255 + 0.5;
|
||||
|
@ -93,7 +93,7 @@ NS_IMETHODIMP nsColorPicker::Open(
|
|||
GtkWindow* parent_window =
|
||||
GTK_WINDOW(mParentWidget->GetNativeData(NS_NATIVE_SHELLWIDGET));
|
||||
|
||||
#if defined(ACTIVATE_GTK3_COLOR_PICKER) && GTK_CHECK_VERSION(3, 4, 0)
|
||||
#if defined(ACTIVATE_GTK3_COLOR_PICKER)
|
||||
GtkWidget* color_chooser = gtk_color_chooser_dialog_new(title, parent_window);
|
||||
|
||||
if (parent_window) {
|
||||
|
@ -139,7 +139,7 @@ NS_IMETHODIMP nsColorPicker::Open(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#if defined(ACTIVATE_GTK3_COLOR_PICKER) && GTK_CHECK_VERSION(3, 4, 0)
|
||||
#if defined(ACTIVATE_GTK3_COLOR_PICKER)
|
||||
/* static */
|
||||
void nsColorPicker::OnColorChanged(GtkColorChooser* color_chooser,
|
||||
GdkRGBA* color, gpointer user_data) {
|
||||
|
@ -201,7 +201,7 @@ void nsColorPicker::Done(GtkWidget* color_chooser, gint response) {
|
|||
switch (response) {
|
||||
case GTK_RESPONSE_OK:
|
||||
case GTK_RESPONSE_ACCEPT:
|
||||
#if defined(ACTIVATE_GTK3_COLOR_PICKER) && GTK_CHECK_VERSION(3, 4, 0)
|
||||
#if defined(ACTIVATE_GTK3_COLOR_PICKER)
|
||||
GdkRGBA color;
|
||||
gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(color_chooser), &color);
|
||||
SetColor(&color);
|
||||
|
|
|
@ -35,7 +35,7 @@ class nsColorPicker final : public nsIColorPicker {
|
|||
gpointer user_data);
|
||||
static void OnDestroy(GtkWidget* dialog, gpointer user_data);
|
||||
|
||||
#if defined(ACTIVATE_GTK3_COLOR_PICKER) && GTK_CHECK_VERSION(3, 4, 0)
|
||||
#if defined(ACTIVATE_GTK3_COLOR_PICKER)
|
||||
static void OnColorChanged(GtkColorChooser* color_chooser, GdkRGBA* color,
|
||||
gpointer user_data);
|
||||
|
||||
|
|
|
@ -402,11 +402,6 @@ bool nsDragService::SetAlphaPixmap(SourceSurface* aSurface,
|
|||
#ifdef cairo_image_surface_create
|
||||
# error "Looks like we're including Mozilla's cairo instead of system cairo"
|
||||
#endif
|
||||
// Prior to GTK 3.9.12, cairo surfaces passed into gtk_drag_set_icon_surface
|
||||
// had their shape information derived from the alpha channel and used with
|
||||
// the X SHAPE extension instead of being displayed as an ARGB window.
|
||||
// See bug 1249604.
|
||||
if (gtk_check_version(3, 9, 12)) return false;
|
||||
|
||||
// TODO: grab X11 pixmap or image data instead of expensive readback.
|
||||
cairo_surface_t* surf = cairo_image_surface_create(
|
||||
|
|
|
@ -57,10 +57,6 @@ extern mozilla::LazyLogModule gWidgetLog;
|
|||
((nscolor)NS_RGBA((int)((c).red * 255), (int)((c).green * 255), \
|
||||
(int)((c).blue * 255), (int)((c).alpha * 255)))
|
||||
|
||||
#if !GTK_CHECK_VERSION(3, 12, 0)
|
||||
# define GTK_STATE_FLAG_LINK (static_cast<GtkStateFlags>(1 << 9))
|
||||
#endif
|
||||
|
||||
nsLookAndFeel::nsLookAndFeel() = default;
|
||||
|
||||
nsLookAndFeel::~nsLookAndFeel() = default;
|
||||
|
@ -981,9 +977,6 @@ void nsLookAndFeel::ConfigureContentGtkTheme() {
|
|||
}
|
||||
|
||||
void nsLookAndFeel::EnsureInit() {
|
||||
GdkColor colorValue;
|
||||
GdkColor* colorValuePtr;
|
||||
|
||||
if (mInitialized) {
|
||||
return;
|
||||
}
|
||||
|
@ -1246,25 +1239,12 @@ void nsLookAndFeel::EnsureInit() {
|
|||
}
|
||||
mMenuSupportsDrag = supports_menubar_drag;
|
||||
|
||||
if (gtk_check_version(3, 12, 0) == nullptr) {
|
||||
// TODO: It returns wrong color for themes which
|
||||
// sets link color for GtkLabel only as we query
|
||||
// GtkLinkButton style here.
|
||||
style = gtk_widget_get_style_context(linkButton);
|
||||
gtk_style_context_get_color(style, GTK_STATE_FLAG_LINK, &color);
|
||||
mNativeHyperLinkText = GDK_RGBA_TO_NS_RGBA(color);
|
||||
} else {
|
||||
colorValuePtr = nullptr;
|
||||
gtk_widget_style_get(linkButton, "link-color", &colorValuePtr, nullptr);
|
||||
if (colorValuePtr) {
|
||||
colorValue = *colorValuePtr; // we can't pass deref pointers to
|
||||
// GDK_COLOR_TO_NS_RGB
|
||||
mNativeHyperLinkText = GDK_COLOR_TO_NS_RGB(colorValue);
|
||||
gdk_color_free(colorValuePtr);
|
||||
} else {
|
||||
mNativeHyperLinkText = NS_RGB(0x00, 0x00, 0xEE);
|
||||
}
|
||||
}
|
||||
// TODO: It returns wrong color for themes which
|
||||
// sets link color for GtkLabel only as we query
|
||||
// GtkLinkButton style here.
|
||||
style = gtk_widget_get_style_context(linkButton);
|
||||
gtk_style_context_get_color(style, GTK_STATE_FLAG_LINK, &color);
|
||||
mNativeHyperLinkText = GDK_RGBA_TO_NS_RGBA(color);
|
||||
|
||||
// invisible character styles
|
||||
guint value;
|
||||
|
|
|
@ -1893,8 +1893,6 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext,
|
|||
case StyleAppearance::Window:
|
||||
case StyleAppearance::Dialog:
|
||||
case StyleAppearance::MozGtkInfoBar:
|
||||
return !IsWidgetStyled(aPresContext, aFrame, aAppearance);
|
||||
|
||||
case StyleAppearance::MozWindowButtonBox:
|
||||
case StyleAppearance::MozWindowButtonClose:
|
||||
case StyleAppearance::MozWindowButtonMinimize:
|
||||
|
@ -1902,10 +1900,7 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext,
|
|||
case StyleAppearance::MozWindowButtonRestore:
|
||||
case StyleAppearance::MozWindowTitlebar:
|
||||
case StyleAppearance::MozWindowTitlebarMaximized:
|
||||
// GtkHeaderBar is available on GTK 3.10+, which is used for styling
|
||||
// title bars and title buttons.
|
||||
return gtk_check_version(3, 10, 0) == nullptr &&
|
||||
!IsWidgetStyled(aPresContext, aFrame, aAppearance);
|
||||
return !IsWidgetStyled(aPresContext, aFrame, aAppearance);
|
||||
|
||||
case StyleAppearance::MozMenulistArrowButton:
|
||||
if (aFrame && aFrame->GetWritingMode().IsVertical()) {
|
||||
|
|
|
@ -157,10 +157,7 @@ using mozilla::gl::GLContextGLX;
|
|||
const gint kEvents =
|
||||
GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK | GDK_VISIBILITY_NOTIFY_MASK |
|
||||
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK |
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
GDK_SMOOTH_SCROLL_MASK | GDK_TOUCH_MASK |
|
||||
#endif
|
||||
GDK_BUTTON_RELEASE_MASK | GDK_SMOOTH_SCROLL_MASK | GDK_TOUCH_MASK |
|
||||
GDK_SCROLL_MASK | GDK_POINTER_MOTION_MASK | GDK_PROPERTY_CHANGE_MASK;
|
||||
|
||||
#if !GTK_CHECK_VERSION(3, 22, 0)
|
||||
|
@ -177,10 +174,6 @@ typedef enum {
|
|||
} GdkAnchorHints;
|
||||
#endif
|
||||
|
||||
#if !GTK_CHECK_VERSION(3, 10, 0)
|
||||
# define GDK_WINDOW_STATE_TILED (1 << 8)
|
||||
#endif
|
||||
|
||||
/* utility functions */
|
||||
static bool is_mouse_in_window(GdkWindow* aWindow, gdouble aMouseX,
|
||||
gdouble aMouseY);
|
||||
|
@ -231,9 +224,7 @@ static void widget_composited_changed_cb(GtkWidget* widget, gpointer user_data);
|
|||
|
||||
static void scale_changed_cb(GtkWidget* widget, GParamSpec* aPSpec,
|
||||
gpointer aPointer);
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
static gboolean touch_event_cb(GtkWidget* aWidget, GdkEventTouch* aEvent);
|
||||
#endif
|
||||
static nsWindow* GetFirstNSWindowForGDKWindow(GdkWindow* aGdkWindow);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -339,10 +330,7 @@ static bool gUseWaylandVsync = true;
|
|||
static bool gUseWaylandUseOpaqueRegion = true;
|
||||
static bool gUseAspectRatio = true;
|
||||
static GList* gVisibleWaylandPopupWindows = nullptr;
|
||||
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
static uint32_t gLastTouchID = 0;
|
||||
#endif
|
||||
|
||||
#define NS_WINDOW_TITLE_MAX_LENGTH 4095
|
||||
|
||||
|
@ -400,9 +388,7 @@ nsWindow::nsWindow() {
|
|||
mNeedsShow = false;
|
||||
mEnabled = true;
|
||||
mCreated = false;
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
mHandleTouchEvent = false;
|
||||
#endif
|
||||
mIsDragPopup = false;
|
||||
mIsX11Display = gfxPlatformGtk::GetPlatform()->IsX11Display();
|
||||
|
||||
|
@ -468,9 +454,8 @@ nsWindow::nsWindow() {
|
|||
mTransparencyBitmapWidth = 0;
|
||||
mTransparencyBitmapHeight = 0;
|
||||
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
mLastScrollEventTime = GDK_CURRENT_TIME;
|
||||
#endif
|
||||
|
||||
mPendingConfigures = 0;
|
||||
mCSDSupportLevel = CSD_SUPPORT_NONE;
|
||||
mDrawToContainer = false;
|
||||
|
@ -943,10 +928,8 @@ void nsWindow::SetModal(bool aModal) {
|
|||
bool nsWindow::IsVisible() const { return mIsShown; }
|
||||
|
||||
void nsWindow::RegisterTouchWindow() {
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
mHandleTouchEvent = true;
|
||||
mTouches.Clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
void nsWindow::ConstrainPosition(bool aAllowSlop, int32_t* aX, int32_t* aY) {
|
||||
|
@ -3711,7 +3694,6 @@ gboolean nsWindow::OnKeyReleaseEvent(GdkEventKey* aEvent) {
|
|||
void nsWindow::OnScrollEvent(GdkEventScroll* aEvent) {
|
||||
// check to see if we should rollup
|
||||
if (CheckForRollup(aEvent->x_root, aEvent->y_root, true, false)) return;
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
// check for duplicate legacy scroll event, see GNOME bug 726878
|
||||
if (aEvent->direction != GDK_SCROLL_SMOOTH &&
|
||||
mLastScrollEventTime == aEvent->time) {
|
||||
|
@ -3719,11 +3701,9 @@ void nsWindow::OnScrollEvent(GdkEventScroll* aEvent) {
|
|||
aEvent->direction));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
WidgetWheelEvent wheelEvent(true, eWheel, this);
|
||||
wheelEvent.mDeltaMode = dom::WheelEvent_Binding::DOM_DELTA_LINE;
|
||||
switch (aEvent->direction) {
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
case GDK_SCROLL_SMOOTH: {
|
||||
// As of GTK 3.4, all directional scroll events are provided by
|
||||
// the GDK_SCROLL_SMOOTH direction on XInput2 and Wayland devices.
|
||||
|
@ -3778,7 +3758,6 @@ void nsWindow::OnScrollEvent(GdkEventScroll* aEvent) {
|
|||
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case GDK_SCROLL_UP:
|
||||
wheelEvent.mDeltaY = wheelEvent.mLineOrPageDeltaY = -3;
|
||||
break;
|
||||
|
@ -4096,7 +4075,6 @@ bool nsWindow::IsHandlingTouchSequence(GdkEventSequence* aSequence) {
|
|||
return mHandleTouchEvent && mTouches.Contains(aSequence);
|
||||
}
|
||||
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
gboolean nsWindow::OnTouchEvent(GdkEventTouch* aEvent) {
|
||||
if (!mHandleTouchEvent) {
|
||||
// If a popup window was spawned (e.g. as the result of a long-press)
|
||||
|
@ -4162,7 +4140,6 @@ gboolean nsWindow::OnTouchEvent(GdkEventTouch* aEvent) {
|
|||
DispatchInputEvent(&event);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
static GdkWindow* CreateGdkWindow(GdkWindow* parent, GtkWidget* widget) {
|
||||
GdkWindowAttr attributes;
|
||||
|
@ -4747,10 +4724,8 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
|
|||
G_CALLBACK(button_release_event_cb), nullptr);
|
||||
g_signal_connect(eventWidget, "scroll-event", G_CALLBACK(scroll_event_cb),
|
||||
nullptr);
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
g_signal_connect(eventWidget, "touch-event", G_CALLBACK(touch_event_cb),
|
||||
nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
LOG(("nsWindow [%p] %s %s\n", (void*)this,
|
||||
|
@ -5347,21 +5322,6 @@ void nsWindow::UpdateTopLevelOpaqueRegionWayland(bool aSubtractCorners) {
|
|||
}
|
||||
#endif
|
||||
|
||||
static void GdkWindowSetOpaqueRegion(GdkWindow* aGdkWindow,
|
||||
cairo_region_t* aRegion) {
|
||||
// Available as of GTK 3.10+
|
||||
static auto sGdkWindowSetOpaqueRegion =
|
||||
(void (*)(GdkWindow*, cairo_region_t*))dlsym(
|
||||
RTLD_DEFAULT, "gdk_window_set_opaque_region");
|
||||
|
||||
if (MOZ_UNLIKELY(!sGdkWindowSetOpaqueRegion)) {
|
||||
LOG((" gdk_window_set_opaque_region is not available!\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
(*sGdkWindowSetOpaqueRegion)(aGdkWindow, aRegion);
|
||||
}
|
||||
|
||||
// See subtract_corners_from_region() at gtk/gtkwindow.c
|
||||
// We need to subtract corners from toplevel window opaque region
|
||||
// to draw transparent corners of default Gtk titlebar.
|
||||
|
@ -5401,7 +5361,7 @@ void nsWindow::UpdateTopLevelOpaqueRegionGtk(bool aSubtractCorners) {
|
|||
GdkWindow* window =
|
||||
(mDrawToContainer) ? gtk_widget_get_window(mShell) : mGdkWindow;
|
||||
MOZ_ASSERT(gdk_window_get_window_type(window) == GDK_WINDOW_TOPLEVEL);
|
||||
GdkWindowSetOpaqueRegion(window, region);
|
||||
gdk_window_set_opaque_region(window, region);
|
||||
|
||||
cairo_region_destroy(region);
|
||||
}
|
||||
|
@ -5421,7 +5381,7 @@ void nsWindow::UpdatePopupOpaqueRegion(
|
|||
|
||||
GdkWindow* window =
|
||||
(mDrawToContainer) ? gtk_widget_get_window(mShell) : mGdkWindow;
|
||||
GdkWindowSetOpaqueRegion(window, region);
|
||||
gdk_window_set_opaque_region(window, region);
|
||||
|
||||
if (region) {
|
||||
cairo_region_destroy(region);
|
||||
|
@ -6935,7 +6895,6 @@ static void scale_changed_cb(GtkWidget* widget, GParamSpec* aPSpec,
|
|||
window->OnScaleChanged(&allocation);
|
||||
}
|
||||
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
static gboolean touch_event_cb(GtkWidget* aWidget, GdkEventTouch* aEvent) {
|
||||
UpdateLastInputEventTime(aEvent);
|
||||
|
||||
|
@ -6946,7 +6905,6 @@ static gboolean touch_event_cb(GtkWidget* aWidget, GdkEventTouch* aEvent) {
|
|||
|
||||
return window->OnTouchEvent(aEvent);
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// These are all of our drag and drop operations
|
||||
|
@ -7745,31 +7703,15 @@ nsresult nsWindow::SynthesizeNativeMouseScrollEvent(
|
|||
|
||||
// The delta values are backwards on Linux compared to Windows and Cocoa,
|
||||
// hence the negation.
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
// TODO: is this correct? I don't have GTK 3.4+ so I can't check
|
||||
event.scroll.direction = GDK_SCROLL_SMOOTH;
|
||||
event.scroll.delta_x = -aDeltaX;
|
||||
event.scroll.delta_y = -aDeltaY;
|
||||
#else
|
||||
if (aDeltaX < 0) {
|
||||
event.scroll.direction = GDK_SCROLL_RIGHT;
|
||||
} else if (aDeltaX > 0) {
|
||||
event.scroll.direction = GDK_SCROLL_LEFT;
|
||||
} else if (aDeltaY < 0) {
|
||||
event.scroll.direction = GDK_SCROLL_DOWN;
|
||||
} else if (aDeltaY > 0) {
|
||||
event.scroll.direction = GDK_SCROLL_UP;
|
||||
} else {
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
gdk_event_put(&event);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
nsresult nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
|
||||
TouchPointerState aPointerState,
|
||||
LayoutDeviceIntPoint aPoint,
|
||||
|
@ -7844,19 +7786,12 @@ nsresult nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsWindow::CSDSupportLevel nsWindow::GetSystemCSDSupportLevel(bool aIsPopup) {
|
||||
if (sCSDSupportLevel != CSD_SUPPORT_UNKNOWN) {
|
||||
return sCSDSupportLevel;
|
||||
}
|
||||
|
||||
// Require GTK 3.10 for GtkHeaderBar support and compatible window manager.
|
||||
if (gtk_check_version(3, 10, 0) != nullptr) {
|
||||
sCSDSupportLevel = CSD_SUPPORT_NONE;
|
||||
return sCSDSupportLevel;
|
||||
}
|
||||
|
||||
// Allow MOZ_GTK_TITLEBAR_DECORATION to override our heuristics
|
||||
const char* decorationOverride = getenv("MOZ_GTK_TITLEBAR_DECORATION");
|
||||
if (decorationOverride) {
|
||||
|
|
|
@ -228,9 +228,7 @@ class nsWindow final : public nsBaseWidget {
|
|||
GtkSelectionData* aSelectionData, guint aInfo,
|
||||
guint aTime, gpointer aData);
|
||||
gboolean OnPropertyNotifyEvent(GtkWidget* aWidget, GdkEventProperty* aEvent);
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
gboolean OnTouchEvent(GdkEventTouch* aEvent);
|
||||
#endif
|
||||
|
||||
virtual already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawingInRegion(
|
||||
LayoutDeviceIntRegion& aInvalidRegion,
|
||||
|
@ -361,14 +359,12 @@ class nsWindow final : public nsBaseWidget {
|
|||
double aDeltaY, double aDeltaZ, uint32_t aModifierFlags,
|
||||
uint32_t aAdditionalFlags, nsIObserver* aObserver) override;
|
||||
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
|
||||
TouchPointerState aPointerState,
|
||||
LayoutDeviceIntPoint aPoint,
|
||||
double aPointerPressure,
|
||||
uint32_t aPointerOrientation,
|
||||
nsIObserver* aObserver) override;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_X11
|
||||
Display* XDisplay() { return mXDisplay; }
|
||||
|
@ -473,10 +469,8 @@ class nsWindow final : public nsBaseWidget {
|
|||
bool mEnabled;
|
||||
// has the native window for this been created yet?
|
||||
bool mCreated;
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
// whether we handle touch event
|
||||
bool mHandleTouchEvent;
|
||||
#endif
|
||||
// true if this is a drag and drop feedback popup
|
||||
bool mIsDragPopup;
|
||||
// Can we access X?
|
||||
|
@ -547,7 +541,6 @@ class nsWindow final : public nsBaseWidget {
|
|||
// Cached result of gdk_window_get_origin which can be expensive.
|
||||
mozilla::Maybe<nsIntPoint> mWindowOrigin;
|
||||
|
||||
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||
// This field omits duplicate scroll events caused by GNOME bug 726878.
|
||||
guint32 mLastScrollEventTime;
|
||||
|
||||
|
@ -556,7 +549,6 @@ class nsWindow final : public nsBaseWidget {
|
|||
// for touch event handling
|
||||
nsRefPtrHashtable<nsPtrHashKey<GdkEventSequence>, mozilla::dom::Touch>
|
||||
mTouches;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_X11
|
||||
Display* mXDisplay;
|
||||
|
|
Загрузка…
Ссылка в новой задаче