Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/DBus.vala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Gala.DBus {
private static WindowManagerGala wm;

[DBus (visible = false)]
public static void init (WindowManagerGala _wm) {
public static void init (WindowManagerGala _wm, ScreenshotManager screenshot_manager) {
wm = _wm;

Bus.own_name (BusType.SESSION, "org.pantheon.gala", BusNameOwnerFlags.NONE,
Expand All @@ -34,7 +34,7 @@ public class Gala.DBus {
(connection) => {
try {
connection.register_object ("/org/gnome/Shell", DBusAccelerator.init (wm.get_display ()));
connection.register_object ("/org/gnome/Shell/Screenshot", ScreenshotManager.init (wm));
connection.register_object ("/org/gnome/Shell/Screenshot", screenshot_manager);
} catch (Error e) { warning (e.message); }
},
() => {},
Expand Down
20 changes: 6 additions & 14 deletions src/ScreenshotManager.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//
// Copyright (C) 2016 Rico Tzschichholz, Santiago León O.
// 2025 elementary, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand All @@ -21,16 +22,6 @@ namespace Gala {

[DBus (name="org.gnome.Shell.Screenshot")]
public class ScreenshotManager : Object {
private static ScreenshotManager? instance;

[DBus (visible = false)]
public static unowned ScreenshotManager init (WindowManager wm) {
if (instance == null)
instance = new ScreenshotManager (wm);

return instance;
}

private WindowManager wm;
private Settings desktop_settings;

Expand All @@ -39,12 +30,13 @@ namespace Gala {
private string prev_font_mono;
private uint conceal_timeout;

construct {
desktop_settings = new Settings ("org.gnome.desktop.interface");
[DBus (visible = false)]
public ScreenshotManager (WindowManager _wm) {
wm = _wm;
}

private ScreenshotManager (WindowManager _wm) {
wm = _wm;
construct {
desktop_settings = new Settings ("org.gnome.desktop.interface");
}

public void flash_area (int x, int y, int width, int height) throws DBusError, IOError {
Expand Down
10 changes: 5 additions & 5 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//
// Copyright (C) 2012-2014 Tom Beckmann, Rico Tzschichholz
// 2025 elementary, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -71,6 +72,8 @@ namespace Gala {

public WindowTracker? window_tracker { get; private set; }

private ScreenshotManager screenshot_manager;

/**
* Allow to zoom in/out the entire desktop.
*/
Expand Down Expand Up @@ -187,7 +190,8 @@ namespace Gala {
private void show_stage () {
unowned Meta.Display display = get_display ();

DBus.init (this);
screenshot_manager = new ScreenshotManager (this);
DBus.init (this, screenshot_manager);
DBusAccelerator.init (display);
MediaFeedback.init ();

Expand Down Expand Up @@ -2317,7 +2321,6 @@ namespace Gala {
string filename = clipboard ? "" : generate_screenshot_filename ();
bool success = false;
string filename_used = "";
unowned var screenshot_manager = ScreenshotManager.init (this);
yield screenshot_manager.screenshot_window (true, false, true, filename, out success, out filename_used);
} catch (Error e) {
// Ignore this error
Expand All @@ -2330,8 +2333,6 @@ namespace Gala {
bool success = false;
string filename_used = "";

unowned var screenshot_manager = ScreenshotManager.init (this);

int x, y, w, h;
yield screenshot_manager.select_area (out x, out y, out w, out h);
yield screenshot_manager.screenshot_area (x, y, w, h, true, filename, out success, out filename_used);
Expand All @@ -2345,7 +2346,6 @@ namespace Gala {
string filename = clipboard ? "" : generate_screenshot_filename ();
bool success = false;
string filename_used = "";
unowned var screenshot_manager = ScreenshotManager.init (this);
yield screenshot_manager.screenshot (false, true, filename, out success, out filename_used);
} catch (Error e) {
// Ignore this error
Expand Down
Loading