Skip to content

Commit 6807d7a

Browse files
committed
notification: Limit max height and enable vscroll
1 parent b0c6e1f commit 6807d7a

3 files changed

Lines changed: 27 additions & 22 deletions

File tree

data/theme/cinnamon-sass/widgets/_notifications.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ $notification_width: 34em;
1919
&-body { spacing: $base_padding; }
2020
&-actions { spacing: $base_padding * 2; }
2121

22-
&-scrollview {}
22+
&-scrollview {
23+
max-height: $notification_width * 0.75;
24+
min-height: $notification_width * 0.25;
25+
}
2326

2427
StEntry {}
2528
}

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
118118
this.menu.passEvents = false;
119119
}));
120120

121+
let adjustment = this.scrollview.vscroll.adjustment;
122+
adjustment.connect('changed', Lang.bind(this, function() {
123+
let needsScroll = adjustment.upper > adjustment.page_size;
124+
for (let i = 0; i < this.notifications.length; i++) {
125+
this.notifications[i].setMouseScrolling(!needsScroll);
126+
}
127+
}));
128+
121129
// Alternative tray icons.
122130
this._crit_icon = new St.Icon({icon_name: 'critical-notif', icon_type: St.IconType.SYMBOLIC, reactive: true, track_hover: true, style_class: 'system-status-icon' });
123131
this._alt_crit_icon = new St.Icon({icon_name: 'alt-critical-notif', icon_type: St.IconType.SYMBOLIC, reactive: true, track_hover: true, style_class: 'system-status-icon' });

js/ui/messageTray.js

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -392,32 +392,19 @@ var Notification = class Notification {
392392
_setBodyArea(text, allowMarkup) {
393393
if (text) {
394394
if (!this._scrollArea) {
395-
/* FIXME: vscroll should be enabled
396-
* -vfade covers too much for this size of scrollable
397-
* -scrollview min-height is broken inside tray with a scrollview
398-
*
399-
* TODO: when scrollable:
400-
*
401-
* applet connects to this signal to enable captured-event passthru so you can grab the scrollbar:
402-
* let vscroll = this._scrollArea.get_vscroll_bar();
403-
* vscroll.connect('scroll-start', () => { this.emit('scrolling-changed', true) });
404-
* vscroll.connect('scroll-stop', () => { this.emit('scrolling-changed', false) });
405-
*
406-
* `enable_mouse_scrolling` makes it difficult to scroll when there are many notifications
407-
* in the tray because most of the area is these smaller scrollviews which capture the event.
408-
* ideally, this should only be disabled when the notification is in the tray and there are
409-
* many notifications.
410-
*/
411395
this._scrollArea = new St.ScrollView({
412396
name: 'notification-scrollview',
413-
vscrollbar_policy: St.PolicyType.NEVER,
397+
vscrollbar_policy: St.PolicyType.AUTOMATIC,
414398
hscrollbar_policy: St.PolicyType.NEVER,
415-
enable_mouse_scrolling: false/*,
416-
style_class: 'vfade'*/ });
399+
enable_mouse_scrolling: true,
400+
style_class: 'vfade'});
417401

418402
this._table.add(this._scrollArea, {
419403
row: 1,
420-
col: 2
404+
col: 2,
405+
y_expand: false,
406+
y_fill: false,
407+
y_align: St.Align.START
421408
});
422409

423410
let content = new St.BoxLayout({
@@ -463,6 +450,12 @@ var Notification = class Notification {
463450
adjustment.value = adjustment.upper;
464451
}
465452

453+
setMouseScrolling(enabled) {
454+
if (this._scrollArea) {
455+
this._scrollArea.enable_mouse_scrolling = enabled;
456+
}
457+
}
458+
466459
_updateLayout() {
467460
if (this._imageBin || this._scrollArea || this._actionArea) {
468461
this._table.add_style_class_name('multi-line-notification');
@@ -504,7 +497,8 @@ var Notification = class Notification {
504497
x_expand: false,
505498
y_expand: false,
506499
x_fill: false,
507-
y_fill: false
500+
y_fill: false,
501+
y_align: St.Align.START
508502
});
509503
this._updateLayout();
510504
}

0 commit comments

Comments
 (0)