Skip to content

Commit 3e207a7

Browse files
mmstickjackpot51
authored andcommitted
fix: Horizontally center launcher based on display dimensions
1 parent ed509bc commit 3e207a7

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/extension.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,11 @@ export class Ext extends Ecs.System<ExtEvent> {
741741
return Rect.Rectangle.from_meta(meta as Rectangular);
742742
}
743743

744+
monitor_area(monitor: number): Rectangle | null {
745+
const rect = global.display.get_monitor_geometry(monitor)
746+
return rect ? Rect.Rectangle.from_meta(rect as Rectangular) : null
747+
}
748+
744749
on_active_workspace_changed() {
745750
this.register_fn(() => {
746751
this.exit_modes();

src/launcher.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,10 @@ export class Launcher extends search.Search {
293293
}
294294

295295
open(ext: Ext) {
296-
const mon = ext.monitor_work_area(ext.active_monitor())
296+
const active_monitor = ext.active_monitor()
297+
const mon_work_area = ext.monitor_work_area(active_monitor)
298+
const mon_area = ext.monitor_area(active_monitor)
299+
const mon_width = mon_area ? mon_area.width : mon_work_area.width
297300

298301
super.cleanup()
299302

@@ -302,9 +305,9 @@ export class Launcher extends search.Search {
302305

303306
super._open(global.get_current_time(), false)
304307

305-
this.dialog.dialogLayout.x = (mon.width / 2) - (this.dialog.dialogLayout.width / 2)
308+
this.dialog.dialogLayout.x = (mon_width / 2) - (this.dialog.dialogLayout.width / 2)
306309

307-
let height = mon.height >= 900 ? mon.height / 2 : mon.height / 3.5
310+
let height = mon_work_area.height >= 900 ? mon_work_area.height / 2 : mon_work_area.height / 3.5
308311
this.dialog.dialogLayout.y = height - (this.dialog.dialogLayout.height / 2)
309312
}
310313

0 commit comments

Comments
 (0)