mirror of
https://github.com/elementary/gala.git
synced 2024-10-26 07:51:41 +03:00
Reduce the number of warnings
No functional change.
This commit is contained in:
parent
87d51c50fb
commit
4aec79ae0d
@ -36,7 +36,7 @@ namespace Gala {
|
||||
* @param y The global y coordinate where the action was activated
|
||||
* @return A ClutterActor that serves as handle
|
||||
*/
|
||||
public signal Actor drag_begin (float x, float y);
|
||||
public signal Actor? drag_begin (float x, float y);
|
||||
|
||||
/**
|
||||
* A drag has been canceled. You may want to consider cleaning up
|
||||
|
@ -91,12 +91,16 @@ namespace Gala.Plugins.PIP {
|
||||
cr.set_source_surface (buffer.surface, 0, 0);
|
||||
cr.paint ();
|
||||
|
||||
var texture = new Cogl.Texture2D.from_data (context, width, height, Cogl.PixelFormat.BGRA_8888_PRE,
|
||||
surface.get_stride (), surface.get_data ());
|
||||
try {
|
||||
var texture = new Cogl.Texture2D.from_data (context, width, height, Cogl.PixelFormat.BGRA_8888_PRE,
|
||||
surface.get_stride (), surface.get_data ());
|
||||
|
||||
shadow_cache.@set (current_key, new Shadow (texture));
|
||||
|
||||
return texture;
|
||||
shadow_cache.@set (current_key, new Shadow (texture));
|
||||
return texture;
|
||||
} catch (GLib.Error e) {
|
||||
debug (e.message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void decrement_shadow_users (string key) {
|
||||
|
@ -131,25 +131,25 @@ namespace Gala {
|
||||
}
|
||||
}
|
||||
|
||||
void finish_animation (string[] files) {
|
||||
set_loaded ();
|
||||
|
||||
if (files.length > 1)
|
||||
background.set_blend (File.new_for_path (files[0]), File.new_for_path (files[1]), animation.transition_progress, style);
|
||||
else if (files.length > 0)
|
||||
background.set_file (File.new_for_path (files[0]), style);
|
||||
else
|
||||
background.set_file (null, style);
|
||||
|
||||
queue_update_animation ();
|
||||
}
|
||||
|
||||
void update_animation () {
|
||||
update_animation_timeout_id = 0;
|
||||
|
||||
animation.update (display.get_monitor_geometry (monitor_index));
|
||||
var files = animation.key_frame_files;
|
||||
|
||||
Clutter.Callback finish = () => {
|
||||
set_loaded ();
|
||||
|
||||
if (files.length > 1)
|
||||
background.set_blend (File.new_for_path (files[0]), File.new_for_path (files[1]), animation.transition_progress, style);
|
||||
else if (files.length > 0)
|
||||
background.set_file (File.new_for_path (files[0]), style);
|
||||
else
|
||||
background.set_file (null, style);
|
||||
|
||||
queue_update_animation ();
|
||||
};
|
||||
|
||||
var cache = Meta.BackgroundImageCache.get_default ();
|
||||
var num_pending_images = files.length;
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
@ -159,14 +159,16 @@ namespace Gala {
|
||||
|
||||
if (image.is_loaded ()) {
|
||||
num_pending_images--;
|
||||
if (num_pending_images == 0)
|
||||
finish (null);
|
||||
if (num_pending_images == 0) {
|
||||
finish_animation (files);
|
||||
}
|
||||
} else {
|
||||
ulong handler = 0;
|
||||
handler = image.loaded.connect (() => {
|
||||
SignalHandler.disconnect (image, handler);
|
||||
if (--num_pending_images == 0)
|
||||
finish (null);
|
||||
if (--num_pending_images == 0) {
|
||||
finish_animation (files);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,16 @@
|
||||
|
||||
namespace Gala {
|
||||
public class BackgroundSource : Object {
|
||||
// list of keys that are actually relevant for us
|
||||
const string[] OPTIONS = {
|
||||
"color-shading-type",
|
||||
"picture-opacity",
|
||||
"picture-options",
|
||||
"picture-uri",
|
||||
"primary-color",
|
||||
"secondary-color"
|
||||
};
|
||||
|
||||
public signal void changed ();
|
||||
|
||||
public Meta.Display display { get; construct; }
|
||||
@ -25,6 +35,7 @@ namespace Gala {
|
||||
internal int use_count { get; set; default = 0; }
|
||||
|
||||
Gee.HashMap<int,Background> backgrounds;
|
||||
uint[] hash_cache;
|
||||
|
||||
public BackgroundSource (Meta.Display display, string settings_schema) {
|
||||
Object (display: display, settings: new Settings (settings_schema));
|
||||
@ -32,11 +43,23 @@ namespace Gala {
|
||||
|
||||
construct {
|
||||
backgrounds = new Gee.HashMap<int,Background> ();
|
||||
hash_cache = new uint[OPTIONS.length];
|
||||
|
||||
Meta.MonitorManager.@get ().monitors_changed.connect (monitors_changed);
|
||||
|
||||
settings_hash_cache = get_current_settings_hash_cache ();
|
||||
settings.changed.connect (settings_changed);
|
||||
// unfortunately the settings sometimes tend to fire random changes even though
|
||||
// nothing actually happend. The code below is used to prevent us from spamming
|
||||
// new actors all the time, which lead to some problems in other areas of the code
|
||||
for (int i = 0; i < OPTIONS.length; i++) {
|
||||
hash_cache[i] = settings.get_value (OPTIONS[i]).hash ();
|
||||
settings.changed[OPTIONS[i]].connect (() => {
|
||||
uint new_hash = settings.get_value (OPTIONS[i]).hash ();
|
||||
if (new_hash != hash_cache[i]) {
|
||||
hash_cache[i] = new_hash;
|
||||
changed ();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void monitors_changed () {
|
||||
@ -98,51 +121,5 @@ namespace Gala {
|
||||
background.destroy ();
|
||||
}
|
||||
}
|
||||
|
||||
// unfortunately the settings sometimes tend to fire random changes even though
|
||||
// nothing actually happend. The code below is used to prevent us from spamming
|
||||
// new actors all the time, which lead to some problems in other areas of the code
|
||||
|
||||
// helper struct which stores the hash values generated by g_variant_hash
|
||||
struct SettingsHashCache {
|
||||
uint color_shading_type;
|
||||
uint picture_opacity;
|
||||
uint picture_options;
|
||||
uint picture_uri;
|
||||
uint primar_color;
|
||||
uint secondary_color;
|
||||
}
|
||||
|
||||
SettingsHashCache settings_hash_cache;
|
||||
|
||||
// list of keys that are actually relevant for us
|
||||
const string[] OPTIONS = { "color-shading-type", "picture-opacity",
|
||||
"picture-options", "picture-uri", "primary-color", "secondary-color" };
|
||||
|
||||
void settings_changed (string key) {
|
||||
if (!(key in OPTIONS))
|
||||
return;
|
||||
|
||||
var current = get_current_settings_hash_cache ();
|
||||
|
||||
if (Memory.cmp (&settings_hash_cache, ¤t, sizeof (SettingsHashCache)) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Memory.copy (&settings_hash_cache, ¤t, sizeof (SettingsHashCache));
|
||||
|
||||
changed ();
|
||||
}
|
||||
|
||||
SettingsHashCache get_current_settings_hash_cache () {
|
||||
return {
|
||||
settings.get_value ("color-shading-type").hash (),
|
||||
settings.get_value ("picture-opacity").hash (),
|
||||
settings.get_value ("picture-options").hash (),
|
||||
settings.get_value ("picture-uri").hash (),
|
||||
settings.get_value ("primary-color").hash (),
|
||||
settings.get_value ("secondary-color").hash ()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ namespace Gala {
|
||||
|
||||
private DBus () {
|
||||
if (wm.background_group != null)
|
||||
(wm.background_group as BackgroundContainer).changed.connect (() => background_changed ());
|
||||
((BackgroundContainer) wm.background_group).changed.connect (() => background_changed ());
|
||||
else
|
||||
assert_not_reached ();
|
||||
}
|
||||
|
@ -104,11 +104,16 @@ namespace Gala {
|
||||
|
||||
cr.paint ();
|
||||
|
||||
var texture = new Cogl.Texture2D.from_data (context, width, height, Cogl.PixelFormat.BGRA_8888_PRE,
|
||||
surface.get_stride (), surface.get_data ());
|
||||
shadow_cache.@set (current_key, new Shadow (texture));
|
||||
try {
|
||||
var texture = new Cogl.Texture2D.from_data (context, width, height, Cogl.PixelFormat.BGRA_8888_PRE,
|
||||
surface.get_stride (), surface.get_data ());
|
||||
shadow_cache.@set (current_key, new Shadow (texture));
|
||||
|
||||
return texture;
|
||||
return texture;
|
||||
} catch (Error e) {
|
||||
debug (e.message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void decrement_shadow_users (string key) {
|
||||
|
@ -505,7 +505,7 @@ namespace Gala {
|
||||
return false;
|
||||
}
|
||||
|
||||
Actor drag_begin (float click_x, float click_y) {
|
||||
Actor? drag_begin (float click_x, float click_y) {
|
||||
unowned Meta.WorkspaceManager manager = workspace.get_display ().get_workspace_manager ();
|
||||
if (icon_container.get_n_children () < 1 &&
|
||||
Prefs.get_dynamic_workspaces () &&
|
||||
|
@ -49,7 +49,7 @@ namespace Gala {
|
||||
private Clutter.Canvas background_canvas;
|
||||
private static int border_radius;
|
||||
private static Gdk.RGBA color;
|
||||
private static const double COLOR_OPACITY = 0.8;
|
||||
private const double COLOR_OPACITY = 0.8;
|
||||
|
||||
static construct {
|
||||
var label_widget_path = new Gtk.WidgetPath ();
|
||||
|
@ -146,21 +146,19 @@ namespace Gala {
|
||||
});
|
||||
}
|
||||
|
||||
void on_menu_get (GLib.Object? o, GLib.AsyncResult? res) {
|
||||
try {
|
||||
daemon_proxy = Bus.get_proxy.end (res);
|
||||
} catch (Error e) {
|
||||
warning ("Failed to get Menu proxy: %s", e.message);
|
||||
}
|
||||
}
|
||||
|
||||
void lost_daemon () {
|
||||
daemon_proxy = null;
|
||||
}
|
||||
|
||||
void daemon_appeared () {
|
||||
if (daemon_proxy == null) {
|
||||
Bus.get_proxy.begin<Daemon> (BusType.SESSION, DAEMON_DBUS_NAME, DAEMON_DBUS_OBJECT_PATH, 0, null, on_menu_get);
|
||||
Bus.get_proxy.begin<Daemon> (BusType.SESSION, DAEMON_DBUS_NAME, DAEMON_DBUS_OBJECT_PATH, 0, null, (obj, res) => {
|
||||
try {
|
||||
daemon_proxy = Bus.get_proxy.end (res);
|
||||
} catch (Error e) {
|
||||
warning ("Failed to get Menu proxy: %s", e.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -366,11 +364,13 @@ namespace Gala {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
daemon_proxy.show_desktop_menu.begin (x, y);
|
||||
} catch (Error e) {
|
||||
message ("Error invoking MenuManager: %s", e.message);
|
||||
}
|
||||
daemon_proxy.show_desktop_menu.begin (x, y, (obj, res) => {
|
||||
try {
|
||||
((Daemon) obj).show_desktop_menu.end (res);
|
||||
} catch (Error e) {
|
||||
message ("Error invoking MenuManager: %s", e.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void on_monitors_changed () {
|
||||
@ -913,7 +913,7 @@ namespace Gala {
|
||||
workspace.activate (display.get_current_time ());
|
||||
break;
|
||||
case ActionType.SCREENSHOT_CURRENT:
|
||||
screenshot_current_window ();
|
||||
screenshot_current_window.begin ();
|
||||
break;
|
||||
default:
|
||||
warning ("Trying to run unknown action");
|
||||
@ -959,11 +959,13 @@ namespace Gala {
|
||||
if (window.can_close ())
|
||||
flags |= WindowFlags.CAN_CLOSE;
|
||||
|
||||
try {
|
||||
daemon_proxy.show_window_menu.begin (flags, x, y);
|
||||
} catch (Error e) {
|
||||
message ("Error invoking MenuManager: %s", e.message);
|
||||
}
|
||||
daemon_proxy.show_window_menu.begin (flags, x, y, (obj, res) => {
|
||||
try {
|
||||
((Daemon) obj).show_window_menu.end (res);
|
||||
} catch (Error e) {
|
||||
message ("Error invoking MenuManager: %s", e.message);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case Meta.WindowMenuType.APP:
|
||||
// FIXME we don't have any sort of app menus
|
||||
|
Loading…
Reference in New Issue
Block a user