Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gnome 45 port #137

Merged
merged 11 commits into from
Nov 12, 2023
Prev Previous commit
Next Next commit
Port extension to gnome 45
  • Loading branch information
yilozt committed Nov 12, 2023
commit 6c8b92dad8d6d044e176d13468c35c4f7d9725b7
19 changes: 10 additions & 9 deletions po/rounded-window-corners@yilozt.pot
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Report-Msgid-Bugs-To: yilozt@outlook.com\n"
"Project-Id-Version: 10\n"
"Project-Id-Version: 11\n"

#: src/preferences/pages/general.ui:284
msgid "Add Settings Entry in right-click menu of Background"
@@ -56,12 +56,12 @@ msgstr ""
msgid "Bottom"
msgstr ""

#: src/preferences/pages/blacklist.ts:65
#: src/preferences/pages/custom.ts:177
#: src/preferences/pages/blacklist.ts:64
#: src/preferences/pages/custom.ts:174
msgid "Can't add to list, because it has exists"
msgstr ""

#: src/preferences/widgets/app_row.ts:106
#: src/preferences/widgets/app_row.ts:105
msgid "Can't pick a window window from this position"
msgstr ""

@@ -86,15 +86,15 @@ msgstr ""
msgid "Debug"
msgstr ""

#: src/preferences/widgets/edit_shadow_window.ts:58
#: src/preferences/widgets/edit_shadow_window.ts:59
msgid "Edit Shadow for Rounded Corners Windows"
msgstr ""

#: src/preferences/pages/custom.ts:189
#: src/preferences/pages/custom.ts:186
msgid "Enable"
msgstr ""

#: src/preferences/pages/custom.ts:193
#: src/preferences/pages/custom.ts:190
msgid "Enable custom settings for this window"
msgstr ""

@@ -103,7 +103,7 @@ msgstr ""
msgid "Enable Log"
msgstr ""

#: src/utils/constants.ts:17
#: src/utils/prefs.ts:48
msgid "Expand this row to pick a window."
msgstr ""

@@ -182,7 +182,8 @@ msgstr ""
msgid "Right"
msgstr ""

#: src/utils/constants.ts:21
#: src/utils/ui.ts:103
#: src/utils/ui.ts:131
msgid "Rounded Corners Settings..."
msgstr ""

6 changes: 4 additions & 2 deletions resources/metadata.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,9 @@
"name": "Rounded Window Corners",
"description": "Add rounded corners for all windows",
"uuid": "rounded-window-corners@yilozt",
"version": "11",
"version": "12",
"url": "https://github.com/yilozt/rounded-window-corners",
"shell-version": ["40", "41", "42", "43", "44"]
"gettext-domain": "rounded-window-corners@yilozt",
"settings-schema": "org.gnome.shell.extensions.rounded-window-corners",
"shell-version": ["45"]
}
2 changes: 1 addition & 1 deletion src/dbus/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// imports.gi
import * as Gio from '@gi/Gio'
import * as Gio from 'gi://Gio'

// --------------------------------------------------------------- [end imports]

32 changes: 15 additions & 17 deletions src/dbus/services.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
// imports.gi
import * as Gio from '@gi/Gio'
import { Variant } from '@gi/GLib'
import * as Gio from 'gi://Gio'
import * as GLib from 'gi://GLib'
import * as Meta from 'gi://Meta'
import * as Clutter from 'gi://Clutter'

// gnome modules
import { Inspector } from '@imports/ui/lookingGlass'
import * as Main from '@imports/ui/main'
import { Inspector } from 'resource:///org/gnome/shell/ui/lookingGlass.js'
import * as Main from 'resource:///org/gnome/shell/ui/main.js'

// local modules
import { _log } from '@me/utils/log'
import { load } from '@me/utils/io'
import { _log } from '../utils/log.js'
import { loadFile } from '../utils/io.js'

// types
import { WindowActor } from '@gi/Meta'
import { Me } from '@global'
import { Actor } from '@gi/Clutter'
// --------------------------------------------------------------- [end imports]

const iface = load (`${Me.path}/dbus/iface.xml`)
const iface = loadFile (import.meta.url, 'iface.xml')

