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
2 changes: 0 additions & 2 deletions data/styles/Application.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ panel {
}

panel > box {
/* Keep in sync with Panel.vala height request */
min-height: 30px;
/*Don't transition shadow etc to avoid visual issues with struts*/
transition: background 200ms cubic-bezier(0.4, 0, 0.2, 1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/DBus/ShellKeyGrabber.vala
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public struct Accelerator {

[DBus (name = "org.gnome.Shell")]
public interface Wingpanel.ShellKeyGrabber : GLib.Object {
public abstract signal void accelerator_activated (uint action, GLib.HashTable<string, GLib.Variant> parameters_dict);
public signal void accelerator_activated (uint action, GLib.HashTable<string, GLib.Variant> parameters_dict);

public abstract uint grab_accelerator (string accelerator, ActionMode mode_flags, Meta.KeyBindingFlags grab_flags) throws GLib.DBusError, GLib.IOError;
public abstract uint[] grab_accelerators (Accelerator[] accelerators) throws GLib.DBusError, GLib.IOError;
Expand Down
101 changes: 71 additions & 30 deletions src/PanelWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,43 @@
*/

public class Wingpanel.PanelWindow : Gtk.Window {
private class BottomMargin : Gtk.Widget {
public const int SIZE = 64;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reasoning behind this particular number?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copied it from the Dock. It can be a lot lower (like 20), but it shouldn't affect anything


construct {
height_request = SIZE;
}
}

public Services.PopoverManager popover_manager;

private Widgets.Panel panel;
private int panel_height;

private Pantheon.Desktop.Shell? desktop_shell;
private Pantheon.Desktop.Panel? desktop_panel;
private bool initialized_background_manager = false;

private Gtk.CssProvider? style_provider = null;

public PanelWindow (Gtk.Application application) {
Object (
application: application,
decorated: false,
resizable: false,
vexpand: false
resizable: false
);

popover_manager = new Services.PopoverManager ();

panel = new Widgets.Panel (popover_manager);
panel.realize.connect (on_realize);

var box = new Gtk.Box (VERTICAL, 0);
box.append (panel);
box.append (new BottomMargin ());

child = box;
remove_css_class (Granite.STYLE_CLASS_BACKGROUND);

var cycle_action = new SimpleAction ("cycle", null);
cycle_action.activate.connect (() => panel.cycle (true));

Expand All @@ -52,9 +66,6 @@ public class Wingpanel.PanelWindow : Gtk.Window {
application.set_accels_for_action ("app.cycle", {"<Control>Tab"});
application.set_accels_for_action ("app.cycle-back", {"<Control><Shift>Tab"});

child = panel;
remove_css_class (Granite.STYLE_CLASS_BACKGROUND);

popover_manager.notify["indicator-open"].connect (() => {
if (!popover_manager.indicator_open) {
Services.BackgroundManager.get_default ().restore_window ();
Expand All @@ -63,43 +74,45 @@ public class Wingpanel.PanelWindow : Gtk.Window {
Services.BackgroundManager.get_default ().remember_window ();
}
});

notify["scale-factor"].connect (update_panel_dimensions);
}

construct {
Services.BackgroundManager.get_default ().background_state_changed.connect (update_background);
}

private void on_realize () {
((Gdk.Toplevel) get_surface ()).compute_size.connect (on_compute_size);
unowned var surface = (Gdk.Toplevel) get_surface ();
surface.compute_size.connect (on_compute_size);
surface.layout.connect (on_layout);

update_panel_dimensions ();
Services.BackgroundManager.initialize (panel_height);
surface.enter_monitor.connect (on_enter_monitor);

init_wl ();
}

private void on_compute_size (Gdk.ToplevelSize top_level_size) {
/* We do our own size calculation to make sure the box shadow in the translucent style isn't cut off */
top_level_size.set_size (width_request, panel.get_height () + 5);
top_level_size.set_shadow_width (0, 0, 0, 5);
private static void on_compute_size (Gdk.ToplevelSize top_level_size) {
top_level_size.set_shadow_width (0, 0, 0, BottomMargin.SIZE);
}

private void update_panel_dimensions () {
panel_height = panel.get_height ();

// We just use our monitor because Gala makes sure we are always on the primary one
var monitor_dimensions = get_display ().get_monitor_at_surface (get_surface ()).get_geometry ();
private void on_layout (Gdk.Surface surface, int width, int height) {
surface.set_input_region (
new Cairo.Region.rectangle ({
0, 0, width, height - BottomMargin.SIZE
})
);

if (!Services.DisplayConfig.is_logical_layout ()) {
monitor_dimensions.width /= get_scale_factor ();
monitor_dimensions.height /= get_scale_factor ();
monitor_dimensions.x /= get_scale_factor ();
monitor_dimensions.y /= get_scale_factor ();
if (!initialized_background_manager) {
Services.BackgroundManager.initialize (panel.get_height ());
initialized_background_manager = true;
}
}

private void on_enter_monitor (Gdk.Monitor new_monitor) {
new_monitor.notify["geometry"].connect (queue_resize);
new_monitor.notify["scale"].connect (queue_resize);
new_monitor.notify["scale-factor"].connect (queue_resize);

this.set_size_request (monitor_dimensions.width, -1);
queue_resize ();
}

public void toggle_indicator (string name) {
Expand All @@ -115,8 +128,6 @@ public class Wingpanel.PanelWindow : Gtk.Window {
desktop_panel = desktop_shell.get_panel (wl_surface);
desktop_panel.set_anchor (TOP);
desktop_panel.set_hide_mode (NEVER);

Idle.add_once (update_panel_dimensions); // Update again since we now can be 100% sure that we are on the primary monitor
}
}
}
Expand Down Expand Up @@ -179,7 +190,6 @@ public class Wingpanel.PanelWindow : Gtk.Window {
break;
}


if (desktop_panel == null) {
return;
}
Expand All @@ -192,8 +202,39 @@ public class Wingpanel.PanelWindow : Gtk.Window {
break;
case Services.BackgroundState.TRANSLUCENT_DARK:
case Services.BackgroundState.TRANSLUCENT_LIGHT:
desktop_panel.add_blur (0, 0, 0, 4, 0);
desktop_panel.add_blur (0, 0, 0, 0, 0);
break;
}
}

public override void measure (
Gtk.Orientation orientation,
int for_size,
out int minimum,
out int natural,
out int minimum_baseline,
out int natural_baseline
) {
if (orientation != HORIZONTAL) {
base.measure (orientation, for_size, out minimum, out natural, out minimum_baseline, out natural_baseline);
return;
}

minimum_baseline = natural_baseline = -1;

var monitor_width = int.MAX;
unowned var surface = get_surface ();
if (surface != null) {
unowned var monitor = get_display ().get_monitor_at_surface (surface);
if (monitor != null) {
monitor_width = monitor.geometry.width;
}
}

if (!Services.DisplayConfig.is_logical_layout ()) {
monitor_width /= get_scale_factor ();
}

minimum = natural = monitor_width;
}
}
2 changes: 0 additions & 2 deletions src/Widgets/Panel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ public class Wingpanel.Widgets.Panel : Granite.Bin {
}

construct {
height_request = 30;
hexpand = true;
vexpand = true;
valign = START;

left_menubar = new IndicatorBar () {
halign = START
Expand Down
Loading