Skip to content

Commit

Permalink
[Protocol change] When a window has no internal size, mark it as hidd…
Browse files Browse the repository at this point in the history
…en to ensure it also has no padding
  • Loading branch information
curiousdannii committed Oct 19, 2024
1 parent 4498793 commit c12f945
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
10 changes: 7 additions & 3 deletions remglk/src/glkapi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1503,19 +1503,23 @@ where S: Default + GlkSystem {
let keywin = Into::<GlkWindow>::into(&win.key);
let keywin = lock!(keywin);
match keywin.wintype {
WindowType::Buffer => if win.vertical {
WindowType::Buffer => if win.size > 0 {
if win.vertical {
win.size as f64 * self.metrics.buffercharwidth + self.metrics.buffermarginx
}
else {
win.size as f64 * self.metrics.buffercharheight + self.metrics.buffermarginy
}
WindowType::Graphics => win.size as f64 + (if win.vertical {self.metrics.graphicsmarginx} else {self.metrics.graphicsmarginy}),
WindowType::Grid => if win.vertical {
} else {0.0},
WindowType::Graphics => if win.size > 0 {win.size as f64 + (if win.vertical {self.metrics.graphicsmarginx} else {self.metrics.graphicsmarginy})} else {0.0},
WindowType::Grid => if win.size > 0 {
if win.vertical {
win.size as f64 * self.metrics.gridcharwidth + self.metrics.gridmarginx
}
else {
win.size as f64 * self.metrics.gridcharheight + self.metrics.gridmarginy
}
} else {0.0},
_ => unreachable!(),
}
}
Expand Down
3 changes: 3 additions & 0 deletions remglk/src/glkapi/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,9 @@ pub struct WindowUpdate {
#[serde(skip_serializing_if = "Option::is_none")]
pub gridwidth: Option<u32>,
pub height: f64,
/** Whether the window should be completely hidden, though could potentially still respond to character events */
#[serde(skip_serializing_if = "Not::not")]
pub hidden: bool,
/** Window ID */
pub id: u32,
/** Left position */
Expand Down
7 changes: 5 additions & 2 deletions remglk/src/glkapi/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,20 @@ impl Window {
}

// Now give it to the specific window types for them to fill in
let height = self.wbox.bottom - self.wbox.top;
let width = self.wbox.right - self.wbox.left;
self.data.update(WindowUpdate {
id: self.id,
input: input_update,
size: protocol::WindowUpdate {
height: self.wbox.bottom - self.wbox.top,
height,
hidden: height == 0.0 || width == 0.0,
id: self.id,
left: self.wbox.left,
rock: self.rock,
top: self.wbox.top,
wintype: self.wintype,
width: self.wbox.right - self.wbox.left,
width,
..Default::default()
},
..Default::default()
Expand Down

0 comments on commit c12f945

Please sign in to comment.