Skip to content

Commit

Permalink
Clean code and build
Browse files Browse the repository at this point in the history
Move input inhibitor and toplevel grabber to their own subdir. This allows to make the build config cleaner.
  • Loading branch information
dkondor committed Nov 29, 2020
1 parent e20b878 commit f163e26
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 136 deletions.
61 changes: 0 additions & 61 deletions actiondb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,65 +406,4 @@ ActionListDiff::~ActionListDiff() {
actions.apps.erase(name); */
}

/* actions
void Button::run() {
fprintf(stderr, "Button action: %u\n", button);
}
void SendKey::run() {
if (!key)
return;
fprintf(stderr, "SendKey: %u\n", key);
// guint code = XKeysymToKeycode(dpy, key);
}
RModifiers ModAction::prepare() {
// todo: process modifiers
return nullptr;
}
RModifiers SendKey::prepare() {
// todo: process modifiers
return nullptr;
}
*/


/*
void SendText::run() {
for (Glib::ustring::iterator i = text.begin(); i != text.end(); i++)
if (!fake_char(*i))
fake_unicode(*i);
}
void Misc::run() {
switch (type) {
case SHOWHIDE:
win->show_hide();
return;
case UNMINIMIZE:
grabber->unminimize();
return;
case DISABLE:
disabled.set(!disabled.get());
return;
default:
return;
}
}
bool ButtonInfo::overlap(const ButtonInfo &bi) const {
if (button != bi.button)
return false;
if (state == AnyModifier || bi.state == AnyModifier)
return true;
return !((state ^ bi.state) & ~Gdk::ModifierType::LOCK_MASK &
~Gdk::ModifierType::MOD2_MASK);
}
bool mods_equal(RModifiers m1, RModifiers m2) {
return m1 && m2 && *m1 == *m2;
}
*/

2 changes: 1 addition & 1 deletion actions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "actiondb.h"
#include "stroke_draw.h"
#include "convert_keycodes.h"
#include "toplevel-grabber.h"
#include <toplevel-grabber.h>
#include <glibmm/i18n.h>
#include <gdkmm.h>
#include <gdk/gdkwayland.h>
Expand Down
2 changes: 1 addition & 1 deletion input_inhibitor.c → input-inhibitor/input_inhibitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/


#include "input_inhibitor.h"
#include <input_inhibitor.h>
#include <wlr-input-inhibitor-unstable-v1-client-protocol.h>
#include <gdk/gdkwayland.h>

Expand Down
File renamed without changes.
28 changes: 28 additions & 0 deletions input-inhibitor/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
client_protocols = [
'./wlr-input-inhibitor-unstable-v1.xml'
]

wl_protos_client_src = []
wl_protos_headers = []

foreach p : client_protocols
xml = join_paths(p)
wl_protos_headers += wayland_scanner_client.process(xml)
wl_protos_client_src += wayland_scanner_code.process(xml)
endforeach

lib_inhibitor_protos = static_library('wl_inhibitor_protos', wl_protos_client_src + wl_protos_headers,
dependencies: [wayland_client]) # for the include directory

protos = declare_dependency(
link_with: lib_inhibitor_protos,
sources: wl_protos_headers,
)

input_inhibitor = static_library('input_inhibitor', 'input_inhibitor.c',
dependencies: [wayland_client, protos, gdk])

input_inhibitor_dep = declare_dependency(
link_with: input_inhibitor,
include_directories: include_directories('.')
)
File renamed without changes.
89 changes: 18 additions & 71 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ desktop_dir = join_paths(datadir, 'applications')


# dependencies for loadable plugin
glibmm = dependency('glibmm-2.4')
boost = dependency('boost', modules: ['serialization'], static: false)
wayfire = dependency('wayfire')
wlroots = dependency('wlroots')
boost = dependency('boost', modules: ['serialization'], static: false)
wayfire = dependency('wayfire')
wlroots = dependency('wlroots')
wlserver = dependency('wayland-server')

glibmm = dependency("glibmm-2.4")

# additional dependencies for GUI
gtkmm = dependency('gtkmm-3.0')
gdkmm = dependency('gdkmm-3.0')
glib = dependency('glib-2.0')
gobject = dependency('gobject-2.0')
gtk = dependency('gtk+-3.0')
gdk = dependency('gdk-3.0')

gtkmm = dependency('gtkmm-3.0')
gdkmm = dependency('gdkmm-3.0')
glib = dependency('glib-2.0')
gobject = dependency('gobject-2.0')
gtk = dependency('gtk+-3.0')
gdk = dependency('gdk-3.0')

