Skip to content

Commit

Permalink
Move display connection external
Browse files Browse the repository at this point in the history
Signed-off-by: Joel Winarske <joel.winarske@gmail.com>
  • Loading branch information
jwinarske committed May 6, 2024
1 parent 3868151 commit 54d4680
Show file tree
Hide file tree
Showing 13 changed files with 466 additions and 433 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (NOT CMAKE_BUILD_TYPE)
endif ()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_DIR}/third_party/sanitizers-cmake/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/third_party/sanitizers-cmake/cmake)

if (NOT BUILD_NUMBER)
set(BUILD_NUMBER 0)
Expand Down
5 changes: 4 additions & 1 deletion cmake/wayland.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ endmacro()
set(WAYLAND_PROTOCOL_SOURCES)

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/protocols)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/protocols)

add_protocol(${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml)
add_protocol(${CMAKE_CURRENT_SOURCE_DIR}/third_party/agl/protocol/agl-shell.xml)
Expand Down Expand Up @@ -121,6 +120,10 @@ configure_file(cmake/wayland-protocols.h.in ${CMAKE_CURRENT_BINARY_DIR}/protocol

add_library(wayland-gen STATIC ${WAYLAND_PROTOCOL_SOURCES})
target_link_libraries(wayland-gen PUBLIC PkgConfig::WAYLAND)
target_include_directories(wayland-gen PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/protocols
)

if (IPO_SUPPORT_RESULT)
set_property(TARGET wayland-gen PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
Expand Down
3 changes: 0 additions & 3 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,5 @@ static constexpr uint32_t kFractionalScaleManagerMinVersion = UINT32_C(1);
static constexpr uint32_t kXdgDecorationManagerMinVersion = UINT32_C(1);
static constexpr uint32_t kWestonCaptureV1MinVersion = UINT32_C(1);

/// Logging Constants
static constexpr int64_t kLogFlushInterval = INT64_C(5);


#endif // INCLUDE_CONFIG_H_
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ add_library(waypp
${SEAT_SRC}
${WINDOW_SRC}
command.cc
logging.cc
)
if (BUILD_STANDALONE)
# logging.cc
endif ()

if (ENABLE_XDG_CLIENT)
target_sources(waypp PRIVATE
Expand Down
2 changes: 2 additions & 0 deletions src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include "config.h"

static constexpr int32_t kLogFlushInterval = INT32_C(5);

Logging::Logging() {
console_sink_ = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
logger_ = std::make_shared<spdlog::logger>("waypp", console_sink_);
Expand Down
96 changes: 49 additions & 47 deletions src/seat/seat.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,72 +35,74 @@ class Touch;
class Seat;

class SeatObserver {
public:
virtual ~SeatObserver() = default;
public:
virtual ~SeatObserver() = default;

virtual void notify_seat_name(Seat *seat,
struct wl_seat *wl_seat,
const char *name) = 0;
virtual void notify_seat_name(Seat* seat,
struct wl_seat* wl_seat,
const char* name) = 0;

virtual void notify_seat_capabilities(Seat *seat,
struct wl_seat *wl_seat,
uint32_t caps) = 0;
virtual void notify_seat_capabilities(Seat* seat,
struct wl_seat* wl_seat,
uint32_t caps) = 0;
};

class Seat {
public:
explicit Seat(struct wl_seat *seat, struct wl_shm *wl_shm,
struct wl_compositor *wl_compositor, bool disable_cursor = false);
public:
explicit Seat(struct wl_seat* seat,
struct wl_shm* wl_shm,
struct wl_compositor* wl_compositor,
bool disable_cursor = false);

~Seat();
~Seat();

void register_observer(SeatObserver *observer) {
observers_.push_back(observer);
}
void register_observer(SeatObserver* observer) {
observers_.push_back(observer);
}

void unregister_observer(SeatObserver *observer) {
observers_.remove(observer);
}
void unregister_observer(SeatObserver* observer) {
observers_.remove(observer);
}

[[nodiscard]] struct wl_seat *get_seat() const { return wl_seat_; }
[[nodiscard]] struct wl_seat* get_seat() const { return wl_seat_; }

[[nodiscard]] uint32_t get_capabilities() const { return capabilities_; }
[[nodiscard]] uint32_t get_capabilities() const { return capabilities_; }

[[nodiscard]] const std::string &get_name() const { return name_; }
[[nodiscard]] const std::string& get_name() const { return name_; }

[[nodiscard]] std::optional<Keyboard *> get_keyboard() const;
[[nodiscard]] std::optional<Keyboard*> get_keyboard() const;

[[nodiscard]] std::optional<Pointer *> get_pointer() const;
[[nodiscard]] std::optional<Pointer*> get_pointer() const;

// Disallow copy and assign.
Seat(const Seat &) = delete;
// Disallow copy and assign.
Seat(const Seat&) = delete;

Seat &operator=(const Seat &) = delete;
Seat& operator=(const Seat&) = delete;

private:
struct wl_seat *wl_seat_;
uint32_t capabilities_{};
std::string name_;
struct wl_shm *wl_shm_;
struct wl_compositor *wl_compositor_;
bool disable_cursor_;
private:
struct wl_seat* wl_seat_;
uint32_t capabilities_{};
std::string name_;
struct wl_shm* wl_shm_;
struct wl_compositor* wl_compositor_;
bool disable_cursor_;

std::list<SeatObserver *> observers_{};
std::list<SeatObserver*> observers_{};

std::unique_ptr<Keyboard> keyboard_;
std::unique_ptr<Pointer> pointer_;
std::unique_ptr<Touch> touch_;
std::unique_ptr<Keyboard> keyboard_;
std::unique_ptr<Pointer> pointer_;
std::unique_ptr<Touch> touch_;

static void handle_capabilities(void *data,
struct wl_seat *wl_seat,
uint32_t caps);
static void handle_capabilities(void* data,
struct wl_seat* wl_seat,
uint32_t caps);

static void handle_name(void *data,
struct wl_seat *wl_seat,
const char *name);
static void handle_name(void* data,
struct wl_seat* wl_seat,
const char* name);

static constexpr struct wl_seat_listener listener_ = {
.capabilities = handle_capabilities,
.name = handle_name,
};
static constexpr struct wl_seat_listener listener_ = {
.capabilities = handle_capabilities,
.name = handle_name,
};
};
Loading

0 comments on commit 54d4680

Please sign in to comment.