1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:expandtab:shiftwidth=2:tabstop=8:
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "nsGTKRemoteServer.h"
14 #include "mozilla/ModuleUtils.h"
15 #include "nsAppShellCID.h"
19 #include "nsGTKToolkit.h"
22 # include "mozilla/WidgetUtilsGtk.h"
25 nsresult
nsGTKRemoteServer::Startup(const char* aAppName
,
26 const char* aProfileName
) {
27 NS_ASSERTION(aAppName
, "Don't pass a null appname!");
30 return NS_ERROR_ALREADY_INITIALIZED
;
34 if (mozilla::widget::GdkIsWaylandDisplay()) {
35 return NS_ERROR_FAILURE
;
39 XRemoteBaseStartup(aAppName
, aProfileName
);
41 mServerWindow
= gtk_invisible_new();
42 gtk_widget_realize(mServerWindow
);
43 HandleCommandsFor(mServerWindow
);
48 void nsGTKRemoteServer::Shutdown() {
53 gtk_widget_destroy(mServerWindow
);
54 mServerWindow
= nullptr;
57 void nsGTKRemoteServer::HandleCommandsFor(GtkWidget
* widget
) {
58 g_signal_connect(G_OBJECT(widget
), "property_notify_event",
59 G_CALLBACK(HandlePropertyChange
), this);
61 gtk_widget_add_events(widget
, GDK_PROPERTY_CHANGE_MASK
);
63 Window window
= gdk_x11_window_get_xid(gtk_widget_get_window(widget
));
64 nsXRemoteServer::HandleCommandsFor(window
);
67 gboolean
nsGTKRemoteServer::HandlePropertyChange(GtkWidget
* aWidget
,
68 GdkEventProperty
* pevent
,
69 nsGTKRemoteServer
* aThis
) {
70 if (pevent
->state
== GDK_PROPERTY_NEW_VALUE
) {
71 Atom changedAtom
= gdk_x11_atom_to_xatom(pevent
->atom
);
73 XID window
= gdk_x11_window_get_xid(gtk_widget_get_window(aWidget
));
74 return aThis
->HandleNewProperty(
75 window
, GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), pevent
->time
,