Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 39 additions & 6 deletions ddterm/app/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ import { TerminalCommand, WIFEXITED, WEXITSTATUS, WTERMSIG } from './terminal.js
import { TerminalSettings, TerminalSettingsParser } from './terminalsettings.js';
import { PrefsDialog } from '../pref/dialog.js';
import { DisplayConfig } from '../util/displayconfig.js';
import {
create_extension_dbus_proxy,
create_extension_dbus_proxy_oneshot,
} from './extensiondbus.js';

function try_require(namespace, version = undefined) {
try {
Expand Down Expand Up @@ -63,6 +59,32 @@ function is_dbus_interface_error(ex) {
ex.matches(Gio.DBusError.quark(), Gio.DBusError.UNKNOWN_INTERFACE);
}

function create_extension_dbus_proxy(connection) {
const url = GLib.Uri.resolve_relative(
import.meta.url,
'../../data/com.github.amezin.ddterm.Extension.xml',
GLib.UriFlags.NONE
);

const [path] = GLib.filename_from_uri(url);
const [, bytes] = GLib.file_get_contents(path);
const info = Gio.DBusInterfaceInfo.new_for_xml(new TextDecoder().decode(bytes));
const flags =
Gio.DBusProxyFlags.DO_NOT_AUTO_START |
Gio.DBusProxyFlags.GET_INVALIDATED_PROPERTIES |
Gio.DBusProxyFlags.DO_NOT_CONNECT_SIGNALS;

return Gio.DBusProxy.new_sync(
connection,
flags,
info,
info.name,
'/org/gnome/Shell/Extensions/ddterm',
'com.github.amezin.ddterm.Extension',
null
);
}

export const Application = GObject.registerClass({
Properties: {
'window': GObject.ParamSpec.object(
Expand Down Expand Up @@ -319,7 +341,8 @@ class Application extends Gtk.Application {
desktop_settings,
}).bind_settings(this.terminal_settings);

this.extension_dbus = create_extension_dbus_proxy();
this.extension_dbus = create_extension_dbus_proxy(this.get_dbus_connection());

this.display_config = new DisplayConfig({
dbus_connection: this.get_dbus_connection(),
});
Expand Down Expand Up @@ -474,7 +497,17 @@ class Application extends Gtk.Application {
this.flags |= Gio.ApplicationFlags.IS_LAUNCHER;

try {
create_extension_dbus_proxy_oneshot().ServiceSync();
Gio.DBus.session.call_sync(
'org.gnome.Shell',
'/org/gnome/Shell/Extensions/ddterm',
'com.github.amezin.ddterm.Extension',
'Service',
null,
null,
Gio.DBusCallFlags.NO_AUTO_START,
-1,
null
);
} catch (ex) {
if (is_dbus_interface_error(ex)) {
printerr(Gettext.gettext("Can't contact the extension."));
Expand Down
13 changes: 8 additions & 5 deletions ddterm/app/appwindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,21 +599,24 @@ class DDTermAppWindow extends Gtk.ApplicationWindow {
this.unmaximize();
}

const rect = this.extension_dbus.TargetRect;
const rect = this.extension_dbus.get_cached_property('TargetRect');

if (!rect)
return;

let [, , target_w, target_h] = rect;
let target_w = rect.get_child_value(2).get_int32();
let target_h = rect.get_child_value(3).get_int32();

if (this.display_config.layout_mode !== LayoutMode.LOGICAL) {
const scale = this.extension_dbus.TargetMonitorScale;
const scale = this.extension_dbus.get_cached_property('TargetMonitorScale');

if (!scale)
return;

target_w = Math.floor(target_w / scale);
target_h = Math.floor(target_h / scale);
const scale_unpacked = scale.get_double();

target_w = Math.floor(target_w / scale_unpacked);
target_h = Math.floor(target_h / scale_unpacked);
}

this.resize(target_w, target_h);
Expand Down
52 changes: 0 additions & 52 deletions ddterm/app/extensiondbus.js

This file was deleted.

1 change: 0 additions & 1 deletion ddterm/app/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ app_js_src_files = files(
'accellabel.js',
'application.js',
'appwindow.js',
'extensiondbus.js',
'init.js',
'meta.js',
'notebook.js',
Expand Down
Loading