summaryrefslogtreecommitdiff
path: root/src/renderers/pieWindow.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderers/pieWindow.vala')
-rw-r--r--src/renderers/pieWindow.vala69
1 files changed, 46 insertions, 23 deletions
diff --git a/src/renderers/pieWindow.vala b/src/renderers/pieWindow.vala
index 59117df..0a26110 100644
--- a/src/renderers/pieWindow.vala
+++ b/src/renderers/pieWindow.vala
@@ -32,6 +32,19 @@ public class PieWindow : Gtk.Window {
public signal void on_closing();
/////////////////////////////////////////////////////////////////////
+ /// Signal which gets emitted when the PieWindow is closed.
+ /////////////////////////////////////////////////////////////////////
+
+ public signal void on_closed();
+
+ /////////////////////////////////////////////////////////////////////
+ /// The background image used for fake transparency if
+ /// has_compositing is false.
+ /////////////////////////////////////////////////////////////////////
+
+ public Image background { get; private set; default=null; }
+
+ /////////////////////////////////////////////////////////////////////
/// The owned renderer.
/////////////////////////////////////////////////////////////////////
@@ -56,13 +69,6 @@ public class PieWindow : Gtk.Window {
private bool has_compositing = false;
/////////////////////////////////////////////////////////////////////
- /// The background image used for fake transparency if
- /// has_compositing is false.
- /////////////////////////////////////////////////////////////////////
-
- private Image background = null;
-
- /////////////////////////////////////////////////////////////////////
/// C'tor, sets up the window.
/////////////////////////////////////////////////////////////////////
@@ -73,7 +79,7 @@ public class PieWindow : Gtk.Window {
this.set_skip_taskbar_hint(true);
this.set_skip_pager_hint(true);
this.set_keep_above(true);
- this.set_type_hint(Gdk.WindowTypeHint.SPLASHSCREEN);
+ this.set_type_hint(Gdk.WindowTypeHint.UTILITY);
this.set_decorated(false);
this.set_resizable(false);
this.icon_name = "gnome-pie";
@@ -81,7 +87,11 @@ public class PieWindow : Gtk.Window {
// check for compositing
if (this.screen.is_composited()) {
- this.set_colormap(this.screen.get_rgba_colormap());
+ #if HAVE_GTK_3
+ this.set_visual(this.screen.get_rgba_visual());
+ #else
+ this.set_colormap(this.screen.get_rgba_colormap());
+ #endif
this.has_compositing = true;
}
@@ -128,9 +138,18 @@ public class PieWindow : Gtk.Window {
this.renderer.on_mouse_move();
return true;
});
+
+ this.show.connect_after(() => {
+ Gtk.grab_add(this);
+ FocusGrabber.grab(this.get_window(), true, true, false);
+ });
// draw the pie on expose
- this.expose_event.connect(this.draw);
+ #if HAVE_GTK_3
+ this.draw.connect(this.draw_window);
+ #else
+ this.expose_event.connect(this.draw_window);
+ #endif
}
/////////////////////////////////////////////////////////////////////
@@ -139,7 +158,7 @@ public class PieWindow : Gtk.Window {
public void load_pie(Pie pie) {
this.renderer.load_pie(pie);
- this.set_window_position();
+ this.set_window_position(pie);
this.set_size_request(renderer.size, renderer.size);
}
@@ -160,7 +179,6 @@ public class PieWindow : Gtk.Window {
// capture the input focus
this.show();
- FocusGrabber.grab(this);
// start the timer
this.timer = new GLib.Timer();
@@ -178,10 +196,13 @@ public class PieWindow : Gtk.Window {
/// Draw the Pie.
/////////////////////////////////////////////////////////////////////
- private bool draw(Gtk.Widget da, Gdk.EventExpose event) {
- // clear the window
- var ctx = Gdk.cairo_create(this.window);
-
+ #if HAVE_GTK_3
+ private bool draw_window(Cairo.Context ctx) {
+ #else
+ private bool draw_window(Gtk.Widget da, Gdk.EventExpose event) {
+ // clear the window
+ var ctx = Gdk.cairo_create(this.get_window());
+ #endif
// paint the background image if there is no compositing
if (this.has_compositing) {
ctx.set_operator (Cairo.Operator.CLEAR);
@@ -219,12 +240,13 @@ public class PieWindow : Gtk.Window {
if (!this.closing) {
this.closing = true;
this.on_closing();
- FocusGrabber.ungrab(this);
+ Gtk.grab_remove(this);
+ FocusGrabber.ungrab();
this.renderer.activate();
Timeout.add((uint)(Config.global.theme.fade_out_time*1000), () => {
+ this.on_closed();
this.destroy();
- ThemedIcon.clear_cache();
return false;
});
}
@@ -238,12 +260,13 @@ public class PieWindow : Gtk.Window {
if (!this.closing) {
this.closing = true;
this.on_closing();
- FocusGrabber.ungrab(this);
+ Gtk.grab_remove(this);
+ FocusGrabber.ungrab();
this.renderer.cancel();
Timeout.add((uint)(Config.global.theme.fade_out_time*1000), () => {
+ this.on_closed();
this.destroy();
- ThemedIcon.clear_cache();
return false;
});
}
@@ -254,9 +277,9 @@ public class PieWindow : Gtk.Window {
/// the mouse.
/////////////////////////////////////////////////////////////////////
- private void set_window_position() {
- if(Config.global.open_at_mouse) this.set_position(Gtk.WindowPosition.MOUSE);
- else this.set_position(Gtk.WindowPosition.CENTER);
+ private void set_window_position(Pie pie) {
+ if(PieManager.get_is_centered(pie.id)) this.set_position(Gtk.WindowPosition.CENTER);
+ else this.set_position(Gtk.WindowPosition.MOUSE);
}
/////////////////////////////////////////////////////////////////////