# resources (GUI layout)
gnome = import('gnome')
econf_res = gnome.compile_resources(
'ecres', 'resources.xml',
Expand All @@ -56,9 +56,8 @@ elif cpp.has_link_argument('-lstdc++fs')
endif


# protocol for keyboard grabber
# wayland-scanner -- needed for keyboard grabber and input inhibitor
wayland_client = dependency('wayland-client')

wayland_scanner = find_program('wayland-scanner')

wayland_scanner_code = generator(
Expand All @@ -73,73 +72,21 @@ wayland_scanner_client = generator(
arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
)

client_protocols = [
'./wlr-input-inhibitor-unstable-v1.xml'
]

wl_protos_client_src = []
wl_protos_headers = []

foreach p : client_protocols
xml = join_paths(p)
wl_protos_headers += wayland_scanner_client.process(xml)
wl_protos_client_src += wayland_scanner_code.process(xml)
endforeach

lib_inhibitor_protos = static_library('wl_inhibitor_protos', wl_protos_client_src + wl_protos_headers,
dependencies: [wayland_client]) # for the include directory

protos = declare_dependency(
link_with: lib_inhibitor_protos,
sources: wl_protos_headers,
)

# toplevel-grabber library and example program
grabber_protocols = [
'./wlr-foreign-toplevel-management-unstable-v1.xml'
]

grabber_protos_client_src = []
grabber_protos_headers = []

foreach p : grabber_protocols
xml = join_paths(p)
grabber_protos_headers += wayland_scanner_client.process(xml)
grabber_protos_client_src += wayland_scanner_code.process(xml)
endforeach

lib_grabber_protos = static_library('grabber_protos', grabber_protos_client_src + grabber_protos_headers,
dependencies: [wayland_client]) # for the include directory

lib_grabber_protos_dep = declare_dependency(
link_with: lib_grabber_protos,
sources: grabber_protos_headers,
)

toplevel_grabber = static_library('toplevel_grabber', 'toplevel-grabber.c',
dependencies: [wayland_client, lib_grabber_protos_dep],
c_args: ['-D_POSIX_C_SOURCE=200809L'])

toplevel_grabber_dep = declare_dependency(
link_with: toplevel_grabber,
sources: 'toplevel-grabber.h'
)

toplevel_grabber_test = executable('tl_grabber_test', 'toplevel-grabber-test.c',
dependencies: [toplevel_grabber_dep],
install: false)
subdir('input-inhibitor')
subdir('toplevel-grabber')

# note: this is code generated by Vala, compile it separately to
# silence warnings
cellib = static_library('cellib', 'cellrenderertextish.c',
dependencies: [glib, gobject, gtk, protos],
dependencies: [glib, gobject, gtk, input_inhibitor_dep],
c_args: ['-w'])

wconf_sources = ['main.cc', 'actiondb.cc', 'actions.cc', 'gesture.cc',
'stroke_draw.cc', 'stroke.c', 'convert_keycodes.cc',
"stroke_drawing_area.cpp", "input_inhibitor.c", econf_res]
"stroke_drawing_area.cpp", econf_res]
wconf = executable('wstroke-config', wconf_sources,
dependencies: [gtkmm, gdkmm, gdk, boost, protos, toplevel_grabber_dep],
dependencies: [gtkmm, gdkmm, boost, protos, input_inhibitor_dep, toplevel_grabber_dep],
install: true,
cpp_args: ['-DACTIONDB_CONVERT_CODES', '-DWLR_USE_UNSTABLE'],
link_with: cellib)
Expand Down
34 changes: 34 additions & 0 deletions toplevel-grabber/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# toplevel-grabber library and example program
grabber_protocols = [
'./wlr-foreign-toplevel-management-unstable-v1.xml'
]

grabber_protos_client_src = []
grabber_protos_headers = []

foreach p : grabber_protocols
xml = join_paths(p)
grabber_protos_headers += wayland_scanner_client.process(xml)
grabber_protos_client_src += wayland_scanner_code.process(xml)
endforeach

lib_grabber_protos = static_library('grabber_protos', grabber_protos_client_src + grabber_protos_headers,
dependencies: [wayland_client]) # for the include directory

lib_grabber_protos_dep = declare_dependency(
link_with: lib_grabber_protos,
sources: grabber_protos_headers,
)

toplevel_grabber = static_library('toplevel_grabber', 'toplevel-grabber.c',
dependencies: [wayland_client, lib_grabber_protos_dep],
c_args: ['-D_POSIX_C_SOURCE=200809L'])

toplevel_grabber_dep = declare_dependency(
link_with: toplevel_grabber,
include_directories: include_directories('.')
)

toplevel_grabber_test = executable('tl_grabber_test', 'toplevel-grabber-test.c',
dependencies: [toplevel_grabber_dep],
install: false)
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <wayland-client.h>
#include "toplevel-grabber.h"
#include <toplevel-grabber.h>

static int is_done = 0;

Expand Down
2 changes: 1 addition & 1 deletion toplevel-grabber.c → toplevel-grabber/toplevel-grabber.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include "wlr-foreign-toplevel-management-unstable-v1-client-protocol.h"
#include "toplevel-grabber.h"
#include <toplevel-grabber.h>

typedef struct zwlr_foreign_toplevel_handle_v1 wfthandle;

Expand Down
File renamed without changes.

0 comments on commit f163e26

Please sign in to comment.