Skip to content

Commit

Permalink
Merge pull request #2927 from LukashonakV/gtk4
Browse files Browse the repository at this point in the history
Gtk4. Pick up PR#2836
  • Loading branch information
Alexays authored Feb 19, 2024
2 parents f1abc18 + b32abf9 commit b54e2c1
Show file tree
Hide file tree
Showing 22 changed files with 225 additions and 808 deletions.
2 changes: 2 additions & 0 deletions include/AModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace waybar {

class AModule : public IModule {
public:
static constexpr const char *MODULE_CLASS = "module";

virtual ~AModule();
auto update() -> void override;
virtual auto refresh(int) -> void{};
Expand Down
32 changes: 10 additions & 22 deletions include/bar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,18 @@ class BarIpcClient;
}
#endif // HAVE_SWAY

class BarSurface {
protected:
BarSurface() = default;

public:
virtual void setExclusiveZone(bool enable) = 0;
virtual void setLayer(bar_layer layer) = 0;
virtual void setMargins(const struct bar_margins &margins) = 0;
virtual void setPassThrough(bool enable) = 0;
virtual void setPosition(const std::string_view &position) = 0;
virtual void setSize(uint32_t width, uint32_t height) = 0;
virtual void commit(){};

virtual ~BarSurface() = default;
};

class Bar {
public:
using bar_mode_map = std::map<std::string_view, struct bar_mode>;
using bar_mode_map = std::map<std::string, struct bar_mode>;
static const bar_mode_map PRESET_MODES;
static const std::string_view MODE_DEFAULT;
static const std::string_view MODE_INVISIBLE;
static const std::string MODE_DEFAULT;
static const std::string MODE_INVISIBLE;

Bar(struct waybar_output *w_output, const Json::Value &);
Bar(const Bar &) = delete;
~Bar();

void setMode(const std::string_view &);
void setMode(const std::string &mode);
void setVisible(bool visible);
void toggle();
void handleSignal(int);
Expand All @@ -84,9 +68,10 @@ class Bar {
Json::Value config;
struct wl_surface *surface;
bool visible = true;
bool vertical = false;
Gtk::Window window;
Glib::RefPtr<Gdk::Surface> gdk_surface_;
Gtk::Orientation orientation = Gtk::Orientation::HORIZONTAL;
Gtk::PositionType position = Gtk::PositionType::TOP;

int x_global;
int y_global;
Expand All @@ -102,6 +87,8 @@ class Bar {
void setupAltFormatKeyForModule(const std::string &module_name);
void setupAltFormatKeyForModuleList(const char *module_list_name);
void setMode(const bar_mode &);
void setPassThrough(bool passthrough);
void setPosition(Gtk::PositionType position);
void onConfigure(int width, int height);
void configureGlobalOffset(int width, int height);
void onOutputGeometryChanged();
Expand All @@ -111,8 +98,9 @@ class Bar {
std::string last_mode_{MODE_DEFAULT};

struct bar_margins margins_;
uint32_t width_, height_;
bool passthrough_;

std::unique_ptr<BarSurface> surface_impl_;
Gtk::Box left_;
Gtk::Box center_;
Gtk::Box right_;
Expand Down
2 changes: 0 additions & 2 deletions include/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "config.hpp"
#include "util/portal.hpp"

struct zwlr_layer_shell_v1;
struct zwp_idle_inhibitor_v1;
struct zwp_idle_inhibit_manager_v1;

Expand All @@ -22,7 +21,6 @@ class Client {
Glib::RefPtr<Gdk::Display> gdk_display;
struct wl_display *wl_display = nullptr;
struct wl_registry *registry = nullptr;
struct zwlr_layer_shell_v1 *layer_shell = nullptr;
struct zxdg_output_manager_v1 *xdg_output_manager = nullptr;
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager = nullptr;
std::vector<std::unique_ptr<Bar>> bars;
Expand Down
6 changes: 0 additions & 6 deletions man/waybar.5.scd.in
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ Also, a minimal example configuration can be found at the bottom of this man pag
Option to pass any pointer events to the window under the bar.
Intended to be used with either *top* or *overlay* layers and without exclusive zone.

*gtk-layer-shell* ++
typeof: bool ++
default: true ++
Option to disable the use of gtk-layer-shell for popups.
Only functional if compiled with gtk-layer-shell support.

*ipc* ++
typeof: bool ++
default: false ++
Expand Down
7 changes: 1 addition & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,8 @@ spdlog = dependency('spdlog', version : ['>=1.10.0'], fallback : ['spdlog', 'spd

gtk_layer_shell = dependency('gtk4-layer-shell-0',
version : ['>=1.0.2'],
required: get_option('gtk-layer-shell'),
fallback : ['gtk4-layer-shell', 'gtk_layer_shell'],
default_options : ['vapi=false'])

if gtk_layer_shell.found()
add_project_arguments('-DHAVE_GTK_LAYER_SHELL', language: 'cpp')
endif
default_options : ['introspection=false', 'vapi=false'])

prefix = get_option('prefix')
sysconfdir = get_option('sysconfdir')
Expand Down
1 change: 0 additions & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ option('systemd', type: 'feature', value: 'auto', description: 'Install systemd
option('dbusmenu-gtk', type: 'feature', value: 'auto', description: 'Enable support for tray')
option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages')
option('mpd', type: 'feature', value: 'auto', description: 'Enable support for the Music Player Daemon')
option('gtk-layer-shell', type: 'feature', value: 'auto', description: 'Use gtk-layer-shell library for popups support')
option('rfkill', type: 'feature', value: 'auto', description: 'Enable support for RFKILL')
option('sndio', type: 'feature', value: 'auto', description: 'Enable support for sndio')
option('logind', type: 'feature', value: 'auto', description: 'Enable support for logind')
Expand Down
1 change: 0 additions & 1 deletion protocol/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ client_protocols = [
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
[wl_protocol_dir, 'unstable/xdg-output/xdg-output-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'],
['wlr-layer-shell-unstable-v1.xml'],
['wlr-foreign-toplevel-management-unstable-v1.xml'],
['ext-workspace-unstable-v1.xml'],
['river-status-unstable-v1.xml'],
Expand Down
Loading

0 comments on commit b54e2c1

Please sign in to comment.