Browse Source

Add build target for windows. (This only build a very striped version\!)

master
Olaf Schulz 4 years ago
parent
commit
077fc067d7
  1. 117
      Makefile
  2. 2
      src/key-overlay.vala
  3. 10
      src/main.vala
  4. 96
      src/neo-window.vala

117
Makefile

@ -7,7 +7,7 @@
ICON ?= indicator
# Build type. Possible values:
# debug, release
# debug, release, win
BUILD_TYPE ?= release
BINNAME = neo_layout_viewer
@ -20,8 +20,26 @@ APPNAME = NeoLayoutViewer
GIT_COMMIT_VERSION=$(shell git log --oneline --max-count=1 | head --bytes=7)
ENV_FILE=.build_env
#STATIC=-static
#WIN = 1
ifeq ($(WIN),)
NL = \n
BINEXT =
else
BUILD_TYPE = win
BINEXT = .exe
ICON = tray
PKG_CONFIG_PATH=${HOME}/software/gtk/gtk+-3.10_win64/lib/pkgconfig
GCC_WIN = x86_64-w64-mingw32-gcc -mwindows
GCC_WIN_FLAGS =$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags --libs gtk+-3.0 gee-$(GEEVERSION))
endif
# compiler options for a debug build
VALAC_DEBUG_OPTS = -g --save-temps
#VALAC_DEBUG_OPTS = -g
# compiler options for a release build
VALAC_RELEASE_OPTS = -X -O2 --disable-assert
#########################################################
EXEC_PREFIX = $(PREFIX)
@ -34,26 +52,36 @@ VAPIDIR = --vapidir=vapi/
# Source files
SRC = src/version.vala \
src/main.vala \
src/unique.vala \
src/neo-window.vala \
src/key-overlay.vala \
src/config-manager.vala \
src/config-manager.vala
ifeq ($(WIN),)
VALAC_DEBUG_OPTS += -D _NO_WIN
VALAC_RELEASE_OPTS += -D _NO_WIN
SRC += src/key-overlay.vala \
src/unique.vala \
src/keybinding-manager.vala \
csrc/keysend.c \
csrc/checkModifier.c
else
endif
# Asset files
ASSET_FILES=$(wildcard assets/**/*.png)
#test for valac version, workaround for Arch Linux bug
ifeq ($(wildcard /usr/include/gee-0.8),)
ifeq ($(wildcard /mingw64/include/gee-0.8),)
GEEVERSION=1.0
else
GEEVERSION=0.8
endif
else
GEEVERSION=0.8
endif
# packges
PKGS = --pkg x11 --pkg keysym --pkg gtk+-3.0 --pkg gee-$(GEEVERSION) --pkg gdk-x11-3.0 --pkg posix --pkg unique-3.0
PKGS = --pkg x11 --pkg keysym --pkg gtk+-3.0 --pkg gee-$(GEEVERSION) --pkg gdk-x11-3.0 --pkg posix --pkg unique-3.0 --pkg gdk-3.0
# Add some args if tray icon is demanded.
ifeq ($(ICON),tray)
@ -64,23 +92,16 @@ SRC += src/indicator.vala
PKGS += --pkg appindicator3-0.1
endif
# compiler options for a debug build
VALAC_DEBUG_OPTS = -g --save-temps
#VALAC_DEBUG_OPTS = -g
# compiler options for a release build
VALAC_RELEASE_OPTS = -X -O2 --disable-assert
.PHONY: debug release install clean last_build_env
# .FORCE: last_build_env
# the 'all' target build a debug build
all: $(BINDIR) info last_build_env $(BINDIR)/$(BINNAME)
all: $(BINDIR) info last_build_env $(BINDIR)/$(BINNAME)$(BINEXT)
@echo "Done"
$(BINDIR)/$(BINNAME): $(SRC) Makefile
make bulid_$(BUILD_TYPE)
$(BINDIR)/$(BINNAME)$(BINEXT): $(SRC) Makefile
make build_$(BUILD_TYPE)
# Remove binary if current env differs from last build env
# This toggles a rebuild.
@ -89,29 +110,29 @@ last_build_env:
&& echo "Same environment as last build.") \
|| (echo "Env has changed. Force build" \
&& env | sort > "$(ENV_FILE)" \
&& rm -f $(BINDIR)/$(BINNAME)\
&& rm -f $(BINDIR)/$(BINNAME)$(BINEXT)\
)
# the 'release' target builds a release build
# you might want disable asserts also
release: $(BINDIR) clean bulid_release
release: $(BINDIR) clean build_release
info:
@echo " \n"\
"Buildtype: $(BUILD_TYPE)\n" \
"Trayicon: $(ICON)\n" \
"\n" \
"Notes:\n" \
" Use 'ICON=... make' to switch type of panel menu.\n" \
" indicator: For gnome 3.x (default)\n" \
" tray: For gnome 2.x (default)\n" \
" none: Disables icon\n\n" \
" Use 'BUILD_TYPE=[release|debug] make' to switch build type\n\n" \
@echo " $(NL)"\
"Buildtype: $(BUILD_TYPE)$(NL)" \
"Trayicon: $(ICON)$(NL)" \
"$(NL)" \
"Notes:$(NL)" \
" Use 'ICON=... make' to switch type of panel menu.$(NL)" \
" indicator: For gnome 3.x (default)$(NL)" \
" tray: For gnome 2.x (default)$(NL)" \
" none: Disables icon$(NL)$(NL)" \
" Use 'BUILD_TYPE=[release|debug] make' to switch build type$(NL)$(NL)" \
gen_version:
@echo "namespace NeoLayoutViewer{\n" \
"public const string GIT_COMMIT_VERSION = \"$(GIT_COMMIT_VERSION)\";\n" \
"public const string SHARED_ASSETS_PATH = \"$(DATADIR)/$(APPNAME)/assets\";\n" \
@echo "namespace NeoLayoutViewer{$(NL)" \
"public const string GIT_COMMIT_VERSION = \"$(GIT_COMMIT_VERSION)\";$(NL)" \
"public const string SHARED_ASSETS_PATH = \"$(DATADIR)/$(APPNAME)/assets\";$(NL)" \
"}" \
> src/version.vala
@ -119,24 +140,42 @@ $(BINDIR):
@mkdir -p $(BINDIR)
@ln -s ../assets bin/assets
bulid_debug: gen_version
# @echo $(VALAC) $(VAPIDIR) $(VALAC_DEBUG_OPTS) $(SRC) -o $(BINDIR)/$(BINNAME) $(PKGS) $(CC_INCLUDES)
$(VALAC) $(VAPIDIR) $(VALAC_DEBUG_OPTS) $(SRC) -o $(BINDIR)/$(BINNAME) $(PKGS) $(CC_INCLUDES)
build_debug: gen_version
# @echo $(VALAC) $(VAPIDIR) $(VALAC_DEBUG_OPTS) $(SRC) -o $(BINDIR)/$(BINNAME)$(BINEXT) $(PKGS) $(CC_INCLUDES)
$(VALAC) $(VAPIDIR) $(VALAC_DEBUG_OPTS) $(SRC) -o $(BINDIR)/$(BINNAME)$(BINEXT) $(PKGS) $(CC_INCLUDES)
build_release: gen_version
$(VALAC) $(VAPIDIR) $(VALAC_RELEASE_OPTS) $(SRC) -o $(BINDIR)/$(BINNAME)$(BINEXT) $(PKGS) $(CC_INCLUDES)
# Two staged compiling
build_release2: gen_version
$(VALAC) --ccode $(VAPIDIR) $(VALAC_RELEASE_OPTS) $(SRC) $(PKGS) $(CC_INCLUDES)
gcc $(SRC:.vala=.c) $(CC_INCLUDES) -o $(BINDIR)/$(BINNAME)$(BINEXT) \
`pkg-config --cflags --libs gtk+-3.0 gee-$(GEEVERSION) unique-3.0`
build_win: gen_version
$(VALAC) $(VAPIDIR) $(VALAC_RELEASE_OPTS) $(SRC) -o $(BINDIR)/$(BINNAME)$(BINEXT) $(PKGS) $(CC_INCLUDES)
bulid_release: gen_version
$(VALAC) $(VAPIDIR) $(VALAC_RELEASE_OPTS) $(SRC) -o $(BINDIR)/$(BINNAME) $(PKGS) $(CC_INCLUDES)
build_cross_win: build_ccode
echo "Flags: $(GCC_WIN_FLAGS)"
PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \
$(VALAC) --ccode $(VAPIDIR) $(VALAC_RELEASE_OPTS) $(SRC) $(PKGS) $(CC_INCLUDES)
PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \
$(GCC_WIN) $(SRC:.vala=.c) -o $(BINDIR)/$(BINNAME)$(BINEXT) $(GCC_WIN_FLAGS)
install:
test -f $(BINDIR)/$(BINNAME) || make all
test -f $(BINDIR)/$(BINNAME)$(BINEXT) || make all
install -d $(EXEC_PREFIX)/bin
install -D -m 0755 $(BINDIR)/$(BINNAME) $(EXEC_PREFIX)/bin
install -D -m 0755 $(BINDIR)/$(BINNAME)$(BINEXT) $(EXEC_PREFIX)/bin
$(foreach ASSET_FILE,$(ASSET_FILES), install -D -m 0644 $(ASSET_FILE) $(DATADIR)/$(APPNAME)/$(ASSET_FILE) ; )
uninstall:
@rm -v $(EXEC_PREFIX)/bin/$(BINNAME)
@rm -v $(EXEC_PREFIX)/bin/$(BINNAME)$(BINEXT)
@rm -v -r $(DATADIR)/$(APPNAME)
# clean all build files
clean:
@rm -v -fr *~ *.c src/*.c src/*~
run:
bin/neo_layout_viewer

2
src/key-overlay.vala

@ -695,6 +695,7 @@ namespace NeoLayoutViewer {
int modi = winMain.getActiveModifierMask({4,5}); //ctrl+alt mask
if (ks < 1) return false;
#if _NO_WIN
if (modi == 0 || true) {
// Alt-Mask do not work :-(
keysend(ks,modi);
@ -702,6 +703,7 @@ namespace NeoLayoutViewer {
//debug("Variante mit zweitem Modifier.");
keysend2(ks,modi & Gdk.ModifierType.CONTROL_MASK, modi & Gdk.ModifierType.MOD1_MASK);
}
#endif
return false;
});

10
src/main.vala

@ -3,7 +3,9 @@ using X;
namespace NeoLayoutViewer{
public NeoWindow neo_win;
#if _NO_WIN
public KeybindingManager manager;
#endif
public ConfigManager configm;
#if tray
@ -60,13 +62,17 @@ namespace NeoLayoutViewer{
neo_win = new NeoWindow (slayer, configm.getConfig());
#if _NO_WIN
var app = showPreviousInstance("org.gnome.neo_layout_viewer", neo_win);
if (app == null) {
return 0;
}
#endif
#if _NO_WIN
manager = new KeybindingManager(neo_win);
#endif
#if tray
neo_tray = new AppStatusIcon(neo_win);
@ -76,8 +82,10 @@ namespace NeoLayoutViewer{
neo_indicator = new NeoIndicator(neo_win);
#endif
#if _NO_WIN
manager.bind(configm.getConfig().get("show_shortcut"), ()=>{neo_win.toggle();});
manager.bind(configm.getConfig().get("move_shortcut"), ()=>{neo_win.numkeypad_move(0);});
#endif
//move window (Fehlerquelle: config von configm ist im allgemeinen nicht gleich neo_win.config?! Derzeit gleiches Objekt.)
@ -165,8 +173,10 @@ Tastenkombinationen:
}
#if _NO_WIN
/* Extern C routines */
extern int keysend(uint keysym, int modifiers);
extern int keysend2(uint keysym, uint modsym1, uint modsym2);
extern bool checkCapsLock(X.Display* d);
extern void checkModifier(X.Display* d, int* keycodes, int nkeycodes, int* pressed );
#endif

