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

refactor: rename from glint #3

Merged
merged 1 commit into from
Jul 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "glint"
name = "glimmer"
version = "0.0.1"
authors = ["Daniel Acuna <[email protected]>"]
edition = "2018"
Expand Down
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# glint ?
name will likely change, since it seems there's another package under the same name in crates.io :)
# glimmer

## What
A tool for decorating i3 (_should_ work with Sway too!) windows when they get focused, written in Rust.
## What

A tool for decorating i3 (_should_ work with Sway too!) windows when they get focused, written in Rust.

https://user-images.githubusercontent.com/4857535/124782646-61e90a80-df12-11eb-8930-a321ecffbee1.mp4


## Why

When using i3-gaps I ran into the following problems.

- Glitches when using regular borders and titlebars that showed up in the background (as described [here](https://github.com/Airblader/i3/issues/190)), which as far as I know haven't been solved yet.
- The above meant usually relying on transparency or dimming to have a 'highlighted' state, which for me at least beats the purpose of having all your windows in a tiled fashion. To get the highlighted effect you have to lower the opacity or dim it to the point it's too hard to read.
- Even if borders and titlebars _did_ work properly. They just don't gel very well with the `a e s t h e t i c` anyway.
Expand All @@ -28,7 +27,6 @@ Since the binaries are not distributed yet, and this hasn't been published as a
cargo build && cargo run
```


## Running and customizing

By default this application should use the `style.css` in the root of the repo, but you can provide your own using the `--styles` arg and providing a path to your own styles.
Expand All @@ -37,7 +35,6 @@ The css file dictates how the window decorations look like, and they have 2 elem

#### Note that the CSS is not full spec, and you can see the supported properties by GTK [here](https://developer.gnome.org/gtk3/stable/chap-css-properties.html)


A simple example for this, animated using transitions:

```css
Expand All @@ -60,4 +57,3 @@ A simple example for this, animated using transitions:
This will produce the following

https://user-images.githubusercontent.com/4857535/124782792-8349f680-df12-11eb-8231-4a356d33f066.mp4

16 changes: 8 additions & 8 deletions src/actors/glint_instance.rs → src/actors/glimmer_instance.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::glint_manager::{GlintManager, WindowDataMsg};
use super::glimmer_manager::{GlimmerManager, WindowDataMsg};
use crate::gtk_utils::{Messages, WindowShim};
use actix::prelude::*;
use glib::Sender;
Expand All @@ -24,14 +24,14 @@ pub struct InstanceKillNotificationMsg {
}

// Actor definition
pub struct GlintInstance {
pub struct GlimmerInstance {
pub id: usize,
sender: Sender<Messages>,
manager: Addr<GlintManager>,
manager: Addr<GlimmerManager>,
kill_handle: Option<SpawnHandle>,
}

impl Actor for GlintInstance {
impl Actor for GlimmerInstance {
type Context = Context<Self>;

fn stopped(&mut self, _ctx: &mut Self::Context) {
Expand All @@ -43,8 +43,8 @@ impl Actor for GlintInstance {
}
}

impl GlintInstance {
pub fn new(id: usize, sender: Sender<Messages>, manager: Addr<GlintManager>) -> Self {
impl GlimmerInstance {
pub fn new(id: usize, sender: Sender<Messages>, manager: Addr<GlimmerManager>) -> Self {
Self {
id,
sender,
Expand Down Expand Up @@ -82,7 +82,7 @@ impl From<WindowDataMsg> for usize {
}
}

impl Handler<WindowDataMsg> for GlintInstance {
impl Handler<WindowDataMsg> for GlimmerInstance {
type Result = ();

fn handle(&mut self, msg: WindowDataMsg, ctx: &mut Context<Self>) {
Expand All @@ -108,7 +108,7 @@ impl Handler<WindowDataMsg> for GlintInstance {
}
}

impl Handler<DismountMsg> for GlintInstance {
impl Handler<DismountMsg> for GlimmerInstance {
type Result = ();

fn handle(&mut self, _msg: DismountMsg, ctx: &mut Self::Context) -> Self::Result {
Expand Down
24 changes: 12 additions & 12 deletions src/actors/glint_manager.rs → src/actors/glimmer_manager.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::glint_instance::{GlintInstance, InstanceKillNotificationMsg};
use super::glimmer_instance::{GlimmerInstance, InstanceKillNotificationMsg};
use actix::{prelude::*, WeakAddr};
use glib::Sender;
use std::collections::HashMap;
Expand All @@ -20,13 +20,13 @@ pub struct AttachSenderMsg {

// Actor definition
#[derive(Default)]
pub struct GlintManager {
instances: HashMap<usize, actix::WeakAddr<GlintInstance>>,
pub struct GlimmerManager {
instances: HashMap<usize, actix::WeakAddr<GlimmerInstance>>,
sender: Option<Sender<crate::gtk_utils::Messages>>,
}

impl Supervised for GlintManager {}
impl SystemService for GlintManager {
impl Supervised for GlimmerManager {}
impl SystemService for GlimmerManager {
fn start_service(_wrk: &ArbiterHandle) -> Addr<Self> {
Self {
instances: HashMap::new(),
Expand All @@ -35,20 +35,20 @@ impl SystemService for GlintManager {
.start()
}
}
impl Actor for GlintManager {
impl Actor for GlimmerManager {
type Context = Context<Self>;
}

impl GlintManager {
impl GlimmerManager {
pub fn get_instance(
&mut self,
msg: &WindowDataMsg,
self_address: Addr<Self>,
) -> &WeakAddr<GlintInstance> {
) -> &WeakAddr<GlimmerInstance> {
let id = msg.container.id;
let sender = self.sender.clone().unwrap();
let instance = self.instances.entry(id).or_insert_with(|| {
GlintInstance::new(id, sender, self_address)
GlimmerInstance::new(id, sender, self_address)
.start()
.downgrade()
});
Expand All @@ -57,7 +57,7 @@ impl GlintManager {
}
}

impl Handler<WindowDataMsg> for GlintManager {
impl Handler<WindowDataMsg> for GlimmerManager {
type Result = ();

fn handle(&mut self, msg: WindowDataMsg, ctx: &mut Context<Self>) {
Expand All @@ -72,7 +72,7 @@ impl Handler<WindowDataMsg> for GlintManager {
}
}

impl Handler<InstanceKillNotificationMsg> for GlintManager {
impl Handler<InstanceKillNotificationMsg> for GlimmerManager {
type Result = ();

fn handle(
Expand All @@ -84,7 +84,7 @@ impl Handler<InstanceKillNotificationMsg> for GlintManager {
}
}

impl Handler<AttachSenderMsg> for GlintManager {
impl Handler<AttachSenderMsg> for GlimmerManager {
type Result = ();

fn handle(&mut self, msg: AttachSenderMsg, _ctx: &mut Self::Context) -> Self::Result {
Expand Down
7 changes: 4 additions & 3 deletions src/actors/i3_ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use tokio_i3ipc::{
};
use tokio_stream::StreamExt;

use super::glint_manager::{GlintManager, WindowDataMsg};
use super::glimmer_manager::{GlimmerManager, WindowDataMsg};
pub struct I3Ipc {}

trait Find<T> {
Expand Down Expand Up @@ -43,9 +43,10 @@ impl Find<Node> for Node {
// impl Find for Node {}

async fn i3_subscribe() -> io::Result<()> {
let addr = GlintManager::from_registry();
let addr = GlimmerManager::from_registry();

let mut i3 = I3::connect().await?;
// There must be a better way of doing this instead of using two clients?
let mut i32 = I3::connect().await?;

i3.subscribe([Subscribe::Window]).await?;
Expand All @@ -72,7 +73,7 @@ async fn i3_subscribe() -> io::Result<()> {
}

impl Actor for I3Ipc {
type Context = Context<Self>;
type Context = Context<Sz1elf>;

fn started(&mut self, _ctx: &mut Context<Self>) {
// TODO: handle abort, on actor stop?
Expand Down
4 changes: 2 additions & 2 deletions src/actors/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub mod glint_instance;
pub mod glint_manager;
pub mod glimmer_instance;
pub mod glimmer_manager;
pub mod i3_ipc;
4 changes: 2 additions & 2 deletions src/gtk_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use gtk::prelude::*;
use gtk::{Window, WindowType};
use std::collections::HashMap;

use crate::actors::glint_instance::Geometry;
use crate::actors::glimmer_instance::Geometry;

const MAIN_WINDOW_TITLE: &str = "__GLINT_WINDOW__";
const MAIN_WINDOW_TITLE: &str = "__GLIMMER_WINDOW__";

pub fn setup(styles_path: String) {
let css_provider = gtk::CssProvider::new();
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use actix::prelude::*;
use actors::glint_manager::AttachSenderMsg;
use actors::glimmer_manager::AttachSenderMsg;
use clap::{AppSettings, Clap};
use std::thread;
mod actors;
Expand All @@ -25,7 +25,7 @@ fn main() {
let system = System::new();

system.block_on(async {
let manager = actors::glint_manager::GlintManager::from_registry();
let manager = actors::glimmer_manager::GlimmerManager::from_registry();
manager.do_send(AttachSenderMsg { sender });

actors::i3_ipc::I3Ipc {}.start();
Expand Down