feynman/src/compositor.h

126 lines
3.4 KiB
C

/*
* Feynman -- Wayland compositor for GNU Emacs
*
* Copyright (c) 2022 Sameer Rahmani <lxsameer@gnu.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FEYNMAN_COMPOSITOR_H
#define FEYNMAN_COMPOSITOR_H
#include <linux/limits.h>
#include <pthread.h>
#include <wayland-server-core.h>
#include <wayland-server.h>
#include <wlr/backend.h>
#include <wlr/render/allocator.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_pointer.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/types/wlr_xdg_shell.h>
#include <wlr/util/log.h>
#include <xkbcommon/xkbcommon.h>
enum feynman_cursor_mode
{
FEYNMAN_CURSOR_PASSTHROUGH,
FEYNMAN_CURSOR_MOVE,
FEYNMAN_CURSOR_RESIZE,
};
// This struct holds the state of the WM
struct feynman_server
{
struct wl_display *wl_display;
struct wlr_backend *backend;
struct wlr_renderer *renderer;
struct wlr_allocator *allocator;
struct wlr_scene *scene;
struct wlr_xdg_shell *xdg_shell;
struct wl_listener new_xdg_surface;
struct wl_list views;
struct wlr_cursor *cursor;
struct wlr_xcursor_manager *cursor_mgr;
struct wl_listener cursor_motion;
struct wl_listener cursor_motion_absolute;
struct wl_listener cursor_button;
struct wl_listener cursor_axis;
struct wl_listener cursor_frame;
struct wlr_seat *seat;
struct wl_listener new_input;
struct wl_listener request_cursor;
struct wl_listener request_set_selection;
struct wl_list keyboards;
enum feynman_cursor_mode cursor_mode;
struct feynman_view *grabbed_view;
double grab_x, grab_y;
struct wlr_box grab_geobox;
uint32_t resize_edges;
struct wlr_output_layout *output_layout;
struct wl_list outputs;
struct wl_listener new_output;
char log_file[PATH_MAX];
pthread_t server_thread_id;
};
struct feynman_output
{
struct wl_list link;
struct feynman_server *server;
struct wlr_output *wlr_output;
struct wl_listener frame;
};
struct feynman_view
{
struct wl_list link;
struct feynman_server *server;
struct wlr_xdg_surface *xdg_surface;
struct wlr_scene_node *scene_node;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener destroy;
struct wl_listener request_move;
struct wl_listener request_resize;
int x, y;
};
struct feynman_keyboard
{
struct wl_list link;
struct feynman_server *server;
struct wlr_input_device *device;
struct wl_listener modifiers;
struct wl_listener key;
};
int init_feynman_server (struct feynman_server *server);
void start_feynman (struct feynman_server *server);
void stop_feynman (struct feynman_server *server);
#endif