96
src/neo-window.vala

@ -145,16 +145,41 @@ namespace NeoLayoutViewer {
this.layer = int.parse(slayer);
if (this.layer < 1 || this.layer > 6) { this.layer = 1; }
//Lade die Pngs der sechs Ebenen
// Crawl dimensions of screen/display/monitor
// Should be done before load_image_buffer() is called.
screen_dim_auto[0] = (config.get("screen_width") == "auto");
screen_dim_auto[1] = (config.get("screen_height") == "auto");
if (screen_dim_auto[0]) {
this.screen_dim[0] = this.get_screen_width();
this.screen_dim_auto[0] = false; // Disables further re-evaluations
} else {
this.screen_dim[0] = int.max(1, int.parse(config.get("screen_width")));
}
if(screen_dim_auto[1]) {
this.screen_dim[1] = this.get_screen_height();
this.screen_dim_auto[1] = false; // Disables further re-evaluations
} else {
this.screen_dim[1] = int.max(1, int.parse(config.get("screen_height")));
}
// Load pngs of all six layers
this.load_image_buffer();
this.image = new Gtk.Image();//.from_pixbuf(this.image_buffer[layer]);
image.show();
render_page();
var fixed = new Fixed();
fixed.put(this.image, 0, 0);
#if _NO_WIN
fixed.put(new KeyOverlay(this), 0, 0);
#endif
this.status = new Label("");
status.show();
@ -173,7 +198,7 @@ namespace NeoLayoutViewer {
this.button_press_event.connect(on_button_pressed);
this.destroy.connect(Gtk.main_quit);
this.set_gravity(Gdk.Gravity.SOUTH);
//this.set_gravity(Gdk.Gravity.SOUTH);
this.decorated = (config.get("window_decoration") != "0");
this.skip_taskbar_hint = true;
@ -183,23 +208,6 @@ namespace NeoLayoutViewer {
//Nicht selektierbar (für virtuelle Tastatur)
this.set_accept_focus((config.get("window_selectable") != "0"));
screen_dim_auto[0] = (config.get("screen_width") == "auto");
screen_dim_auto[1] = (config.get("screen_height") == "auto");
//Dimension des Bildschirms festlegen
if (screen_dim_auto[0]) {
screen_dim[0] = Gdk.Screen.width();
} else {
screen_dim[0] = int.max(1, int.parse(config.get("screen_width")));
}
if(screen_dim_auto[1]) {
screen_dim[1] = Gdk.Screen.height();
} else {
screen_dim[1] = int.max(1, int.parse(config.get("screen_height")));
}
if( this.config.get("show_on_startup") != "0" ){
//Move ist erst nach show() erfolgreich
this.numkeypad_move(int.parse(config.get("position")));
@ -256,8 +264,8 @@ namespace NeoLayoutViewer {
}
public void numkeypad_move(int pos){
int screen_width = (screen_dim_auto[0] ? Gdk.Screen.width() : screen_dim[0]);
int screen_height = (screen_dim_auto[1] ? Gdk.Screen.height() : screen_dim[1]);
int screen_width = this.get_screen_width();
int screen_height = this.get_screen_height();
int x,y,w,h;
this.get_size(out w, out h);
@ -331,7 +339,7 @@ namespace NeoLayoutViewer {
this.image_buffer = new Gdk.Pixbuf[7];
this.image_buffer[0] = open_image_str(@"$(config.get("asset_folder"))/icons/Neo-Icon.png");
int screen_width = Gdk.Screen.width();
int screen_width = this.get_screen_width(); //Gdk.Screen.width();
int max_width = (int) (double.parse(this.config.get("max_width")) * screen_width);
int min_width = (int) (double.parse(this.config.get("min_width")) * screen_width);
int width = int.min(int.max(int.parse(config.get("width")),min_width),max_width);
@ -505,11 +513,55 @@ namespace NeoLayoutViewer {
public int get_screen_width(){
// Return value derived from config.get("screen_width")) or Gdk.Screen.width()
if( this.screen_dim_auto[0] ){
//Re-evaluate
#if GTK_MINOR_VERSION == 18 || GTK_MINOR_VERSION == 19 || GTK_MINOR_VERSION == 20 || GTK_MINOR_VERSION == 21
// Old variant for ubuntu 16.04 ( '<' check not defined in vala preprozessor :-()
var display = Gdk.Display.get_default();
var screen = display.get_default_screen();
//Gdk.Rectangle geometry = {0, 0, screen.get_width(), screen.get_height()};
screen_dim[0] = screen.get_width();
#else
var display = Gdk.Display.get_default();
var screen = this.get_screen();
var monitor = display.get_monitor_at_window(screen.get_active_window());
//Note that type of this is Gtk.Window, but get_active_window() return Gdk.Window
if( monitor == null){
monitor = display.get_primary_monitor();
}
Gdk.Rectangle geometry = monitor.get_geometry();
screen_dim[0] = geometry.width;
#endif
}
return screen_dim[0];
}
public int get_screen_height(){
// Return value derived from config.get("screen_height")) or Gdk.Screen.height()
if( this.screen_dim_auto[1] ){
//Re-evaluate
#if GTK_MINOR_VERSION == 18 || GTK_MINOR_VERSION == 19 || GTK_MINOR_VERSION == 20 || GTK_MINOR_VERSION == 21
// Old variant for ubuntu 16.04 ( '<' check not defined in vala preprozessor :-()
var display = Gdk.Display.get_default();
var screen = display.get_default_screen();
//Gdk.Rectangle geometry = {0, 0, screen.get_width(), screen.get_height()};
screen_dim[1] = screen.get_height();
#else
var display = Gdk.Display.get_default();
var screen = this.get_screen();
var monitor = display.get_monitor_at_window(screen.get_active_window());
//Note that type of this is Gtk.Window, but get_active_window() return Gdk.Window
if( monitor == null){
monitor = display.get_primary_monitor();
}
Gdk.Rectangle geometry = monitor.get_geometry();
screen_dim[1] = geometry.height;
#endif
}
return screen_dim[1];
}

Loading…
Cancel
Save