Began to implement the messaging protocol
This commit is contained in:
parent
1746d19cfa
commit
d02e552203
10
src/Makefile
10
src/Makefile
|
@ -5,8 +5,9 @@ BINDIR = $(PREFIX)/bin
|
|||
CC ?= cc
|
||||
CPPFLAGSF= -I ../include
|
||||
CPPFLAGS?=
|
||||
CFLAGSF = -W
|
||||
CFLAGSF = -W `pkg-config --cflags libDesktop`
|
||||
CFLAGS = -Wall -g -pedantic
|
||||
LDFLAGSF= `pkg-config --libs libDesktop`
|
||||
RM ?= rm -f
|
||||
LN ?= ln -f
|
||||
MKDIR ?= mkdir -p
|
||||
|
@ -16,8 +17,8 @@ INSTALL ?= install
|
|||
all: $(TARGETS)
|
||||
|
||||
keyboard_OBJS = callbacks.o common.o key.o keyboard.o layout.o main.o
|
||||
keyboard_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) `pkg-config --cflags gtk+-2.0`
|
||||
keyboard_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) `pkg-config --libs gtk+-2.0` -lXtst
|
||||
keyboard_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||
keyboard_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) -lXtst
|
||||
|
||||
keyboard: $(keyboard_OBJS)
|
||||
$(CC) -o keyboard $(keyboard_OBJS) $(keyboard_LDFLAGS)
|
||||
|
@ -59,8 +60,11 @@ distclean: clean
|
|||
install: $(TARGETS)
|
||||
$(MKDIR) $(DESTDIR)$(BINDIR)
|
||||
$(INSTALL) -m 0755 -- keyboard $(DESTDIR)$(BINDIR)/keyboard
|
||||
$(MKDIR) $(DESTDIR)$(BINDIR)
|
||||
$(INSTALL) -m 0755 -- keyboardctl $(DESTDIR)$(BINDIR)/keyboardctl
|
||||
|
||||
uninstall:
|
||||
$(RM) -- $(DESTDIR)$(BINDIR)/keyboard
|
||||
$(RM) -- $(DESTDIR)$(BINDIR)/keyboardctl
|
||||
|
||||
.PHONY: all clean distclean install uninstall
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* $Id$ */
|
||||
/* Copyright (c) 2010 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2010-2012 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Keyboard */
|
||||
/* 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
|
||||
|
@ -42,6 +42,26 @@ void on_keyboard_embedded(gpointer data)
|
|||
}
|
||||
|
||||
|
||||
/* on_keyboard_message */
|
||||
int on_keyboard_message(void * data, uint32_t value1, uint32_t value2,
|
||||
uint32_t value3)
|
||||
{
|
||||
Keyboard * keyboard = data;
|
||||
KeyboardMessage message = value1;
|
||||
|
||||
switch(message)
|
||||
{
|
||||
case KEYBOARD_MESSAGE_SET_PAGE:
|
||||
keyboard_set_page(keyboard, value2);
|
||||
break;
|
||||
case KEYBOARD_MESSAGE_SET_VISIBLE:
|
||||
keyboard_show(keyboard, (value2 != 0) ? TRUE : FALSE);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* on_keyboard_set_layout_keypad */
|
||||
void on_keyboard_set_layout_keypad(gpointer data)
|
||||
{
|
||||
|
|
|
@ -19,12 +19,15 @@
|
|||
# define KEYBOARD_CALLBACKS_H
|
||||
|
||||
# include <gtk/gtk.h>
|
||||
# include <Desktop.h>
|
||||
|
||||
|
||||
/* public */
|
||||
/* functions */
|
||||
gboolean on_keyboard_delete_event(gpointer data);
|
||||
void on_keyboard_embedded(gpointer data);
|
||||
int on_keyboard_message(void * data, uint32_t value1, uint32_t value2,
|
||||
uint32_t value3);
|
||||
|
||||
void on_keyboard_set_layout_keypad(gpointer data);
|
||||
void on_keyboard_set_layout_letters(gpointer data);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <Desktop.h>
|
||||
#define XK_LATIN1
|
||||
#define XK_MISCELLANY
|
||||
#include <X11/Xlib.h>
|
||||
|
@ -362,6 +363,9 @@ Keyboard * keyboard_new(KeyboardPrefs * prefs)
|
|||
}
|
||||
keyboard_set_layout(keyboard, KLS_LETTERS);
|
||||
pango_font_description_free(bold);
|
||||
/* messages */
|
||||
desktop_message_register(KEYBOARD_CLIENT_MESSAGE, on_keyboard_message,
|
||||
keyboard);
|
||||
return keyboard;
|
||||
}
|
||||
|
||||
|
@ -379,16 +383,6 @@ void keyboard_delete(Keyboard * keyboard)
|
|||
|
||||
|
||||
/* accessors */
|
||||
/* keyboard_set_modifier */
|
||||
void keyboard_set_modifier(Keyboard * keyboard, unsigned int modifier)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < keyboard->layouts_cnt; i++)
|
||||
keyboard_layout_apply_modifier(keyboard->layouts[i], modifier);
|
||||
}
|
||||
|
||||
|
||||
/* keyboard_set_layout */
|
||||
void keyboard_set_layout(Keyboard * keyboard, unsigned int which)
|
||||
{
|
||||
|
@ -406,6 +400,32 @@ void keyboard_set_layout(Keyboard * keyboard, unsigned int which)
|
|||
}
|
||||
|
||||
|
||||
/* keyboard_set_modifier */
|
||||
void keyboard_set_modifier(Keyboard * keyboard, unsigned int modifier)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < keyboard->layouts_cnt; i++)
|
||||
keyboard_layout_apply_modifier(keyboard->layouts[i], modifier);
|
||||
}
|
||||
|
||||
|
||||
/* keyboard_set_page */
|
||||
void keyboard_set_page(Keyboard * keyboard, KeyboardPage page)
|
||||
{
|
||||
/* FIXME really implement */
|
||||
switch(page)
|
||||
{
|
||||
case KEYBOARD_PAGE_DEFAULT:
|
||||
keyboard_set_layout(keyboard, 0);
|
||||
break;
|
||||
case KEYBOARD_PAGE_KEYPAD:
|
||||
keyboard_set_layout(keyboard, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* useful */
|
||||
/* keyboard_show */
|
||||
void keyboard_show(Keyboard * keyboard, gboolean show)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
# define KEYBOARD_KEYBOARD_H
|
||||
|
||||
# include <gtk/gtk.h>
|
||||
# include "Keyboard.h"
|
||||
# include "key.h"
|
||||
|
||||
|
||||
|
@ -41,6 +42,7 @@ void keyboard_delete(Keyboard * keyboard);
|
|||
/* accessors */
|
||||
/* XXX be more explicit */
|
||||
void keyboard_set_layout(Keyboard * keyboard, unsigned int which);
|
||||
void keyboard_set_page(Keyboard * keyboard, KeyboardPage page);
|
||||
|
||||
/* useful */
|
||||
void keyboard_show(Keyboard * keyboard, gboolean show);
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
targets=keyboard,keyboardctl
|
||||
cppflags_force=-I ../include
|
||||
cflags_force=-W
|
||||
cflags_force=-W `pkg-config --cflags libDesktop`
|
||||
cflags=-Wall -g -O2
|
||||
ldflags_force=`pkg-config --libs libDesktop`
|
||||
cflags=-Wall -g -pedantic
|
||||
dist=Makefile,callbacks.h,common.h,key.h,keyboard.h,layout.h
|
||||
|
||||
[keyboard]
|
||||
type=binary
|
||||
cflags=`pkg-config --cflags gtk+-2.0`
|
||||
ldflags=`pkg-config --libs gtk+-2.0` -lXtst
|
||||
install=$(BINDIR)
|
||||
sources=callbacks.c,common.c,key.c,keyboard.c,layout.c,main.c
|
||||
ldflags=-lXtst
|
||||
install=$(BINDIR)
|
||||
|
||||
[key.c]
|
||||
depends=key.h
|
||||
|
@ -28,3 +29,4 @@ type=binary
|
|||
sources=keyboardctl.c
|
||||
cflags=`pkg-config --cflags libDesktop`
|
||||
ldflags=`pkg-config --libs libDesktop`
|
||||
install=$(BINDIR)
|
||||
|
|
Loading…
Reference in New Issue
Block a user