Bug 627699 - Port GTK2 to GTK3, gtk-rest. r=karlt

This commit is contained in:
Martin Stransky 2012-09-13 21:56:59 -04:00
parent fa4a000b19
commit 4a163dab88
16 changed files with 151 additions and 94 deletions

View File

@ -177,6 +177,20 @@ gtk_window_group_get_current_grab(GtkWindowGroup *window_group)
return GTK_WIDGET(window_group->grabs->data);
}
static inline GList *
gdk_drag_context_list_targets(GdkDragContext *context)
{
return context->targets;
}
#endif
#if !GTK_CHECK_VERSION(2, 23, 3)
static inline GdkWindow *
gdk_drag_context_get_dest_window(GdkDragContext *context)
{
return context->dest_window;
}
#endif
#if !GTK_CHECK_VERSION(2, 24, 0)

View File

@ -31,6 +31,10 @@
#include <sys/types.h>
#include <unistd.h>
#if (MOZ_WIDGET_GTK == 2)
#include "gtk2compat.h"
#endif
using namespace mozilla;
// Callback when someone asks us for the data
@ -331,8 +335,10 @@ nsClipboard::GetData(nsITransferable *aTransferable, int32_t aWhichClipboard)
continue;
nsCOMPtr<nsIInputStream> byteStream;
NS_NewByteInputStream(getter_AddRefs(byteStream), (const char*)selectionData->data,
selectionData->length, NS_ASSIGNMENT_COPY);
NS_NewByteInputStream(getter_AddRefs(byteStream),
(const char*)gtk_selection_data_get_data(selectionData),
gtk_selection_data_get_length(selectionData),
NS_ASSIGNMENT_COPY);
aTransferable->SetTransferData(flavorStr, byteStream, sizeof(nsIInputStream*));
gtk_selection_data_free(selectionData);
return NS_OK;
@ -344,13 +350,14 @@ nsClipboard::GetData(nsITransferable *aTransferable, int32_t aWhichClipboard)
GtkSelectionData *selectionData;
selectionData = wait_for_contents(clipboard, atom);
if (selectionData) {
length = selectionData->length;
const guchar *clipboardData = gtk_selection_data_get_data(selectionData);
length = gtk_selection_data_get_length(selectionData);
// Special case text/html since we can convert into UCS2
if (!strcmp(flavorStr, kHTMLMime)) {
PRUnichar* htmlBody= nullptr;
int32_t htmlBodyLen = 0;
// Convert text/html into our unicode format
ConvertHTMLtoUCS2((guchar *)selectionData->data, length,
ConvertHTMLtoUCS2(const_cast<guchar*>(clipboardData), length,
&htmlBody, htmlBodyLen);
// Try next data format?
if (!htmlBodyLen)
@ -361,7 +368,7 @@ nsClipboard::GetData(nsITransferable *aTransferable, int32_t aWhichClipboard)
data = (guchar *)nsMemory::Alloc(length);
if (!data)
break;
memcpy(data, selectionData->data, length);
memcpy(data, clipboardData, length);
}
foundData = true;
foundFlavor = flavorStr;
@ -513,9 +520,10 @@ nsClipboard::SelectionGetEvent(GtkClipboard *aClipboard,
int32_t whichClipboard;
// which clipboard?
if (aSelectionData->selection == GDK_SELECTION_PRIMARY)
GdkAtom selection = gtk_selection_data_get_selection(aSelectionData);
if (selection == GDK_SELECTION_PRIMARY)
whichClipboard = kSelectionClipboard;
else if (aSelectionData->selection == GDK_SELECTION_CLIPBOARD)
else if (selection == GDK_SELECTION_CLIPBOARD)
whichClipboard = kGlobalClipboard;
else
return; // THAT AIN'T NO CLIPBOARD I EVER HEARD OF
@ -534,12 +542,15 @@ nsClipboard::SelectionGetEvent(GtkClipboard *aClipboard,
nsCOMPtr<nsISupports> item;
uint32_t len;
GdkAtom selectionTarget = gtk_selection_data_get_target(aSelectionData);
// Check to see if the selection data includes any of the string
// types that we support.
if (aSelectionData->target == gdk_atom_intern ("STRING", FALSE) ||
aSelectionData->target == gdk_atom_intern ("TEXT", FALSE) ||
aSelectionData->target == gdk_atom_intern ("COMPOUND_TEXT", FALSE) ||
aSelectionData->target == gdk_atom_intern ("UTF8_STRING", FALSE)) {
if (selectionTarget == gdk_atom_intern ("STRING", FALSE) ||
selectionTarget == gdk_atom_intern ("TEXT", FALSE) ||
selectionTarget == gdk_atom_intern ("COMPOUND_TEXT", FALSE) ||
selectionTarget == gdk_atom_intern ("UTF8_STRING", FALSE)) {
// Try to convert our internal type into a text string. Get
// the transferable for this clipboard and try to get the
// text/unicode type for it.
@ -567,7 +578,7 @@ nsClipboard::SelectionGetEvent(GtkClipboard *aClipboard,
}
// Check to see if the selection data is an image type
if (gtk_targets_include_image(&aSelectionData->target, 1, TRUE)) {
if (gtk_targets_include_image(&selectionTarget, 1, TRUE)) {
// Look through our transfer data for the image
static const char* const imageMimeTypes[] = {
kNativeImageMime, kPNGImageMime, kJPEGImageMime, kJPGImageMime, kGIFImageMime };
@ -598,7 +609,7 @@ nsClipboard::SelectionGetEvent(GtkClipboard *aClipboard,
// Try to match up the selection data target to something our
// transferable provides.
gchar *target_name = gdk_atom_name(aSelectionData->target);
gchar *target_name = gdk_atom_name(selectionTarget);
if (!target_name)
return;
@ -615,7 +626,7 @@ nsClipboard::SelectionGetEvent(GtkClipboard *aClipboard,
if (primitive_data) {
// Check to see if the selection data is text/html
if (aSelectionData->target == gdk_atom_intern (kHTMLMime, FALSE)) {
if (selectionTarget == gdk_atom_intern (kHTMLMime, FALSE)) {
/*
* "text/html" can be encoded UCS2. It is recommended that
* documents transmitted as UCS2 always begin with a ZERO-WIDTH
@ -635,7 +646,7 @@ nsClipboard::SelectionGetEvent(GtkClipboard *aClipboard,
len += sizeof(prefix);
}
gtk_selection_data_set(aSelectionData, aSelectionData->target,
gtk_selection_data_set(aSelectionData, selectionTarget,
8, /* 8 bits in a unit */
(const guchar *)primitive_data, len);
nsMemory::Free(primitive_data);
@ -816,7 +827,7 @@ DispatchSelectionNotifyEvent(GtkWidget *widget, XEvent *xevent)
{
GdkEvent event;
event.selection.type = GDK_SELECTION_NOTIFY;
event.selection.window = widget->window;
event.selection.window = gtk_widget_get_window(widget);
event.selection.selection = gdk_x11_xatom_to_atom(xevent->xselection.selection);
event.selection.target = gdk_x11_xatom_to_atom(xevent->xselection.target);
event.selection.property = gdk_x11_xatom_to_atom(xevent->xselection.property);
@ -828,10 +839,11 @@ DispatchSelectionNotifyEvent(GtkWidget *widget, XEvent *xevent)
static void
DispatchPropertyNotifyEvent(GtkWidget *widget, XEvent *xevent)
{
if (((GdkWindowObject *) widget->window)->event_mask & GDK_PROPERTY_CHANGE_MASK) {
GdkWindow *window = gtk_widget_get_window(widget);
if ((gdk_window_get_events(window)) & GDK_PROPERTY_CHANGE_MASK) {
GdkEvent event;
event.property.type = GDK_PROPERTY_NOTIFY;
event.property.window = widget->window;
event.property.window = window;
event.property.atom = gdk_x11_xatom_to_atom(xevent->xproperty.atom);
event.property.time = xevent->xproperty.time;
event.property.state = xevent->xproperty.state;
@ -855,7 +867,9 @@ checkEventProc(Display *display, XEvent *event, XPointer arg)
(event->xany.type == PropertyNotify &&
event->xproperty.atom == context->selAtom)) {
GdkWindow *cbWindow = gdk_window_lookup(event->xany.window);
GdkWindow *cbWindow =
gdk_x11_window_lookup_for_display(gdk_x11_lookup_xdisplay(display),
event->xany.window);
if (cbWindow) {
GtkWidget *cbWidget = NULL;
gdk_window_get_user_data(cbWindow, (gpointer *)&cbWidget);
@ -878,7 +892,7 @@ wait_for_retrieval(GtkClipboard *clipboard, retrieval_context *r_context)
if (r_context->completed) // the request completed synchronously
return true;
Display *xDisplay = GDK_DISPLAY();
Display *xDisplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()) ;
checkEventContext context;
context.cbWidget = NULL;
context.selAtom = gdk_x11_atom_to_xatom(gdk_atom_intern("GDK_SELECTION",
@ -937,7 +951,7 @@ clipboard_contents_received(GtkClipboard *clipboard,
context->completed = true;
if (selection_data->length >= 0)
if (gtk_selection_data_get_length(selection_data) >= 0)
context->data = gtk_selection_data_copy(selection_data);
}

View File

@ -16,8 +16,12 @@
#include "nsCRT.h" /* should be <limits.h>? */
#include <gtk/gtk.h>
#if (MOZ_WIDGET_GTK == 2)
#include <gtk/gtkprinter.h>
#include <gtk/gtkprintjob.h>
#else
#include <gtk/gtkunixprint.h>
#endif
#define NS_PORTRAIT 0
#define NS_LANDSCAPE 1

View File

@ -25,7 +25,7 @@
#include "nsCRT.h"
#include "mozilla/Services.h"
#if defined(MOZ_WIDGET_GTK2)
#if (MOZ_WIDGET_GTK == 2)
#include "gtk2compat.h"
#endif
@ -351,7 +351,7 @@ nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
GdkEvent event;
memset(&event, 0, sizeof(GdkEvent));
event.type = GDK_BUTTON_PRESS;
event.button.window = mHiddenWidget->window;
event.button.window = gtk_widget_get_window(mHiddenWidget);
event.button.time = nsWindow::GetLastUserInputTime();
// Put the drag widget in the window group of the source node so that the
@ -362,6 +362,13 @@ nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
gtk_window_group_add_window(window_group,
GTK_WINDOW(mHiddenWidget));
#if (MOZ_WIDGET_GTK == 3)
// Get device for event source
GdkDisplay *display = gdk_display_get_default();
GdkDeviceManager *device_manager = gdk_display_get_device_manager(display);
event.button.device = gdk_device_manager_get_client_pointer(device_manager);
#endif
// start our drag.
GdkDragContext *context = gtk_drag_begin(mHiddenWidget,
sourceList,
@ -402,6 +409,7 @@ nsDragService::SetAlphaPixmap(gfxASurface *aSurface,
int32_t aYOffset,
const nsIntRect& dragRect)
{
#if (MOZ_WIDGET_GTK == 2)
GdkScreen* screen = gtk_widget_get_screen(mHiddenWidget);
// Transparent drag icons need, like a lot of transparency-related things,
@ -443,6 +451,10 @@ nsDragService::SetAlphaPixmap(gfxASurface *aSurface,
aXOffset, aYOffset);
g_object_unref(pixmap);
return true;
#else
// TODO GTK3
return false;
#endif
}
NS_IMETHODIMP
@ -974,7 +986,8 @@ nsDragService::IsDataFlavorSupported(const char *aDataFlavor,
// check the target context vs. this flavor, one at a time
GList *tmp;
for (tmp = mTargetDragContext->targets; tmp; tmp = tmp->next) {
for (tmp = gdk_drag_context_list_targets(mTargetDragContext);
tmp; tmp = tmp->next) {
/* Bug 331198 */
GdkAtom atom = GDK_POINTER_TO_ATOM(tmp->data);
gchar *name = NULL;
@ -1058,15 +1071,16 @@ nsDragService::TargetDataReceived(GtkWidget *aWidget,
PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::TargetDataReceived"));
TargetResetData();
mTargetDragDataReceived = true;
if (aSelectionData->length > 0) {
mTargetDragDataLen = aSelectionData->length;
mTargetDragDataLen = gtk_selection_data_get_length(aSelectionData);
if (mTargetDragDataLen > 0) {
mTargetDragData = g_malloc(mTargetDragDataLen);
memcpy(mTargetDragData, aSelectionData->data, mTargetDragDataLen);
memcpy(mTargetDragData, gtk_selection_data_get_data(aSelectionData),
mTargetDragDataLen);
}
else {
PR_LOG(sDragLm, PR_LOG_DEBUG,
("Failed to get data. selection data len was %d\n",
aSelectionData->length));
mTargetDragDataLen));
}
}
@ -1086,7 +1100,8 @@ nsDragService::IsTargetContextList(void)
// walk the list of context targets and see if one of them is a list
// of items.
for (tmp = mTargetDragContext->targets; tmp; tmp = tmp->next) {
for (tmp = gdk_drag_context_list_targets(mTargetDragContext);
tmp; tmp = tmp->next) {
/* Bug 331198 */
GdkAtom atom = GDK_POINTER_TO_ATOM(tmp->data);
gchar *name = NULL;
@ -1363,7 +1378,8 @@ nsDragService::SourceEndDragSession(GdkDragContext *aContext,
// cancelled (but no drag-failed signal would have been sent).
// aContext->dest_window will be non-NULL only if the drop was sent.
GdkDragAction action =
aContext->dest_window ? aContext->action : (GdkDragAction)0;
gdk_drag_context_get_dest_window(aContext) ?
gdk_drag_context_get_actions(aContext) : (GdkDragAction)0;
// Only one bit of action should be set, but, just in case someone
// does something funny, erring away from MOVE, and not recording
@ -1556,7 +1572,7 @@ nsDragService::SourceDataGet(GtkWidget *aWidget,
if (tmpData) {
// this copies the data
gtk_selection_data_set(aSelectionData,
aSelectionData->target,
gtk_selection_data_get_target(aSelectionData),
8,
(guchar *)tmpData, tmpDataLen);
// this wasn't allocated with glib
@ -1569,7 +1585,7 @@ nsDragService::SourceDataGet(GtkWidget *aWidget,
gint length;
CreateUriList(mSourceDataItems, &uriList, &length);
gtk_selection_data_set(aSelectionData,
aSelectionData->target,
gtk_selection_data_get_target(aSelectionData),
8, (guchar *)uriList, length);
g_free(uriList);
return;

View File

@ -433,8 +433,9 @@ nsFilePicker::Open(nsIFilePickerShownCallback *aCallback)
gtk_window_set_modal(window, TRUE);
if (parent_widget) {
gtk_window_set_destroy_with_parent(window, TRUE);
if (parent_widget->group) {
gtk_window_group_add_window(parent_widget->group, window);
GtkWindowGroup *parentGroup = gtk_window_get_group(parent_widget);
if (parentGroup) {
gtk_window_group_add_window(parentGroup, window);
}
}

View File

@ -21,7 +21,6 @@ class nsGTKToolkit
{
public:
nsGTKToolkit();
virtual ~nsGTKToolkit();
static nsGTKToolkit* GetToolkit();
@ -30,9 +29,6 @@ public:
gToolkit = nullptr;
}
void CreateSharedGC(void);
GdkGC *GetSharedGC(void);
/**
* Get/set our value of DESKTOP_STARTUP_ID. When non-empty, this is applied
* to the next toplevel window to be shown or focused (and then immediately
@ -51,7 +47,6 @@ public:
private:
static nsGTKToolkit* gToolkit;
GdkGC *mSharedGC;
nsCString mDesktopStartupID;
uint32_t mFocusTimestamp;
};

View File

@ -24,6 +24,10 @@
#include "mozilla/Services.h"
#endif
#if (MOZ_WIDGET_GTK == 2)
#include "gtk2compat.h"
#endif
using namespace mozilla;
using namespace mozilla::widget;
@ -101,7 +105,7 @@ nsGtkIMModule::Init()
MozContainer* container = mOwnerWindow->GetMozContainer();
NS_PRECONDITION(container, "container is null");
GdkWindow* gdkWindow = GTK_WIDGET(container)->window;
GdkWindow* gdkWindow = gtk_widget_get_window(GTK_WIDGET(container));
// NOTE: gtk_im_*_new() abort (kill) the whole process when it fails.
// So, we don't need to check the result.
@ -255,7 +259,11 @@ nsGtkIMModule::PrepareToDestroyContext(GtkIMContext *aContext)
NS_PRECONDITION(container, "The container of the window is null");
GtkIMMulticontext *multicontext = GTK_IM_MULTICONTEXT(aContext);
#if (MOZ_WIDGET_GTK == 2)
GtkIMContext *slave = multicontext->slave;
#else
GtkIMContext *slave = NULL; //TODO GTK3
#endif
if (!slave) {
return;
}

View File

@ -18,6 +18,9 @@
#ifdef MOZ_X11
#include <gdk/gdkx.h>
#endif /* MOZ_X11 */
#if (MOZ_WIDGET_GTK == 3)
#include <gdk/gdkkeysyms-compat.h>
#endif
#include "nsGUIEvent.h"
#include "WidgetUtils.h"
#include "keysym2ucs.h"

View File

@ -5,12 +5,16 @@
* 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/. */
#include <gtk/gtk.h>
#include "nsIdleServiceGTK.h"
#include "nsIServiceManager.h"
#include "nsDebug.h"
#include "prlink.h"
#include "prlog.h"
#if (MOZ_WIDGET_GTK == 2)
#include "gtk2compat.h"
#endif
#ifdef PR_LOGGING
static PRLogModuleInfo* sIdleLog = nullptr;
@ -102,7 +106,7 @@ nsIdleServiceGTK::PollIdleTime(uint32_t *aIdleTime)
*aIdleTime = 0;
// We might not have a display (cf. in xpcshell)
Display *dplay = GDK_DISPLAY();
Display *dplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
if (!dplay) {
#ifdef PR_LOGGING
PR_LOG(sIdleLog, PR_LOG_WARNING, ("No display found!\n"));

View File

@ -308,9 +308,13 @@ nsNativeKeyBindings::KeyPressInternal(const nsNativeKeyEvent& aEvent,
gCurrentCallbackData = aCallbackData;
gHandled = false;
#if (MOZ_WIDGET_GTK == 2)
gtk_bindings_activate(GTK_OBJECT(mNativeTarget),
aKeyCode, GdkModifierType(modifiers));
#else
gtk_bindings_activate(G_OBJECT(mNativeTarget),
aKeyCode, GdkModifierType(modifiers));
#endif
gCurrentCallback = nullptr;
gCurrentCallbackData = nullptr;

View File

@ -4,7 +4,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <gtk/gtk.h>
#if (MOZ_WIDGET_GTK == 2)
#include <gtk/gtkprintunixdialog.h>
#include "gtk2compat.h"
#else
#include <gtk/gtkunixprint.h>
#endif
#include <stdlib.h>
#include "mozilla/Util.h"
@ -77,7 +82,11 @@ ShowCustomDialog(GtkComboBox *changed_box, gpointer user_data)
printBundle->GetStringFromName(NS_LITERAL_STRING("headerFooterCustom").get(), getter_Copies(intlString));
GtkWidget* prompt_dialog = gtk_dialog_new_with_buttons(NS_ConvertUTF16toUTF8(intlString).get(), printDialog,
#if (MOZ_WIDGET_GTK == 2)
(GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR),
#else
(GtkDialogFlags)(GTK_DIALOG_MODAL),
#endif
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
NULL);
@ -110,7 +119,8 @@ ShowCustomDialog(GtkComboBox *changed_box, gpointer user_data)
gtk_container_set_border_width(GTK_CONTAINER(custom_hbox), 2);
gtk_widget_show_all(custom_hbox);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(prompt_dialog)->vbox), custom_hbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(prompt_dialog))),
custom_hbox, FALSE, FALSE, 0);
gint diag_response = gtk_dialog_run(GTK_DIALOG(prompt_dialog));
if (diag_response == GTK_RESPONSE_ACCEPT) {
@ -481,14 +491,23 @@ nsPrintDialogWidgetGTK::ExportSettings(nsIPrintSettings *aNSSettings)
GtkWidget*
nsPrintDialogWidgetGTK::ConstructHeaderFooterDropdown(const PRUnichar *currentString)
{
#if (MOZ_WIDGET_GTK == 2)
GtkWidget* dropdown = gtk_combo_box_new_text();
#else
GtkWidget* dropdown = gtk_combo_box_text_new();
#endif
const char hf_options[][22] = {"headerFooterBlank", "headerFooterTitle",
"headerFooterURL", "headerFooterDate",
"headerFooterPage", "headerFooterPageTotal",
"headerFooterCustom"};
for (unsigned int i = 0; i < ArrayLength(hf_options); i++) {
#if (MOZ_WIDGET_GTK == 2)
gtk_combo_box_append_text(GTK_COMBO_BOX(dropdown), GetUTF8FromBundle(hf_options[i]).get());
#else
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(dropdown), NULL,
GetUTF8FromBundle(hf_options[i]).get());
#endif
}
bool shouldBeCustom = true;

View File

@ -11,8 +11,12 @@
extern "C" {
#include <gtk/gtk.h>
#if (MOZ_WIDGET_GTK == 2)
#include <gtk/gtkprinter.h>
#include <gtk/gtkprintjob.h>
#else
#include <gtk/gtkunixprint.h>
#endif
}
#define NS_PRINTSETTINGSGTK_IID \

View File

@ -11,6 +11,9 @@
#include <X11/Xatom.h>
#endif
#include <gtk/gtk.h>
#if (MOZ_WIDGET_GTK == 2)
#include "gtk2compat.h"
#endif
nsScreenGtk :: nsScreenGtk ( )
: mScreenNum(0),
@ -54,8 +57,8 @@ nsScreenGtk :: GetAvailRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth
NS_IMETHODIMP
nsScreenGtk :: GetPixelDepth(int32_t *aPixelDepth)
{
GdkVisual * rgb_visual = gdk_rgb_get_visual();
*aPixelDepth = rgb_visual->depth;
GdkVisual * visual = gdk_screen_get_system_visual(gdk_screen_get_default());
*aPixelDepth = gdk_visual_get_depth(visual);
return NS_OK;

View File

@ -132,9 +132,9 @@ nsScreenManagerGtk :: Init()
PR_FindFunctionSymbol(mXineramalib, "XineramaQueryScreens");
// get the number of screens via xinerama
if (_XnrmIsActive && _XnrmQueryScreens &&
_XnrmIsActive(GDK_DISPLAY())) {
screenInfo = _XnrmQueryScreens(GDK_DISPLAY(), &numScreens);
Display *display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
if (_XnrmIsActive && _XnrmQueryScreens && _XnrmIsActive(display)) {
screenInfo = _XnrmQueryScreens(display, &numScreens);
}
}
@ -297,11 +297,18 @@ nsScreenManagerGtk :: ScreenForNativeWidget (void *aWidget, nsIScreen **outScree
if (mCachedScreenArray.Count() > 1) {
// I don't know how to go from GtkWindow to nsIScreen, especially
// given xinerama and stuff, so let's just do this
gint x, y, width, height, depth;
gint x, y, width, height;
#if (MOZ_WIDGET_GTK == 2)
gint depth;
#endif
x = y = width = height = 0;
#if (MOZ_WIDGET_GTK == 2)
gdk_window_get_geometry(GDK_WINDOW(aWidget), &x, &y, &width, &height,
&depth);
#else
gdk_window_get_geometry(GDK_WINDOW(aWidget), &x, &y, &width, &height);
#endif
gdk_window_get_origin(GDK_WINDOW(aWidget), &x, &y);
rv = ScreenForRect(x, y, width, height, outScreen);
} else {

View File

@ -16,38 +16,8 @@ nsGTKToolkit* nsGTKToolkit::gToolkit = nullptr;
//
//-------------------------------------------------------------------------
nsGTKToolkit::nsGTKToolkit()
: mSharedGC(nullptr), mFocusTimestamp(0)
: mFocusTimestamp(0)
{
CreateSharedGC();
}
//-------------------------------------------------------------------------
//
// destructor
//
//-------------------------------------------------------------------------
nsGTKToolkit::~nsGTKToolkit()
{
if (mSharedGC) {
g_object_unref(mSharedGC);
}
}
void nsGTKToolkit::CreateSharedGC(void)
{
GdkPixmap *pixmap;
if (mSharedGC)
return;
pixmap = gdk_pixmap_new(NULL, 1, 1, gdk_rgb_get_visual()->depth);
mSharedGC = gdk_gc_new(pixmap);
g_object_unref(pixmap);
}
GdkGC *nsGTKToolkit::GetSharedGC(void)
{
return (GdkGC *)g_object_ref(mSharedGC);
}
//-------------------------------------------------------------------------------

View File

@ -26,7 +26,7 @@
#include "nsGtkCursors.h"
#include <gtk/gtk.h>
#if defined(MOZ_WIDGET_GTK3)
#if (MOZ_WIDGET_GTK == 3)
#include <gtk/gtkx.h>
#endif
#ifdef MOZ_X11
@ -34,7 +34,7 @@
#include <X11/Xatom.h>
#include <X11/extensions/XShm.h>
#include <X11/extensions/shape.h>
#if defined(MOZ_WIDGET_GTK3)
#if (MOZ_WIDGET_GTK == 3)
#include <gdk/gdkkeysyms-compat.h>
#endif
@ -44,7 +44,9 @@
#include <X11/XF86keysym.h>
#endif
#if (MOZ_WIDGET_GTK == 2)
#include "gtk2xtbin.h"
#endif
#endif /* MOZ_X11 */
#include <gdk/gdkkeysyms.h>
#if defined(MOZ_WIDGET_GTK2)
@ -1681,17 +1683,6 @@ nsWindow::GetNativeData(uint32_t aDataType)
#endif /* MOZ_X11 */
break;
case NS_NATIVE_GRAPHIC: {
#if defined(MOZ_WIDGET_GTK2)
nsGTKToolkit* toolkit = nsGTKToolkit::GetToolkit();
NS_ASSERTION(nullptr != toolkit, "NULL toolkit, unable to get a GC");
return toolkit->GetSharedGC();
#else
return nullptr;
#endif
break;
}
case NS_NATIVE_SHELLWIDGET:
return (void *) mShell;