Skip to content

Commit bcc64cf

Browse files
authored
lookingGlass.js: Port the inspector to GObject (#13589)
This allows us to get rid of another use CinnamonGenericContainer. No functional changes
1 parent 05168ca commit bcc64cf

1 file changed

Lines changed: 33 additions & 24 deletions

File tree

js/ui/lookingGlass.js

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -265,22 +265,31 @@ function addBorderPaintHook(actor) {
265265
return signalId;
266266
}
267267

268-
class Inspector {
269-
constructor() {
270-
let container = new Cinnamon.GenericContainer({ width: 0,
271-
height: 0 });
272-
container.connect('allocate', (...args) => { this._allocate(...args) });
273-
Main.uiGroup.add_actor(container);
274-
275-
let eventHandler = new St.BoxLayout({ name: 'LookingGlassDialog',
276-
vertical: true,
277-
reactive: true });
268+
var Inspector = GObject.registerClass({
269+
Signals: {
270+
'closed': {},
271+
'target': { param_types: [Clutter.Actor.$gtype, GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE]},
272+
},
273+
}, class Inspector extends Clutter.Actor {
274+
_init() {
275+
super._init({
276+
width: 0,
277+
height: 0,
278+
});
279+
280+
Main.uiGroup.add_actor(this);
281+
282+
let eventHandler = new St.BoxLayout({
283+
name: 'LookingGlassDialog',
284+
vertical: true,
285+
reactive: true,
286+
});
278287
this._eventHandler = eventHandler;
279288
Main.pushModal(this._eventHandler);
280-
container.add_actor(eventHandler);
281-
this._displayText = new St.Label({style: 'text-align: center;'});
289+
this.add_child(eventHandler);
290+
this._displayText = new St.Label({ style: 'text-align: center;' });
282291
eventHandler.add(this._displayText, { expand: true });
283-
this._passThroughText = new St.Label({style: 'text-align: center;'});
292+
this._passThroughText = new St.Label({ style: 'text-align: center;' });
284293
eventHandler.add(this._passThroughText, { expand: true });
285294

286295
this._borderPaintTarget = null;
@@ -312,11 +321,11 @@ class Inspector {
312321
event.get_key_symbol() === Clutter.KEY_Pause)) {
313322
this.passThroughEvents = !this.passThroughEvents;
314323
this._updatePassthroughText();
315-
return true;
324+
return Clutter.EVENT_STOP;
316325
}
317326

318327
if (this.passThroughEvents)
319-
return false;
328+
return Clutter.EVENT_PROPAGATE;
320329

321330
switch (event.type()) {
322331
case Clutter.EventType.KEY_PRESS:
@@ -328,14 +337,16 @@ class Inspector {
328337
case Clutter.EventType.MOTION:
329338
return this._onMotionEvent(actor, event);
330339
default:
331-
return true;
340+
return Clutter.EVENT_STOP;
332341
}
333342
}
334343

335-
_allocate(actor, box, flags) {
344+
vfunc_allocate(box, flags) {
336345
if (!this._eventHandler)
337346
return;
338347

348+
this.set_allocation(box, flags);
349+
339350
let primary = Main.layoutManager.primaryMonitor;
340351

341352
let [minWidth, minHeight, natWidth, natHeight] =
@@ -366,7 +377,7 @@ class Inspector {
366377
_onKeyPressEvent(actor, event) {
367378
if (event.get_key_symbol() === Clutter.KEY_Escape)
368379
this._close();
369-
return true;
380+
return Clutter.EVENT_STOP;
370381
}
371382

372383
_onButtonPressEvent(actor, event) {
@@ -375,7 +386,7 @@ class Inspector {
375386
this.emit('target', this._target, stageX, stageY);
376387
}
377388
this._close();
378-
return true;
389+
return Clutter.EVENT_STOP;
379390
}
380391

381392
_onScrollEvent(actor, event) {
@@ -409,12 +420,12 @@ class Inspector {
409420
default:
410421
break;
411422
}
412-
return true;
423+
return Clutter.EVENT_STOP;
413424
}
414425

415426
_onMotionEvent(actor, event) {
416427
this._update(event);
417-
return true;
428+
return Clutter.EVENT_STOP;
418429
}
419430

420431
_update(event) {
@@ -438,9 +449,7 @@ class Inspector {
438449
this._borderPaintId = addBorderPaintHook(this._target);
439450
}
440451
}
441-
};
442-
Signals.addSignalMethods(Inspector.prototype);
443-
452+
});
444453

445454
const melangeIFace =
446455
'<node> \

0 commit comments

Comments
 (0)