Skip to content

Commit a3c9b2e

Browse files
committed
GTK4. wlr migration
Signed-off-by: Viktar Lukashonak <myxabeer@gmail.com>
1 parent 82ddd90 commit a3c9b2e

File tree

3 files changed

+133
-201
lines changed

3 files changed

+133
-201
lines changed

include/modules/wlr/taskbar.hpp

+10-35
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,22 @@
11
#pragma once
22

3-
#include <gdk/gdk.h>
4-
#include <glibmm/refptr.h>
5-
#include <gtkmm/box.h>
3+
#include <giomm/desktopappinfo.h>
64
#include <gtkmm/button.h>
75
#include <gtkmm/icontheme.h>
86
#include <gtkmm/image.h>
97
#include <gtkmm/label.h>
10-
#include <wayland-client.h>
118

12-
#include <map>
13-
#include <memory>
14-
#include <string>
159
#include <unordered_set>
16-
#include <vector>
1710

1811
#include "AModule.hpp"
1912
#include "bar.hpp"
20-
#include "client.hpp"
21-
#include "giomm/desktopappinfo.h"
22-
#include "util/json.hpp"
2313
#include "wlr-foreign-toplevel-management-unstable-v1-client-protocol.h"
2414

2515
namespace waybar::modules::wlr {
2616

2717
struct widget_geometry {
28-
int x, y, w, h;
18+
double x, y;
19+
int w, h;
2920
};
3021

3122
class Taskbar;
@@ -45,13 +36,13 @@ class Task {
4536
INVALID = (1 << 4)
4637
};
4738
// made public so TaskBar can reorder based on configuration.
48-
Gtk::Button button;
39+
Glib::RefPtr<Gtk::Button> const button;
4940
struct widget_geometry minimize_hint;
5041

5142
private:
5243
static uint32_t global_id;
44+
Glib::RefPtr<Gtk::GestureClick> const controllClick_;
5345

54-
private:
5546
const waybar::Bar &bar_;
5647
const Json::Value &config_;
5748
Taskbar *tbar_;
@@ -80,15 +71,9 @@ class Task {
8071
std::string app_id_;
8172
uint32_t state_ = 0;
8273

83-
int32_t drag_start_x;
84-
int32_t drag_start_y;
85-
int32_t drag_start_button = -1;
86-
87-
private:
8874
std::string repr() const;
8975
std::string state_string(bool = false) const;
9076
void set_minimize_hint();
91-
void on_button_size_allocated(Gtk::Allocation &alloc);
9277
void set_app_info_from_app_id_list(const std::string &app_id_list);
9378
bool image_load_icon(Gtk::Image &image, const Glib::RefPtr<Gtk::IconTheme> &icon_theme,
9479
Glib::RefPtr<Gio::DesktopAppInfo> app_info, int size);
@@ -105,7 +90,6 @@ class Task {
10590
bool active() const { return state_ & ACTIVE; }
10691
bool fullscreen() const { return state_ & FULLSCREEN; }
10792

108-
public:
10993
/* Callbacks for the wlr protocol */
11094
void handle_title(const char *);
11195
void handle_app_id(const char *);
@@ -116,22 +100,14 @@ class Task {
116100
void handle_closed();
117101

118102
/* Callbacks for Gtk events */
119-
bool handle_clicked(GdkEventButton *);
120-
bool handle_button_release(GdkEventButton *);
121-
bool handle_motion_notify(GdkEventMotion *);
122-
void handle_drag_data_get(const Glib::RefPtr<Gdk::DragContext> &context,
123-
Gtk::SelectionData &selection_data, guint info, guint time);
124-
void handle_drag_data_received(const Glib::RefPtr<Gdk::DragContext> &context, int x, int y,
125-
Gtk::SelectionData selection_data, guint info, guint time);
103+
void handleClick(int n_press, double dx, double dy);
104+
bool handleDropData(const Glib::ValueBase &, double, double);
126105

127-
public:
128106
bool operator==(const Task &) const;
129107
bool operator!=(const Task &) const;
130108

131-
public:
132109
void update();
133110

134-
public:
135111
/* Interaction with the tasks */
136112
void maximize(bool);
137113
void minimize(bool);
@@ -169,10 +145,9 @@ class Taskbar : public waybar::AModule {
169145
void handle_toplevel_create(struct zwlr_foreign_toplevel_handle_v1 *);
170146
void handle_finished();
171147

172-
public:
173-
void add_button(Gtk::Button &);
174-
void move_button(Gtk::Button &, int);
175-
void remove_button(Gtk::Button &);
148+
void add_button(Glib::RefPtr<Gtk::Button>);
149+
void move_button(Glib::RefPtr<Gtk::Button>, int);
150+
void remove_button(Glib::RefPtr<Gtk::Button>);
176151
void remove_task(uint32_t);
177152

178153
bool show_output(struct wl_output *) const;

meson.build

+2-1
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,12 @@ man_files += files('man/waybar-sway-language.5.scd',
263263
'man/waybar-sway-scratchpad.5.scd',
264264
'man/waybar-sway-window.5.scd',
265265
'man/waybar-sway-workspaces.5.scd')
266-
if 1 == 0
266+
267267
add_project_arguments('-DHAVE_WLR_TASKBAR', language: 'cpp')
268268
src_files += files('src/modules/wlr/taskbar.cpp')
269269
man_files += files('man/waybar-wlr-taskbar.5.scd')
270270

271+
if 1 == 0
271272
add_project_arguments('-DHAVE_RIVER', language: 'cpp')
272273
src_files += files('src/modules/river/layout.cpp',
273274
'src/modules/river/mode.cpp',

0 commit comments

Comments
 (0)