Skip to content

Commit

Permalink
Add a option for disabling Client Side Decoration
Browse files Browse the repository at this point in the history
This can eliminate the black border in specific platforms (e.g. Windows 10 with intel gl driver)

Signed-off-by: tsukinaha <[email protected]>
  • Loading branch information
tsukinaha committed Feb 26, 2025
1 parent 9ae480f commit a638a60
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 22 deletions.
1 change: 1 addition & 0 deletions libmpv2-rs
Submodule libmpv2-rs added at c380cd
4 changes: 4 additions & 0 deletions resources/moe.tsuna.tsukimi.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -226,5 +226,9 @@
<summary>Whether the app is first run</summary>
<default>true</default>
</key>
<key name="is-window-decorated" type="b">
<summary>Whether the window is decorated</summary>
<default>true</default>
</key>
</schema>
</schemalist>
11 changes: 11 additions & 0 deletions resources/ui/account_settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,17 @@
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Others</property>
<child>
<object class="AdwSwitchRow" id="decorated_switchrow">
<property name="title" translatable="yes">Disable Client Side Decoration</property>
<property name="subtitle" translatable="yes">This may helpful for eliminating black border in specific platforms.</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
Expand Down
42 changes: 24 additions & 18 deletions src/ui/widgets/account_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,22 @@ use crate::{
mod imp {
use std::cell::{
Cell,
OnceCell,
RefCell,
};

use glib::subclass::InitializingObject;

use crate::Window;

use super::*;

#[derive(Debug, Default, CompositeTemplate)]
#[derive(Debug, Default, CompositeTemplate, glib::Properties)]
#[template(resource = "/moe/tsuna/tsukimi/ui/account_settings.ui")]
#[properties(wrapper_type = super::AccountSettings)]
pub struct AccountSettings {
#[property(get, set, construct_only)]
pub window: OnceCell<Window>,
#[template_child]
pub password_entry: TemplateChild<adw::PasswordEntryRow>,
#[template_child]
Expand Down Expand Up @@ -77,6 +83,9 @@ mod imp {
#[template_child]
pub config_switchrow: TemplateChild<adw::SwitchRow>,

#[template_child]
pub decorated_switchrow: TemplateChild<adw::SwitchRow>,

#[template_child]
pub post_spinrow: TemplateChild<adw::SpinRow>,

Expand Down Expand Up @@ -192,6 +201,7 @@ mod imp {
}
}

#[glib::derived_properties]
impl ObjectImpl for AccountSettings {
fn constructed(&self) {
self.parent_constructed();
Expand Down Expand Up @@ -221,16 +231,10 @@ glib::wrapper! {
gtk::ConstraintTarget, gtk::Native, gtk::Root, gtk::ShortcutManager;
}

impl Default for AccountSettings {
fn default() -> Self {
Self::new()
}
}

#[template_callbacks]
impl AccountSettings {
pub fn new() -> Self {
glib::Object::builder().build()
pub fn new(window: crate::Window) -> Self {
glib::Object::builder().property("window", window).build()
}

#[template_callback]
Expand Down Expand Up @@ -347,15 +351,6 @@ impl AccountSettings {
));
}

fn window(&self) -> super::window::Window {
let windows = self.application().unwrap().windows();
let window = windows
.into_iter()
.find(|w| w.is::<super::window::Window>())
.unwrap();
window.downcast::<super::window::Window>().unwrap()
}

pub fn set_pic(&self) {
let imp = self.imp();
imp.backgroundcontrol
Expand Down Expand Up @@ -451,6 +446,17 @@ impl AccountSettings {
SETTINGS
.bind("is-refresh", &imp.refresh_control.get(), "active")
.build();
SETTINGS
.bind(
"is-window-decorated",
&imp.decorated_switchrow.get(),
"active",
)
.build();

SETTINGS
.bind("is-window-decorated", &self.window(), "decorated")
.build();

let action_group = gio::SimpleActionGroup::new();

Expand Down
9 changes: 5 additions & 4 deletions src/ui/widgets/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,11 @@ impl Window {
}

pub fn account_settings(&self) {
let window = crate::ui::widgets::account_settings::AccountSettings::new();
window.set_transient_for(Some(self));
window.set_application(Some(&self.application().unwrap()));
window.present();
let window_clone = self.clone();
let ac = crate::ui::widgets::account_settings::AccountSettings::new(window_clone);
ac.set_transient_for(Some(self));
ac.set_application(Some(&self.application().unwrap()));
ac.present();
}

pub fn change_pop_visibility(&self) {
Expand Down

0 comments on commit a638a60

Please sign in to comment.