Skip to content

Commit

Permalink
gtk: menu start work on top menu
Browse files Browse the repository at this point in the history
  • Loading branch information
jcollie committed Jan 15, 2025
1 parent 0de2748 commit a201b78
Show file tree
Hide file tree
Showing 7 changed files with 383 additions and 206 deletions.
12 changes: 6 additions & 6 deletions src/apprt/gtk/Surface.zig
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ im_len: u7 = 0,
cgroup_path: ?[]const u8 = null,

/// Our context menu.
menu: Menu(Surface),
context_menu: Menu(Surface, .context, .popover_menu),

/// Configuration used for initializing the surface. We have to copy some
/// data since initialization is delayed with GTK (on realize).
Expand Down Expand Up @@ -567,13 +567,13 @@ pub fn init(self: *Surface, app: *App, opts: Options) !void {
.cursor_pos = .{ .x = 0, .y = 0 },
.im_context = im_context,
.cgroup_path = cgroup_path,
.menu = undefined,
.context_menu = undefined,
};
errdefer self.* = undefined;

// initialize the context menu
self.menu.init();
self.menu.setParent(overlay);
self.context_menu.init();
self.context_menu.setParent(overlay);

// Set our default mouse shape
try self.setMouseShape(.text);
Expand Down Expand Up @@ -1431,7 +1431,7 @@ fn gtkMouseDown(
// word and returns false. We can use this to handle the context menu
// opening under normal scenarios.
if (!consumed and button == .right) {
self.menu.popupAt(x, y);
self.context_menu.popupAt(x, y);
}
}

Expand Down Expand Up @@ -1984,7 +1984,7 @@ pub fn dimSurface(self: *Surface) void {

// Don't dim surface if context menu is open.
// This means we got unfocused due to it opening.
if (self.menu.isVisible()) return;
if (self.context_menu.isVisible()) return;

if (self.unfocused_widget != null) return;
self.unfocused_widget = c.gtk_drawing_area_new();
Expand Down
Loading

0 comments on commit a201b78

Please sign in to comment.