Skip to content

Commit

Permalink
remove use of friend
Browse files Browse the repository at this point in the history
Signed-off-by: Joel Winarske <[email protected]>
  • Loading branch information
jwinarske committed May 6, 2024
1 parent fc4c738 commit efe33eb
Show file tree
Hide file tree
Showing 443 changed files with 69 additions and 60 deletions.
2 changes: 2 additions & 0 deletions examples/gl-shadertoy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ add_executable(gl-shadertoy shadertoy.cc)

target_compile_definitions(gl-shadertoy PRIVATE EGL_NO_X11 MESA_EGL_NO_X11_HEADERS)

target_include_directories(gl-shadertoy PRIVATE ${CMAKE_SOURCE_DIR}/third_party)

target_link_libraries(gl-shadertoy PRIVATE waypp wayland-gen PkgConfig::GLESv2 cxxopts::cxxopts)

if (IPO_SUPPORT_RESULT)
Expand Down
1 change: 1 addition & 0 deletions examples/vk-shadertoy/vk_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "vk_backend.h"

#include <optional>
#include <utility>

#include "logging.h"
Expand Down
1 change: 1 addition & 0 deletions examples/vk-shadertoy/vk_image.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include "vk_image.h"

#include <cmath>
#include "vk_common.h"


Expand Down
4 changes: 0 additions & 4 deletions src/window/egl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>

class SurfaceEgl;

