Skip to content

Commit

Permalink
Merge pull request #109 from pinnacle-comp/blocker_impl
Browse files Browse the repository at this point in the history
Use a `Blocker` implementation instead of halting rendering

Introduces flickering when closing windows
  • Loading branch information
Ottatop authored Dec 22, 2023
2 parents 24c8356 + e8702f9 commit a69ab4e
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 174 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ldoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
repository: Ottatop/ldoc_gen
path: ./ldoc_gen
- name: Setup Lua
uses: leafo/gh-actions-lua@v8
uses: leafo/gh-actions-lua@v10
with:
luaVersion: 5.4
luaVersion: "5.4"
- name: Setup Lua Rocks
uses: leafo/gh-actions-luarocks@v4
- name: Setup dependencies
Expand Down
67 changes: 28 additions & 39 deletions api/lua/example_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,55 +42,49 @@ require("pinnacle").setup(function(pinnacle)

-- Mousebinds --------------------------------------------------------------------

input.mousebind({ "Ctrl" }, buttons.left, "Press", function()
window.begin_move(buttons.left)
end)
input.mousebind({ "Ctrl" }, buttons.right, "Press", function()
window.begin_resize(buttons.right)
end)
input.mousebind({"Ctrl"}, buttons.left, "Press",
function() window.begin_move(buttons.left) end)
input.mousebind({"Ctrl"}, buttons.right, "Press",
function() window.begin_resize(buttons.right) end)

-- Keybinds ----------------------------------------------------------------------

-- mod_key + Alt + q quits the compositor
input.keybind({ mod_key, "Alt" }, keys.q, pinnacle.quit)
input.keybind({mod_key, "Alt"}, keys.q, pinnacle.quit)

-- mod_key + Alt + c closes the focused window
input.keybind({ mod_key, "Alt" }, keys.c, function()
window.get_focused():close()
end)
input.keybind({mod_key, "Alt"}, keys.c,
function() window.get_focused():close() end)

-- mod_key + return spawns a terminal
input.keybind({ mod_key }, keys.Return, function()
input.keybind({mod_key}, keys.Return, function()
process.spawn(terminal, function(stdout, stderr, exit_code, exit_msg)
-- do something with the output here
end)
end)

-- mod_key + Alt + Space toggle floating on the focused window
input.keybind({ mod_key, "Alt" }, keys.space, function()
window.get_focused():toggle_floating()
end)
input.keybind({mod_key, "Alt"}, keys.space,
function() window.get_focused():toggle_floating() end)

-- mod_key + f toggles fullscreen on the focused window
input.keybind({ mod_key }, keys.f, function()
window.get_focused():toggle_fullscreen()
end)
input.keybind({mod_key}, keys.f,
function() window.get_focused():toggle_fullscreen() end)

-- mod_key + m toggles maximized on the focused window
input.keybind({ mod_key }, keys.m, function()
window.get_focused():toggle_maximized()
end)
input.keybind({mod_key}, keys.m,
function() window.get_focused():toggle_maximized() end)

-- Tags ---------------------------------------------------------------------------

local tags = { "1", "2", "3", "4", "5" }
local tags = {"1", "2", "3", "4", "5"}

output.connect_for_all(function(op)
-- Add tags 1, 2, 3, 4 and 5 on all monitors, and toggle tag 1 active by default

op:add_tags(tags)
-- Same as tag.add(op, "1", "2", "3", "4", "5")
tag.toggle({ name = "1", output = op })
tag.toggle({name = "1", output = op})

-- Window rules
-- Add your own window rules here. Below is an example.
Expand All @@ -117,35 +111,30 @@ require("pinnacle").setup(function(pinnacle)
-- Create a layout cycler to cycle your tag layouts. This will store which layout each tag has
-- and change to the next or previous one in the array when the respective function is called.
local layout_cycler = tag.layout_cycler({
"MasterStack",
"Dwindle",
"Spiral",
"CornerTopLeft",
"CornerTopRight",
"CornerBottomLeft",
"CornerBottomRight",
"MasterStack", "Dwindle", "Spiral", "CornerTopLeft", "CornerTopRight",
"CornerBottomLeft", "CornerBottomRight"
})

input.keybind({ mod_key }, keys.space, layout_cycler.next)
input.keybind({ mod_key, "Shift" }, keys.space, layout_cycler.prev)
input.keybind({mod_key}, keys.space, layout_cycler.next)
input.keybind({mod_key, "Shift"}, keys.space, layout_cycler.prev)

-- Tag manipulation

for _, tag_name in pairs(tags) do
-- mod_key + 1-5 switches tags
input.keybind({ mod_key }, tag_name, function()
tag.switch_to(tag_name)
end)
input.keybind({mod_key}, tag_name,
function() tag.switch_to(tag_name) end)
-- mod_key + Shift + 1-5 toggles tags
input.keybind({ mod_key, "Shift" }, tag_name, function()
tag.toggle(tag_name)
end)
input.keybind({mod_key, "Shift"}, tag_name,
function() tag.toggle(tag_name) end)
-- mod_key + Alt + 1-5 moves windows to tags
input.keybind({ mod_key, "Alt" }, tag_name, function()
input.keybind({mod_key, "Alt"}, tag_name,
function()
window:get_focused():move_to_tag(tag_name)
end)
-- mod_key + Shift + Alt + 1-5 toggles tags on windows
input.keybind({ mod_key, "Shift", "Alt" }, tag_name, function()
input.keybind({mod_key, "Shift", "Alt"}, tag_name,
function()
window.get_focused():toggle_tag(tag_name)
end)
end
Expand Down
2 changes: 1 addition & 1 deletion src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl DmabufHandler for State {
.map_err(|_| ()),
};

if let Ok(_) = res {
if res.is_ok() {
let _ = notifier.successful::<State>();
} else {
notifier.failed();
Expand Down
58 changes: 1 addition & 57 deletions src/backend/udev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use std::{
collections::{HashMap, HashSet},
ffi::OsString,
os::fd::FromRawFd,
path::Path,
time::Duration,
};
Expand Down Expand Up @@ -243,7 +242,7 @@ pub fn run_udev() -> anyhow::Result<()> {
let (session, notifier) = LibSeatSession::new()?;

// Get the primary gpu
let primary_gpu = udev::primary_gpu(&session.seat())
let primary_gpu = udev::primary_gpu(session.seat())
.context("unable to get primary gpu path")?
.and_then(|x| {
DrmNode::from_path(x)
Expand Down Expand Up @@ -1341,61 +1340,6 @@ fn render_surface(

clock: &Clock<Monotonic>,
) -> Result<bool, SwapBuffersError> {
use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel;

let pending_wins = windows
.iter()
.filter(|win| win.alive())
.filter(|win| {
let pending_size = if let WindowElement::Wayland(win) = win {
let current_state = win.toplevel().current_state();
win.toplevel()
.with_pending_state(|state| state.size != current_state.size)
} else {
false
};
pending_size || win.with_state(|state| !state.loc_request_state.is_idle())
})
.filter(|win| {
if let WindowElement::Wayland(win) = win {
!win.toplevel()
.current_state()
.states
.contains(xdg_toplevel::State::Resizing)
} else {
true
}
})
.map(|win| {
(
win.class().unwrap_or("None".to_string()),
win.title().unwrap_or("None".to_string()),
win.with_state(|state| state.loc_request_state.clone()),
)
})
.collect::<Vec<_>>();

if !pending_wins.is_empty() {
tracing::debug!("Skipping frame, waiting on {pending_wins:?}");
for win in windows.iter() {
win.send_frame(output, clock.now(), Some(Duration::ZERO), |_, _| {
Some(output.clone())
});
}

surface
.compositor
.queue_frame(None)
.map_err(Into::<SwapBuffersError>::into)?;

tracing::debug!("queued no frame");

// TODO: still draw the cursor here
surface.render_state = RenderState::WaitingForVblank { dirty: false };

return Ok(true);
}

let output_render_elements = crate::render::generate_render_elements(
output,
renderer,
Expand Down
64 changes: 3 additions & 61 deletions src/backend/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,15 @@ use smithay::{
},
winit::{WinitEvent, WinitGraphicsBackend},
},
desktop::{
layer_map_for_output,
utils::{send_frames_surface_tree, surface_primary_scanout_output},
},
desktop::{layer_map_for_output, utils::send_frames_surface_tree},
input::pointer::CursorImageStatus,
output::{Output, Subpixel},
reexports::{
calloop::{
timer::{TimeoutAction, Timer},
EventLoop,
},
wayland_protocols::{
wp::presentation_time::server::wp_presentation_feedback,
xdg::shell::server::xdg_toplevel,
},
wayland_protocols::wp::presentation_time::server::wp_presentation_feedback,
wayland_server::{protocol::wl_surface::WlSurface, Display},
winit::platform::pump_events::PumpStatus,
},
Expand All @@ -36,8 +30,7 @@ use smithay::{

use crate::{
render::{pointer::PointerElement, take_presentation_feedback},
state::{CalloopData, State, WithState},
window::WindowElement,
state::{CalloopData, State},
};

use super::{Backend, BackendData};
Expand Down Expand Up @@ -264,57 +257,6 @@ impl State {
fn render_winit_window(&mut self, output: &Output) {
let winit = self.backend.winit_mut();

let pending_wins = self
.windows
.iter()
.filter(|win| win.alive())
.filter(|win| {
let pending_size = if let WindowElement::Wayland(win) = win {
let current_state = win.toplevel().current_state();
win.toplevel()
.with_pending_state(|state| state.size != current_state.size)
} else {
false
};
pending_size || win.with_state(|state| !state.loc_request_state.is_idle())
})
.filter(|win| {
if let WindowElement::Wayland(win) = win {
!win.toplevel()
.current_state()
.states
.contains(xdg_toplevel::State::Resizing)
} else {
true
}
})
.map(|win| {
(
win.class().unwrap_or("None".to_string()),
win.title().unwrap_or("None".to_string()),
win.with_state(|state| state.loc_request_state.clone()),
)
})
.collect::<Vec<_>>();

if !pending_wins.is_empty() {
// tracing::debug!("Skipping frame, waiting on {pending_wins:?}");
let op_clone = output.clone();
self.loop_handle.insert_idle(move |dt| {
for win in dt.state.windows.iter() {
win.send_frame(
&op_clone,
dt.state.clock.now(),
Some(Duration::ZERO),
surface_primary_scanout_output,
);
}
});

// TODO: still draw the cursor here

return;
}
let full_redraw = &mut winit.full_redraw;
*full_redraw = full_redraw.saturating_sub(1);

Expand Down
1 change: 1 addition & 0 deletions src/handlers/xdg_shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ impl XdgShellHandler for State {
if let Some(focused_output) = data.state.focus_state.focused_output.clone() {
data.state.update_windows(&focused_output);
}

data.state.loop_handle.insert_idle(move |data| {
data.state
.seat
Expand Down
Loading

0 comments on commit a69ab4e

Please sign in to comment.