export class Services {
DBusImpl = Gio.DBusExportedObject.wrapJSObject (iface, this)
@@ -27,7 +25,7 @@ export class Services {
const _send_wm_class_instance = (wm_instance_class: string) => {
this.DBusImpl.emit_signal (
'picked',
new Variant ('(s)', [wm_instance_class])
new GLib.Variant ('(s)', [wm_instance_class])
)
}

@@ -51,20 +49,20 @@ export class Services {
const effect_name = 'lookingGlass_RedBorderEffect'
target
.get_effects ()
.filter ((e) => e.toString ().includes (effect_name))
.forEach ((e) => target.remove_effect (e))
.filter ((e: Clutter.Effect) => e.toString ().includes (effect_name))
.forEach ((e: Clutter.Effect) => target.remove_effect (e))

let actor: Actor | null = target
let actor: Clutter.Actor | null = target

// User will pick to a Meta.SurfaceActor in most time, let's find the
// associate Meta.WindowActor
for (let i = 0; i < 2; i++) {
if (actor == null || actor instanceof WindowActor) break
if (actor == null || actor instanceof Meta.WindowActor) break
// If picked actor is not a Meta.WindowActor, search it's parent
actor = actor.get_parent ()
}

if (!(actor instanceof WindowActor)) {
if (!(actor instanceof Meta.WindowActor)) {
_send_wm_class_instance ('window-not-found')
return
}
20 changes: 9 additions & 11 deletions src/effect/clip_shadow_effect.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
// imports.gi
import * as GObject from '@gi/GObject'
import { SnippetHook, GLSLEffect } from '@gi/Shell'
import * as GObject from 'gi://GObject'
import * as Shell from 'gi://Shell'
import * as Clutter from 'gi://Clutter'

// local modules
import { loadShader } from '@me/utils/io'

// types
import { Me } from '@global'
import { PaintContext, PaintNode } from '@gi/Clutter'
import { loadShader } from '../utils/io.js'

// ------------------------------------------------------------------- [imports]

const { declarations, code } = loadShader (
`${Me.path}/effect/shader/clip_shadow.frag`
import.meta.url,
'shader/clip_shadow.frag'
)

export const ClipShadowEffect = GObject.registerClass (
{},
class extends GLSLEffect {
class extends Shell.GLSLEffect {
vfunc_build_pipeline (): void {
const hook = SnippetHook.FRAGMENT
const hook = Shell.SnippetHook.FRAGMENT
this.add_glsl_snippet (hook, declarations, code, false)
}

vfunc_paint_target (node: PaintNode, ctx: PaintContext) {
vfunc_paint_target (node: Clutter.PaintNode, ctx: Clutter.PaintContext) {
// Reset to default blend string.
this.get_pipeline ()?.set_blend (
'RGBA = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))'
23 changes: 13 additions & 10 deletions src/effect/linear_filter_effect.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import { PaintNode, PaintContext } from '@gi/Clutter'
import { PipelineFilter } from '@gi/Cogl'
import { registerClass } from '@gi/GObject'
import { GLSLEffect, SnippetHook } from '@gi/Shell'
import * as Clutter from 'gi://Clutter'
import * as Cogl from 'gi://Cogl'
import * as GObject from 'gi://GObject'
import * as Shell from 'gi://Shell'

export const LinearFilterEffect = registerClass (
export const LinearFilterEffect = GObject.registerClass (
{},
class extends GLSLEffect {
class extends Shell.GLSLEffect {
vfunc_build_pipeline (): void {
this.add_glsl_snippet (SnippetHook.FRAGMENT, '', '', false)
this.add_glsl_snippet (Shell.SnippetHook.FRAGMENT, '', '', false)
}

vfunc_paint_target (node: PaintNode, ctx: PaintContext): void {
vfunc_paint_target (
node: Clutter.PaintNode,
ctx: Clutter.PaintContext
): void {
this.get_pipeline ()?.set_layer_filters (
0,
PipelineFilter.LINEAR_MIPMAP_LINEAR,
PipelineFilter.NEAREST
Cogl.PipelineFilter.LINEAR_MIPMAP_LINEAR,
Cogl.PipelineFilter.NEAREST
)
super.vfunc_paint_target (node, ctx)
}
28 changes: 14 additions & 14 deletions src/effect/rounded_corners_effect.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// imports.gi
import { registerClass } from '@gi/GObject'
import { GLSLEffect, SnippetHook } from '@gi/Shell'
import * as GObject from 'gi://GObject'
import * as Meta from 'gi://Meta'
import * as Shell from 'gi://Shell'

// local modules
import { loadShader } from '@me/utils/io'
import * as types from '@me/utils/types'
import { loadShader } from '../utils/io.js'
import * as types from '../utils/types.js'

// types
import { Me } from '@global'
import { PaintContext, PaintNode } from '@gi/Clutter'
import { shell_version } from '@me/utils/ui'
import { WindowActor } from '@gi/Meta'
import * as Clutter from 'gi://Clutter'
import { shell_version } from '../utils/ui.js'

// --------------------------------------------------------------- [end imports]

// Load fragment shader of rounded corners effect.
const { declarations, code } = loadShader (
`${Me.path}/effect/shader/rounded_corners.frag`
import.meta.url,
'shader/rounded_corners.frag'
)

/** Location of uniform variants of rounded corners effect */
@@ -31,9 +31,9 @@ class Uniforms {
border_color = 0
}

export const RoundedCornersEffect = registerClass (
export const RoundedCornersEffect = GObject.registerClass (
{},
class Effect extends GLSLEffect {
class Effect extends Shell.GLSLEffect {
/**
* Location of uniforms variants in shader, Cache those location
* when shader has been setup in `vfunc_build_pipeline()`, sot that
@@ -63,12 +63,12 @@ export const RoundedCornersEffect = registerClass (
}

vfunc_build_pipeline (): void {
const type = SnippetHook.FRAGMENT
const type = Shell.SnippetHook.FRAGMENT
this.add_glsl_snippet (type, declarations, code, false)
this._init_uniforms ()
}

vfunc_paint_target (node: PaintNode, ctx: PaintContext) {
vfunc_paint_target (node: Clutter.PaintNode, ctx: Clutter.PaintContext) {
// Reset to default blend string.
this.get_pipeline ()?.set_blend (
'RGBA = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))'
@@ -125,7 +125,7 @@ export const RoundedCornersEffect = registerClass (
// offers correct one.
if (
shell_version () >= 43.1 &&
actor instanceof WindowActor &&
actor instanceof Meta.WindowActor &&
actor.first_child?.first_child
) {
const { width, height } = actor.first_child.first_child
Loading