class Egl {
public:

Expand Down Expand Up @@ -61,8 +59,6 @@ class Egl {
Egl &operator=(const Egl &) = delete;

private:
friend class SurfaceEgl;

std::vector<EGLint> context_attribs_;
std::vector<EGLint> config_attribs_;
int buffer_bpp_;
Expand Down
4 changes: 0 additions & 4 deletions src/window/feedback.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

class Feedback;

class Window;

class FeedbackObserver {
public:
virtual ~FeedbackObserver() = default;
Expand Down Expand Up @@ -42,8 +40,6 @@ class Feedback {
~Feedback();

private:
friend Window;

static unsigned sequence_;

struct wp_presentation *wp_presentation_;
Expand Down
40 changes: 36 additions & 4 deletions src/window/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class Output;

class WindowManager;

class XdgTopLevel;

class Window {
public:

Expand Down Expand Up @@ -85,10 +83,46 @@ class Window {

[[nodiscard]] int get_height() const { return logical_size_.height; }

void set_max_width(int width) { max_width_ = width; }

void set_max_height(int height) { max_height_ = height; }

void set_window_width(int width) { window_size_.width = width; }

void set_window_height(int height) { window_size_.height = height; }

void set_init_width(int width) { init_width_ = width; }

void set_init_height(int height) { init_height_ = height; }

void set_width(int width) { width_ = width; }

void set_height(int height) { height_ = height; }

[[nodiscard]] int get_init_width() const { return init_width_; }

[[nodiscard]] int get_init_height() const { return init_height_; }

void set_fullscreen(bool fullscreen) { fullscreen_ = fullscreen; }

void set_maximized(bool maximized) { maximized_ = maximized; }

void set_resize(bool resize) { resize_ = resize; }

void set_activated(bool activated) { activated_ = activated; }

void set_valid(bool valid) { valid_ = valid; }

void set_needs_buffer_geometry_update(bool value) { needs_buffer_geometry_update_ = value; }

[[nodiscard]] int32_t get_max_width() const { return max_width_; }

[[nodiscard]] int32_t get_max_height() const { return max_height_; }

[[nodiscard]] bool get_fullscreen() const { return fullscreen_; }

[[nodiscard]] bool get_maximized() const { return maximized_; }

[[nodiscard]] void *get_user_data() const { return user_data_; }

void set_user_data(void *user_data) { user_data_ = user_data; }
Expand Down Expand Up @@ -131,8 +165,6 @@ class Window {
Window &operator=(const Window &) = delete;

private:
friend XdgTopLevel;

WindowManager *wm_;
const std::map<struct wl_output *, std::unique_ptr<Output>> &outputs_;
struct wp_tearing_control_v1 *tearing_control_{};
Expand Down
50 changes: 26 additions & 24 deletions src/window/xdg_toplevel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ XdgTopLevel::XdgTopLevel(WindowManager *wm, const char *title, const char *app_i
exit(EXIT_FAILURE);
}

window_size_.width = width;
window_size_.height = height;
set_window_width(width);
set_window_height(height);

xdg_surface_ = xdg_wm_base_get_xdg_surface(xdg_wm_base, wl_surface_);
auto surface = get_surface();

xdg_surface_ = xdg_wm_base_get_xdg_surface(xdg_wm_base, surface);
xdg_surface_add_listener(xdg_surface_, &xdg_surface_listener_, this);

xdg_toplevel_ = xdg_surface_get_toplevel(xdg_surface_);
Expand All @@ -62,7 +64,7 @@ XdgTopLevel::XdgTopLevel(WindowManager *wm, const char *title, const char *app_i
}

wait_for_configure_ = true;
wl_surface_commit(wl_surface_);
wl_surface_commit(surface);

// this makes the start-up from the beginning with the correct dimensions
// like starting as maximized/fullscreen, rather than starting up as floating
Expand Down Expand Up @@ -136,46 +138,46 @@ void XdgTopLevel::handle_xdg_toplevel_configure(
return;
}

tl->fullscreen_ = false;
tl->maximized_ = false;
tl->resize_ = false;
tl->activated_ = false;
tl->Window::set_fullscreen(false);
tl->set_maximized(false);
tl->set_resize(false);
tl->set_activated(false);

const uint32_t *state;
WL_ARRAY_FOR_EACH(state, states, const uint32_t*) {
switch (*state) {
case XDG_TOPLEVEL_STATE_FULLSCREEN:
SPDLOG_DEBUG("XDG_TOPLEVEL_STATE_FULLSCREEN");
tl->fullscreen_ = true;
tl->Window::set_fullscreen(true);
break;
case XDG_TOPLEVEL_STATE_MAXIMIZED:
SPDLOG_DEBUG("XDG_TOPLEVEL_STATE_MAXIMIZED");
tl->maximized_ = true;
tl->set_maximized(true);
break;
case XDG_TOPLEVEL_STATE_RESIZING:
SPDLOG_DEBUG("XDG_TOPLEVEL_STATE_RESIZING");
tl->resize_ = true;
tl->set_resize(true);
break;
case XDG_TOPLEVEL_STATE_ACTIVATED:
SPDLOG_DEBUG("XDG_TOPLEVEL_STATE_ACTIVATED");
tl->activated_ = true;
tl->set_activated(true);
break;
}
}

if (width > 0 && height > 0) {
if (!tl->fullscreen_ && !tl->maximized_) {
tl->init_width_ = width;
tl->init_height_ = height;
if (!tl->get_fullscreen() && !tl->get_maximized()) {
tl->set_init_width(width);
tl->set_init_height(height);
}
tl->width_ = width;
tl->height_ = height;
} else if (!tl->fullscreen_ && !tl->maximized_) {
tl->width_ = tl->init_width_;
tl->height_ = tl->init_height_;
tl->set_width(width);
tl->set_height(height);
} else if (!tl->get_fullscreen() && !tl->get_maximized()) {
tl->set_width(tl->get_init_width());
tl->set_height(tl->get_init_height());
}

tl->needs_buffer_geometry_update_ = true;
tl->set_needs_buffer_geometry_update(true);
}

/**
Expand All @@ -197,7 +199,7 @@ void XdgTopLevel::handle_xdg_toplevel_close(
if (w->xdg_toplevel_ != xdg_toplevel) {
return;
}
w->valid_ = false;
w->set_valid(false);
}

/**
Expand All @@ -218,8 +220,8 @@ void XdgTopLevel::handle_xdg_toplevel_configure_bounds(void *data,
return;
}
SPDLOG_DEBUG("Configure Bounds: {}x{}", width, height);
w->max_width_ = width;
w->max_height_ = height;
w->set_max_width(width);
w->set_max_height(height);
}

#endif
Expand Down
6 changes: 1 addition & 5 deletions src/window/xdg_toplevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,8 @@ class XdgTopLevel : public Window {

void set_title(const char *title) { xdg_toplevel_set_title(xdg_toplevel_, title); }

[[nodiscard]] bool get_fullscreen() const { return fullscreen_; }

void set_fullscreen() { xdg_toplevel_set_fullscreen(xdg_toplevel_, nullptr); }

[[nodiscard]] bool get_maximize() const { return maximized_; }

void set_maximize() { xdg_toplevel_set_maximized(xdg_toplevel_); }

void set_minimize() { xdg_toplevel_set_minimized(xdg_toplevel_); }
Expand All @@ -74,7 +70,7 @@ class XdgTopLevel : public Window {
void resize(int width, int height);

void set_surface_damage(int x, int y, int width, int height) {
wl_surface_damage(wl_surface_, x, y, width, height);
wl_surface_damage(get_surface(), x, y, width, height);
}

// Disallow copy and assign.
Expand Down
1 change: 1 addition & 0 deletions src/window_manager/agl_shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ std::string AglShell::edge_to_string(const enum agl_shell_edge mode) {
case AGL_SHELL_EDGE_RIGHT:
return "AGL_SHELL_EDGE_RIGHT";
}
return {};
}

void
Expand Down
4 changes: 0 additions & 4 deletions src/window_manager/registrar.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#include "drm_lease_device_v1.h"
#endif

class WindowManager;

class Registrar {
public:
typedef void (*RegistrarGlobalCallback)(
Expand Down Expand Up @@ -129,8 +127,6 @@ class Registrar {
Registrar &operator=(const Registrar &) = delete;

private:
friend WindowManager;

std::unique_ptr<std::map<std::string, RegistrarGlobalCallback>> registrar_global_;
std::unique_ptr<std::map<uint32_t, RegistrarGlobalRemoveCallback>> registrar_global_remove_;

Expand Down
9 changes: 1 addition & 8 deletions src/window_manager/window_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@
#include "registrar.h"
#include "window_manager_observer.h"

class AglShell;

class Registrar;

class XdgWindowManager;


class WindowManager : public Registrar {
public:
explicit WindowManager(bool disable_cursor = false, unsigned long ext_interface_count = 0,
Expand All @@ -47,7 +42,7 @@ class WindowManager : public Registrar {

[[nodiscard]] int display_dispatch() const;

[[nodiscard]] bool has_subcompositor() const { return wl_subcompositor_; }
[[nodiscard]] bool has_subcompositor() const { return get_compositor(); }

void register_task_observer(WindowManagerObserver *observer) {
observers_.push_back(observer);
Expand All @@ -67,8 +62,6 @@ class WindowManager : public Registrar {
WindowManager &operator=(const WindowManager &) = delete;

private:
friend XdgWindowManager;

GMainContext *context_;

std::list<WindowManagerObserver *> observers_{};
Expand Down
3 changes: 0 additions & 3 deletions src/window_manager/xdg_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

#include "output.h"

class Output;

class XdgOutput {
public:
XdgOutput(struct zxdg_output_manager_v1 *zxdg_output_manager_v1, struct wl_output *wl_output);
Expand Down Expand Up @@ -52,7 +50,6 @@ class XdgOutput {
XdgOutput &operator=(const XdgOutput &) = delete;

private:
friend Output;
struct zxdg_output_manager_v1 *zxdg_output_manager_v1_;

struct zxdg_output_v1 *zxdg_output_v1_;
Expand Down
4 changes: 0 additions & 4 deletions src/window_manager/xdg_window_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#include "window_manager.h"
#include "window/egl.h"

class AglShell;

class XdgTopLevel;


Expand Down Expand Up @@ -56,8 +54,6 @@ class XdgWindowManager : public WindowManager {
XdgWindowManager &operator=(const XdgWindowManager &) = delete;

private:
friend AglShell;

struct xdg_wm_base *xdg_wm_base_;
std::unique_ptr<XdgTopLevel> xdg_top_level_;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit efe33eb

Please sign in to comment.