revert X Property change, and cleanup formatting
This commit is contained in:
parent
5a4a802751
commit
65f43a9300
32 changed files with 459 additions and 429 deletions
|
|
@ -1,20 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="DockItem" parent="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image">
|
||||
<property name="margin-start">4</property>
|
||||
<property name="margin-end">4</property>
|
||||
<property name="margin-top">4</property>
|
||||
<property name="pixel-size">48</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="dots">
|
||||
<property name="hexpand">true</property>
|
||||
<property name="halign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
<template class="DockItem" parent="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image">
|
||||
<property name="margin-start">4</property>
|
||||
<property name="margin-end">4</property>
|
||||
<property name="margin-top">4</property>
|
||||
<property name="pixel-size">48</property>
|
||||
<property name="icon-size">large</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="dots">
|
||||
<property name="hexpand">true</property>
|
||||
<property name="halign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
use gtk4 as gtk;
|
||||
use gtk::CompositeTemplate;
|
||||
use gtk::glib;
|
||||
use gtk::prelude::*;
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk4 as gtk;
|
||||
|
||||
use gtk::CompositeTemplate;
|
||||
|
||||
#[derive(Debug, Default, CompositeTemplate)]
|
||||
#[template(file = "dock_item.ui")]
|
||||
|
|
@ -30,5 +29,7 @@ impl ObjectSubclass for DockItem {
|
|||
}
|
||||
|
||||
impl ObjectImpl for DockItem {}
|
||||
|
||||
impl WidgetImpl for DockItem {}
|
||||
|
||||
impl BoxImpl for DockItem {}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
use crate::utils::BoxedWindowList;
|
||||
use gio::DesktopAppInfo;
|
||||
use gio::Icon;
|
||||
use gtk4 as gtk;
|
||||
mod imp;
|
||||
|
||||
use gtk::glib;
|
||||
use gtk::prelude::*;
|
||||
use gtk::subclass::prelude::*;
|
||||
|
||||
use crate::dock_object::DockObject;
|
||||
use crate::utils::BoxedWindowList;
|
||||
|
||||
mod imp;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct DockItem(ObjectSubclass<imp::DockItem>)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
use crate::utils::BoxedWindowList;
|
||||
use std::cell::Cell;
|
||||
use std::cell::RefCell;
|
||||
|
||||
use gio::DesktopAppInfo;
|
||||
use glib::{ParamFlags, ParamSpec, Value};
|
||||
use gtk4::glib;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use once_cell::sync::Lazy;
|
||||
use std::cell::Cell;
|
||||
use std::cell::RefCell;
|
||||
|
||||
use crate::utils::BoxedWindowList;
|
||||
|
||||
// Object holding the state
|
||||
#[derive(Default)]
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
mod imp;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::utils::BoxedWindowList;
|
||||
use gdk4::glib::Object;
|
||||
use gio::DesktopAppInfo;
|
||||
use gtk4::glib;
|
||||
use gtk4::prelude::AppInfoExt;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::utils::BoxedWindowList;
|
||||
|
||||
mod imp;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct DockObject(ObjectSubclass<imp::DockObject>);
|
||||
|
|
|
|||
|
|
@ -1,31 +1,34 @@
|
|||
mod dock_item;
|
||||
mod dock_object;
|
||||
mod utils;
|
||||
mod window;
|
||||
use std::collections::BTreeMap;
|
||||
use std::time::Duration;
|
||||
|
||||
use self::dock_object::DockObject;
|
||||
use self::window::Window;
|
||||
use crate::utils::BoxedWindowList;
|
||||
use futures::executor::block_on;
|
||||
use gdk4::Display;
|
||||
use gio::DesktopAppInfo;
|
||||
use gtk::gio;
|
||||
use gtk::glib;
|
||||
use gtk::prelude::*;
|
||||
use gtk::Application;
|
||||
use gtk4 as gtk;
|
||||
use gtk4::CssProvider;
|
||||
use gtk4::StyleContext;
|
||||
use gtk::Application;
|
||||
use gtk::gio;
|
||||
use gtk::glib;
|
||||
use gtk::prelude::*;
|
||||
use once_cell::sync::OnceCell;
|
||||
use postage::mpsc::Sender;
|
||||
use postage::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::BTreeMap;
|
||||
use std::time::Duration;
|
||||
use x11rb::rust_connection::RustConnection;
|
||||
use zbus::Connection;
|
||||
use zvariant_derive::Type;
|
||||
|
||||
use crate::utils::BoxedWindowList;
|
||||
|
||||
use self::dock_object::DockObject;
|
||||
use self::window::Window;
|
||||
|
||||
mod dock_item;
|
||||
mod dock_object;
|
||||
mod utils;
|
||||
mod window;
|
||||
|
||||
const DEST: &str = "com.System76.PopShell";
|
||||
const PATH: &str = "/com/System76/PopShell";
|
||||
const NUM_LAUNCHER_ITEMS: u8 = 10;
|
||||
|
|
@ -129,7 +132,7 @@ fn main() {
|
|||
match event {
|
||||
Event::Activate(e) => {
|
||||
let _activate_window = zbus_conn
|
||||
.call_method(Some(DEST), PATH, Some(DEST), "WindowFocus", &((e,)))
|
||||
.call_method(Some(DEST), PATH, Some(DEST), "WindowFocus", &((e, )))
|
||||
.await
|
||||
.expect("Failed to focus selected window");
|
||||
}
|
||||
|
|
@ -223,16 +226,16 @@ fn main() {
|
|||
// skip if equal
|
||||
if cached_results.len() == results.len()
|
||||
&& results.iter().zip(cached_results.iter()).fold(
|
||||
0,
|
||||
|acc, z: (&Item, &Item)| {
|
||||
let (a, b) = z;
|
||||
if a.name == b.name {
|
||||
acc + 1
|
||||
} else {
|
||||
acc
|
||||
}
|
||||
},
|
||||
) == cached_results.len()
|
||||
0,
|
||||
|acc, z: (&Item, &Item)| {
|
||||
let (a, b) = z;
|
||||
if a.name == b.name {
|
||||
acc + 1
|
||||
} else {
|
||||
acc
|
||||
}
|
||||
},
|
||||
) == cached_results.len()
|
||||
{
|
||||
continue; // skip this update
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,17 +3,21 @@ row:hover {
|
|||
background: #888888;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
row {
|
||||
background: #333333;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
listview {
|
||||
border-radius: 12px;
|
||||
background: #333333;
|
||||
}
|
||||
|
||||
window {
|
||||
background: rgba(50,50,50,0.0);
|
||||
background: rgba(50, 50, 50, 0.0);
|
||||
}
|
||||
|
||||
box#dock-container {
|
||||
border-radius: 12px;
|
||||
background: #333333;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use gtk4::glib;
|
||||
|
||||
use crate::DockObject;
|
||||
use crate::Item;
|
||||
use gtk4::glib;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Clone, Debug, Default, glib::GBoxed)]
|
||||
#[gboxed(type_name = "BoxedWindowList")]
|
||||
pub struct BoxedWindowList(pub Vec<Item>);
|
||||
|
||||
#[derive(Clone, Debug, Default, glib::GBoxed)]
|
||||
#[gboxed(type_name = "BoxedDockObject")]
|
||||
pub struct BoxedDockObject(pub Option<DockObject>);
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use glib::SignalHandlerId;
|
||||
use glib::subclass::InitializingObject;
|
||||
use gtk::{gio, glib};
|
||||
use gtk::{CompositeTemplate, ListView};
|
||||
use gtk4 as gtk;
|
||||
use gtk4::Box;
|
||||
use gtk4::DragSource;
|
||||
use gtk4::DropTarget;
|
||||
use gtk4::EventControllerMotion;
|
||||
use gtk4::Revealer;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use glib::subclass::InitializingObject;
|
||||
use gtk::prelude::*;
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk::{gio, glib};
|
||||
use gtk::{CompositeTemplate, ListView};
|
||||
use once_cell::sync::OnceCell;
|
||||
|
||||
// Object holding the state
|
||||
|
|
@ -56,6 +56,7 @@ impl ObjectSubclass for Window {
|
|||
obj.init_template();
|
||||
}
|
||||
}
|
||||
|
||||
// Trait shared by all GObjects
|
||||
impl ObjectImpl for Window {
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
|
|
@ -72,6 +73,7 @@ impl ObjectImpl for Window {
|
|||
obj.setup_factory();
|
||||
}
|
||||
}
|
||||
|
||||
// Trait shared by all widgets
|
||||
impl WidgetImpl for Window {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
mod imp;
|
||||
// use crate::ApplicationObject;
|
||||
use crate::dock_item::DockItem;
|
||||
use crate::dock_object::DockObject;
|
||||
use crate::utils::data_path;
|
||||
use crate::BoxedWindowList;
|
||||
use crate::Event;
|
||||
use crate::TX;
|
||||
use crate::X11_CONN;
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
|
||||
use gdk4::ContentProvider;
|
||||
use gdk4::Display;
|
||||
use gdk4::Rectangle;
|
||||
|
|
@ -14,28 +8,36 @@ use gdk4_x11::X11Display;
|
|||
use gdk4_x11::X11Surface;
|
||||
use gio::DesktopAppInfo;
|
||||
use gio::Icon;
|
||||
// use crate::application_row::ApplicationRow;
|
||||
use glib::Object;
|
||||
use glib::Type;
|
||||
use gtk::{gio, glib};
|
||||
use gtk::{Application, SignalListItemFactory};
|
||||
use gtk4 as gtk;
|
||||
use gtk4::prelude::ListModelExt;
|
||||
use gtk4::DragSource;
|
||||
use gtk4::DropTarget;
|
||||
use gtk4::EventControllerMotion;
|
||||
use gtk4::IconTheme;
|
||||
use postage::prelude::Sink;
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
use x11rb::connection::Connection;
|
||||
use x11rb::protocol::xproto::ConnectionExt as OtherConnectionExt;
|
||||
use x11rb::protocol::xproto::*;
|
||||
use x11rb::wrapper::ConnectionExt;
|
||||
// use crate::application_row::ApplicationRow;
|
||||
use glib::Object;
|
||||
use gtk4::prelude::ListModelExt;
|
||||
use gtk::prelude::*;
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk::{gio, glib};
|
||||
use gtk::{Application, SignalListItemFactory};
|
||||
use libcosmic::x;
|
||||
use postage::prelude::Sink;
|
||||
use x11rb::connection::Connection;
|
||||
use x11rb::protocol::xproto;
|
||||
use x11rb::protocol::xproto::ConnectionExt;
|
||||
|
||||
use libcosmic::x;
|
||||
|
||||
use crate::BoxedWindowList;
|
||||
// use crate::ApplicationObject;
|
||||
use crate::dock_item::DockItem;
|
||||
use crate::dock_object::DockObject;
|
||||
use crate::Event;
|
||||
use crate::TX;
|
||||
use crate::utils::data_path;
|
||||
use crate::X11_CONN;
|
||||
|
||||
mod imp;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct Window(ObjectSubclass<imp::Window>)
|
||||
|
|
@ -178,16 +180,15 @@ impl Window {
|
|||
// ignore all x11 errors...
|
||||
let xdisplay = display.clone().downcast::<X11Display>().expect("Failed to downgrade X11 Display.");
|
||||
xdisplay.error_trap_push();
|
||||
let conn = X11_CONN.get().expect("Failed to get X11 connection");
|
||||
let window_type_atom = conn.intern_atom(false, b"_NET_WM_WINDOW_TYPE").unwrap().reply().unwrap().atom;
|
||||
let dock_type_atom = conn.intern_atom(false, b"_NET_WM_WINDOW_TYPE_DOCK").unwrap().reply().unwrap().atom;
|
||||
conn.change_property32(
|
||||
PropMode::REPLACE,
|
||||
surface.xid().try_into().unwrap(),
|
||||
window_type_atom,
|
||||
AtomEnum::ATOM,
|
||||
&[dock_type_atom]
|
||||
).unwrap();
|
||||
unsafe {
|
||||
x::change_property(
|
||||
&display,
|
||||
&surface,
|
||||
"_NET_WM_WINDOW_TYPE",
|
||||
x::PropMode::Replace,
|
||||
&[x::Atom::new(&display, "_NET_WM_WINDOW_TYPE_DOCK").unwrap()],
|
||||
);
|
||||
}
|
||||
let resize = glib::clone!(@weak window, @weak revealer => move || {
|
||||
let s = window.surface().expect("Failed to get Surface for Window");
|
||||
let height = if revealer.reveals_child() { window.height() } else { 4 };
|
||||
|
|
@ -203,6 +204,8 @@ impl Window {
|
|||
width: monitor_width,
|
||||
height: monitor_height,
|
||||
} = monitor.geometry();
|
||||
// dbg!(monitor_x);
|
||||
// dbg!(monitor_y);
|
||||
// dbg!(monitor_width);
|
||||
// dbg!(monitor_height);
|
||||
// dbg!(width);
|
||||
|
|
|
|||
|
|
@ -1,69 +1,69 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="LauncherWindow" parent="GtkApplicationWindow">
|
||||
<!-- drop controller seems to be buggy if window changes size -->
|
||||
<property name="height-request">80</property>
|
||||
<property name="width-request">128</property>
|
||||
<property name="title">Gtk Pop Dock</property>
|
||||
<property name="decorated">false</property>
|
||||
<property name="resizable">false</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="cursor_handle">
|
||||
<property name="orientation">vertical</property>
|
||||
<template class="LauncherWindow" parent="GtkApplicationWindow">
|
||||
<!-- drop controller seems to be buggy if window changes size -->
|
||||
<property name="height-request">80</property>
|
||||
<property name="width-request">128</property>
|
||||
<property name="title">Gtk Pop Dock</property>
|
||||
<property name="decorated">false</property>
|
||||
<property name="resizable">false</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="height-request">0</property>
|
||||
<property name="vexpand">true</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRevealer" id="revealer">
|
||||
<property name="reveal-child">true</property>
|
||||
<property name="transition-duration">300</property>
|
||||
<property name="transition-type">slide-up</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="height-request">0</property>
|
||||
<object class="GtkBox" id="cursor_handle">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="height-request">64</property>
|
||||
<property name="margin-start">4</property>
|
||||
<property name="margin-end">4</property>
|
||||
<property name="spacing">4</property>
|
||||
<property name="name">dock-container</property>
|
||||
<child>
|
||||
<object class="GtkListView" id="saved_app_list_view">
|
||||
<property name="orientation">horizontal</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator">
|
||||
<property name="margin-start">12</property>
|
||||
<property name="margin-end">12</property>
|
||||
<property name="margin-top">4</property>
|
||||
<property name="margin-bottom">4</property>
|
||||
<property name="orientation">vertical</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListView" id="active_app_list_view">
|
||||
<property name="orientation">horizontal</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkBox">
|
||||
<property name="height-request">0</property>
|
||||
<property name="vexpand">true</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="height-request">4</property>
|
||||
</object>
|
||||
<object class="GtkRevealer" id="revealer">
|
||||
<property name="reveal-child">true</property>
|
||||
<property name="transition-duration">300</property>
|
||||
<property name="transition-type">slide-up</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="height-request">0</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="height-request">64</property>
|
||||
<property name="margin-start">4</property>
|
||||
<property name="margin-end">4</property>
|
||||
<property name="spacing">4</property>
|
||||
<property name="name">dock-container</property>
|
||||
<child>
|
||||
<object class="GtkListView" id="saved_app_list_view">
|
||||
<property name="orientation">horizontal</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator">
|
||||
<property name="margin-start">12</property>
|
||||
<property name="margin-end">12</property>
|
||||
<property name="margin-top">4</property>
|
||||
<property name="margin-bottom">4</property>
|
||||
<property name="orientation">vertical</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListView" id="active_app_list_view">
|
||||
<property name="orientation">horizontal</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="height-request">4</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</template>
|
||||
</interface>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue