[PATCH v2 08/28] text: rename text_model::commit to commit_state

2013-04-18 Thread Jan Arne Petersen
From: Jan Arne Petersen jpeter...@openismus.com

Use ::commit_state as a request name to make clear what is commited.

Signed-off-by: Jan Arne Petersen jpeter...@openismus.com
---
 clients/editor.c   | 2 +-
 protocol/text.xml  | 2 +-
 src/text-backend.c | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/clients/editor.c b/clients/editor.c
index 7b6ad35..1696fca 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -640,7 +640,7 @@ text_entry_update(struct text_entry *entry)
text_model_set_preferred_language(entry-model,
  entry-preferred_language);
 
-   text_model_commit(entry-model);
+   text_model_commit_state(entry-model);
 }
 
 static void
diff --git a/protocol/text.xml b/protocol/text.xml
index 508f8de..ea5bfe1 100644
--- a/protocol/text.xml
+++ b/protocol/text.xml
@@ -140,7 +140,7 @@
   arg name=button type=uint/
   arg name=index type=uint/
 /request
-request name=commit
+request name=commit_state
 /request
 request name=show_input_panel
   description summary=show input panels
diff --git a/src/text-backend.c b/src/text-backend.c
index 7741123..7d1d7d7 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -261,8 +261,8 @@ text_model_invoke_action(struct wl_client *client,
 }
 
 static void
-text_model_commit(struct wl_client *client,
- struct wl_resource *resource)
+text_model_commit_state(struct wl_client *client,
+   struct wl_resource *resource)
 {
struct text_model *text_model = resource-data;
struct input_method *input_method, *next;
@@ -324,7 +324,7 @@ static const struct text_model_interface 
text_model_implementation = {
text_model_set_micro_focus,
text_model_set_content_type,
text_model_invoke_action,
-   text_model_commit,
+   text_model_commit_state,
text_model_show_input_panel,
text_model_hide_input_panel,
text_model_set_preferred_language
-- 
1.8.1.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH v2 06/28] text: Fix some text and input-method docs

2013-04-18 Thread Jan Arne Petersen
From: Krzesimir Nowak krno...@openismus.com

Signed-off-by: Jan Arne Petersen jpeter...@openismus.com
---
 protocol/input-method.xml | 40 +++-
 protocol/text.xml | 36 +++-
 2 files changed, 46 insertions(+), 30 deletions(-)

diff --git a/protocol/input-method.xml b/protocol/input-method.xml
index 59ac244..3fc468c 100644
--- a/protocol/input-method.xml
+++ b/protocol/input-method.xml
@@ -37,20 +37,32 @@
 request name=destroy type=destructor/
 request name=commit_string
   description summary=commit string
-Send the commit string text to the applications text model.
+Send the commit string text to the applications text model and
+set the cursor at index (as byte index) relative to the
+beginning of inserted text.
   /description
   arg name=serial type=uint/
   arg name=text type=string/
 /request
 request name=preedit_string
   description summary=pre-edit string
-Send the pre-edit string text to the applications text model.
+Send the pre-edit string text to the applications text model. The 
commit
+text can be used to replace the preedit text on reset (for example on
+unfocus).
   /description
   arg name=serial type=uint/
   arg name=text type=string/
   arg name=commit type=string/
 /request
 request name=preedit_styling
+  description summary=pre-edit styling
+Sets styling information on composing text. The style is applied for
+length (in bytes) characters from index relative to the beginning of 
the
+composing text (as byte index). Multiple styles can be applied to a
+composing text.
+
+This request should be sent before sending preedit_string request.
+  /description
   arg name=serial type=uint/
   arg name=index type=uint/
   arg name=length type=uint/
@@ -60,6 +72,8 @@
   description summary=pre-edit cursor
 Sets the cursor position inside the composing text (as byte index)
 relative to the start of the composing text.
+
+This request should be sent before sending preedit_string request.
   /description
   arg name=serial type=uint/
   arg name=index type=int/
@@ -79,11 +93,10 @@
 /request
 request name=keysym
   description summary=keysym
-Notify when a key event was sent. Key events should not be used
-for normal text input operations, which should be done with
-commit_string, delete_surrounfing_text, etc. The key event follows
-the wl_keyboard key event convention. State is a XKB keysym, state a
-wl_keyboard key_state.
+Notify when a key event was sent. Key events should not be used for
+normal text input operations, which should be done with commit_string,
+delete_surrounfing_text, etc. The key event follows the wl_keyboard key
+event convention. Sym is a XKB keysym, state a wl_keyboard key_state.
   /description
   arg name=serial type=uint/
   arg name=time type=uint/
@@ -94,9 +107,9 @@
 request name=grab_keyboard
   description summary=grab hardware keyboard
 Allows an input method to receive hardware keyboard input and process
-key events to generate text events (with pre-edit) over the. This 
allows
-input methods which compose multiple key events for inputting text
-like it is done for CJK languages.
+key events to generate text events (with pre-edit) over the wire. This
+allows input methods which compose multiple key events for inputting
+text like it is done for CJK languages.
   /description
arg name=keyboard type=new_id interface=wl_keyboard/
 /request
@@ -124,9 +137,10 @@
 event name=surrounding_text
   description summary=surrounding text event
 The plain surrounding text around the input position. Cursor is the
-position within the surrounding text. Anchor is the position of the
-selection anchor within the surrounding text. If there is no selected
-text anchor is the same as cursor.
+position in bytes within the surrounding text relative to the beginning
+of the text. Anchor is the position in bytes of the selection anchor
+within the surrounding text relative to the beginning of the text. If
+there is no selected text anchor is the same as cursor.
   /description
   arg name=text type=string/
   arg name=cursor type=uint/
diff --git a/protocol/text.xml b/protocol/text.xml
index dc86c16..508f8de 100644
--- a/protocol/text.xml
+++ b/protocol/text.xml
@@ -42,7 +42,7 @@
 Sets the plain surrounding text around the input position. Cursor is 
the
 byte index within the surrounding text. Anchor is the byte index of the
 selection anchor within the surrounding text. If there is no selected
-text anchor is 

[PATCH v2 05/28] text: Fix password content hint value

2013-04-18 Thread Jan Arne Petersen
From: Krzesimir Nowak krno...@openismus.com

0xc in this case was a combination of autocapitalization (0x4) and
lowercase (0x8) instead of hidden_text (0x40) and sensitive_data
(0x80).

Signed-off-by: Jan Arne Petersen jpeter...@openismus.com
---
 protocol/text.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/protocol/text.xml b/protocol/text.xml
index 3334769..dc86c16 100644
--- a/protocol/text.xml
+++ b/protocol/text.xml
@@ -88,7 +88,7 @@
   /description
   entry name=none value=0x0 summary=no special behaviour/
   entry name=default value=0x7 summary=auto completion, correction 
and capitalization/
-  entry name=password value=0xc summary=hidden and sensitive text/
+  entry name=password value=0xc0 summary=hidden and sensitive text/
   entry name=auto_completion value=0x1 summary=suggest word 
completions/
   entry name=auto_correction value=0x2 summary=suggest word 
corrections/
   entry name=auto_capitalization value=0x4 summary=switch to 
uppercase letters at the start of a sentence/
-- 
1.8.1.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH v2 11/28] text: Add none preedit-style

2013-04-18 Thread Jan Arne Petersen
From: Jan Arne Petersen jpeter...@openismus.com

Use default preedit style as default. None is used when the
composing text should look like non-composing text.

Signed-off-by: Jan Arne Petersen jpeter...@openismus.com
---
 clients/keyboard.c | 2 +-
 protocol/text.xml  | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clients/keyboard.c b/clients/keyboard.c
index b2f66f0..2f28a8f 100644
--- a/clients/keyboard.c
+++ b/clients/keyboard.c
@@ -233,8 +233,8 @@ static const struct layout arabic_layout = {
 };
 
 static const char *style_labels[] = {
-   none,
default,
+   none,
active,
inactive,
highlight,
diff --git a/protocol/text.xml b/protocol/text.xml
index 85d67ff..02c5041 100644
--- a/protocol/text.xml
+++ b/protocol/text.xml
@@ -209,7 +209,8 @@
   arg name=commit type=string/
 /event
 enum name=preedit_style
-  entry name=default value=1/
+  entry name=default value=0 summary=default style for composing 
text/
+  entry name=none value=1 summary=style should be the same as in 
non-composing text/
   entry name=active value=2/
   entry name=inactive value=3/
   entry name=highlight value=4/
-- 
1.8.1.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH v2 16/28] text: Move input panel into an own file

2013-04-18 Thread Jan Arne Petersen
From: Jan Arne Petersen jpeter...@openismus.com

Signed-off-by: Jan Arne Petersen jpeter...@openismus.com
---
 src/Makefile.am   |   3 +-
 src/compositor.c  |   1 +
 src/compositor.h  |  13 ++
 src/input-panel.c | 461 ++
 src/shell.c   | 350 +
 5 files changed, 484 insertions(+), 344 deletions(-)
 create mode 100644 src/input-panel.c

diff --git a/src/Makefile.am b/src/Makefile.am
index d33ebc5..77b24b5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -43,7 +43,8 @@ weston_SOURCES =  \
../shared/matrix.c  \
../shared/matrix.h  \
weston-launch.h \
-   weston-egl-ext.h
+   weston-egl-ext.h\
+   input-panel.c
 
 if ENABLE_EGL
 weston_SOURCES +=  \
diff --git a/src/compositor.c b/src/compositor.c
index 24772af..82a3fa9 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3181,6 +3181,7 @@ weston_compositor_init(struct weston_compositor *ec,
screenshooter_create(ec);
text_cursor_position_notifier_create(ec);
text_backend_init(ec);
+   ec-input_panel = input_panel_create(ec);
 
wl_data_device_manager_init(ec-wl_display);
 
diff --git a/src/compositor.h b/src/compositor.h
index 5a28260..5c2c404 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -52,6 +52,7 @@ struct shell_surface;
 struct weston_seat;
 struct weston_output;
 struct input_method;
+struct input_panel;
 
 enum weston_keyboard_modifier {
MODIFIER_CTRL = (1  0),
@@ -361,6 +362,8 @@ struct weston_compositor {
struct xkb_rule_names xkb_names;
struct xkb_context *xkb_context;
struct weston_xkb_info xkb_info;
+
+   struct input_panel *input_panel;
 };
 
 struct weston_buffer_reference {
@@ -822,6 +825,16 @@ text_cursor_position_notifier_create(struct 
weston_compositor *ec);
 int
 text_backend_init(struct weston_compositor *ec);
 
+struct input_panel*
+input_panel_create(struct weston_compositor *ec);
+
+void
+input_panel_show_layer(struct input_panel *input_panel,
+  struct weston_layer *previous_layer,
+  struct weston_layer *next_layer);
+void
+input_panel_hide_layer(struct input_panel *panel);
+
 struct weston_process;
 typedef void (*weston_process_cleanup_func_t)(struct weston_process *process,
int status);
diff --git a/src/input-panel.c b/src/input-panel.c
new file mode 100644
index 000..81a82f8
--- /dev/null
+++ b/src/input-panel.c
@@ -0,0 +1,461 @@
+/*
+ * Copyright © 2012-2013 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.  The copyright holders make
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided as is without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include stdbool.h
+#include stdlib.h
+#include string.h
+
+#include wayland-server.h
+#include compositor.h
+
+#include input-method-server-protocol.h
+
+struct input_panel {
+   struct wl_listener destroy_listener;
+   struct wl_listener show_input_panel_listener;
+   struct wl_listener hide_input_panel_listener;
+   struct wl_listener update_input_panel_listener;
+
+   struct wl_resource *binding;
+
+   struct wl_list surfaces;
+
+   bool showing_input_panels;
+
+   struct {
+   struct weston_layer input_panel;
+
+   struct weston_layer *previous;
+   struct weston_layer *next;
+
+   bool visible;
+   } layer;
+
+   struct {
+   struct weston_surface *surface;
+   pixman_box32_t cursor_rectangle;
+   } text_input;
+
+};
+
+struct input_panel_surface {
+   struct wl_resource resource;
+
+   struct input_panel *input_panel;
+
+   struct wl_list link;
+   struct weston_surface *surface;
+   struct wl_listener 

[PATCH v2 19/28] text: Fix serial handling

2013-04-18 Thread Jan Arne Petersen
From: Jan Arne Petersen jpeter...@openismus.com

Signed-off-by: Jan Arne Petersen jpeter...@openismus.com
---
 clients/editor.c   | 24 ++--
 clients/keyboard.c | 23 +--
 clients/weston-simple-im.c | 28 +++-
 protocol/input-method.xml  | 17 ++---
 protocol/text.xml  | 26 ++
 src/text-backend.c | 33 +
 tests/text-test.c  |  8 ++--
 7 files changed, 73 insertions(+), 86 deletions(-)

diff --git a/clients/editor.c b/clients/editor.c
index e61eda0..c40815a 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -63,6 +63,7 @@ struct text_entry {
xkb_mod_mask_t shift_mask;
} keysym;
uint32_t serial;
+   uint32_t reset_serial;
uint32_t content_purpose;
uint32_t click_to_show;
char *preferred_language;
@@ -138,6 +139,12 @@ text_input_commit_string(void *data,
 {
struct text_entry *entry = data;
 
+   if ((entry-serial - serial)  (entry-serial - entry-reset_serial)) {
+   fprintf(stderr, Ignore commit. Serial: %u, Current: %u, Reset: 
%u\n,
+   serial, entry-serial, entry-reset_serial);
+   return;
+   }
+
text_entry_reset_preedit(entry);
 
text_entry_delete_selected_text(entry);
@@ -175,7 +182,6 @@ text_input_preedit_string(void *data,
 static void
 text_input_delete_surrounding_text(void *data,
   struct text_input *text_input,
-  uint32_t serial,
   int32_t index,
   uint32_t length)
 {
@@ -207,7 +213,6 @@ text_input_delete_surrounding_text(void *data,
 static void
 text_input_cursor_position(void *data,
   struct text_input *text_input,
-  uint32_t serial,
   int32_t index,
   int32_t anchor)
 {
@@ -220,7 +225,6 @@ text_input_cursor_position(void *data,
 static void
 text_input_preedit_styling(void *data,
   struct text_input *text_input,
-  uint32_t serial,
   uint32_t index,
   uint32_t length,
   uint32_t style)
@@ -272,7 +276,6 @@ text_input_preedit_styling(void *data,
 static void
 text_input_preedit_cursor(void *data,
  struct text_input *text_input,
- uint32_t serial,
  int32_t index)
 {
struct text_entry *entry = data;
@@ -374,6 +377,9 @@ text_input_enter(void *data,
 
entry-active = 1;
 
+   text_entry_update(entry);
+   entry-reset_serial = entry-serial;
+
widget_schedule_redraw(entry-widget);
 }
 
@@ -552,10 +558,7 @@ text_entry_activate(struct text_entry *entry,
if (!entry-click_to_show)
text_input_show_input_panel(entry-text_input);
 
-   entry-serial++;
-
text_input_activate(entry-text_input,
-   entry-serial,
seat,
surface);
 }
@@ -653,7 +656,7 @@ text_entry_update(struct text_entry *entry)
text_input_set_cursor_rectangle(entry-text_input, cursor_rectangle.x, 
cursor_rectangle.y,
cursor_rectangle.width, 
cursor_rectangle.height);
 
-   text_input_commit_state(entry-text_input);
+   text_input_commit_state(entry-text_input, ++entry-serial);
 }
 
 static void
@@ -714,8 +717,9 @@ text_entry_commit_and_reset(struct text_entry *entry)
free(commit);
}
 
-   entry-serial++;
-   text_input_reset(entry-text_input, entry-serial);
+   text_input_reset(entry-text_input);
+   text_entry_update(entry);
+   entry-reset_serial = entry-serial;
 }
 
 static void
diff --git a/clients/keyboard.c b/clients/keyboard.c
index 17fb683..9dd210a 100644
--- a/clients/keyboard.c
+++ b/clients/keyboard.c
@@ -395,7 +395,6 @@ virtual_keyboard_commit_preedit(struct virtual_keyboard 
*keyboard)
,
);
input_method_context_cursor_position(keyboard-context,
-keyboard-serial,
 0, 0);
input_method_context_commit_string(keyboard-context,
   keyboard-serial,
@@ -412,14 +411,12 @@ virtual_keyboard_send_preedit(struct virtual_keyboard 
*keyboard,
 
if (keyboard-preedit_style)
input_method_context_preedit_styling(keyboard-context,
-keyboard-serial,
 0,
 

[PATCH v2 21/28] keyboard: Remove unneded calls

2013-04-18 Thread Jan Arne Petersen
From: Jan Arne Petersen jpeter...@openismus.com

Signed-off-by: Jan Arne Petersen jpeter...@openismus.com
---
 clients/keyboard.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/clients/keyboard.c b/clients/keyboard.c
index bd88207..4fc8e73 100644
--- a/clients/keyboard.c
+++ b/clients/keyboard.c
@@ -387,13 +387,6 @@ virtual_keyboard_commit_preedit(struct virtual_keyboard 
*keyboard)
strlen(keyboard-preedit_string) == 0)
return;
 
-   input_method_context_preedit_cursor(keyboard-context,
-   keyboard-serial,
-   0);
-   input_method_context_preedit_string(keyboard-context,
-   keyboard-serial,
-   ,
-   );
input_method_context_cursor_position(keyboard-context,
 0, 0);
input_method_context_commit_string(keyboard-context,
@@ -585,13 +578,6 @@ handle_reset(void *data,
fprintf(stderr, Reset pre-edit buffer\n);
 
if (strlen(keyboard-preedit_string)) {
-   input_method_context_preedit_cursor(context,
-   serial,
-   0);
-   input_method_context_preedit_string(context,
-   serial,
-   ,
-   );
free(keyboard-preedit_string);
keyboard-preedit_string = strdup();
}
@@ -797,8 +783,6 @@ keyboard_create(struct output *output, struct 
virtual_keyboard *virtual_keyboard
input_panel_surface_set_toplevel(ips,
 output_get_wl_output(output),
 
INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
-
-   fprintf(stderr, %s, %p\n, __FUNCTION__, output_get_wl_output(output));
 }
 
 int
-- 
1.8.1.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH v2 23/28] text: Rename ::set_panel to ::set_overlay_panel

2013-04-18 Thread Jan Arne Petersen
From: Jan Arne Petersen jpeter...@openismus.com

Also add documentation to input_panel_surface::set_overlay_panel.

Signed-off-by: Jan Arne Petersen jpeter...@openismus.com
---
 protocol/input-method.xml | 8 ++--
 src/input-panel.c | 6 +++---
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/protocol/input-method.xml b/protocol/input-method.xml
index dd905c2..d0e93db 100644
--- a/protocol/input-method.xml
+++ b/protocol/input-method.xml
@@ -1,7 +1,7 @@
 ?xml version=1.0 encoding=UTF-8?
 protocol name=input_method
   copyright
-Copyright © 2012 Intel Corporation
+Copyright © 2012, 2013 Intel Corporation
 
 Permission to use, copy, modify, distribute, and sell this
 software and its documentation for any purpose is hereby granted
@@ -215,7 +215,11 @@
   arg name=position type=uint/
 /request
 
-request name=set_panel
+request name=set_overlay_panel
+  description summary=set the surface type as an overlay panel
+An overlay panel is shown near the input cursor above the application
+window hwne a text model is active.
+  /description
 /request
   /interface
 /protocol
diff --git a/src/input-panel.c b/src/input-panel.c
index 81a82f8..fb3e0d2 100644
--- a/src/input-panel.c
+++ b/src/input-panel.c
@@ -283,8 +283,8 @@ input_panel_surface_set_toplevel(struct wl_client *client,
 }
 
 static void
-input_panel_surface_set_panel(struct wl_client *client,
- struct wl_resource *resource)
+input_panel_surface_set_overlay_panel(struct wl_client *client,
+ struct wl_resource *resource)
 {
struct input_panel_surface *input_panel_surface = resource-data;
struct input_panel *input_panel = input_panel_surface-input_panel;
@@ -297,7 +297,7 @@ input_panel_surface_set_panel(struct wl_client *client,
 
 static const struct input_panel_surface_interface 
input_panel_surface_implementation = {
input_panel_surface_set_toplevel,
-   input_panel_surface_set_panel
+   input_panel_surface_set_overlay_panel
 };
 
 static void
-- 
1.8.1.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH v2 26/28] text: add cursor_rectangle event to input_panel_surface

2013-04-18 Thread Jan Arne Petersen
From: Jan Arne Petersen jpeter...@openismus.com

Signed-off-by: Jan Arne Petersen jpeter...@openismus.com
---
 protocol/input-method.xml | 10 ++
 src/input-panel.c | 37 -
 2 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/protocol/input-method.xml b/protocol/input-method.xml
index f0c1184..5666e7b 100644
--- a/protocol/input-method.xml
+++ b/protocol/input-method.xml
@@ -269,5 +269,15 @@
 window hwne a text model is active.
   /description
 /request
+
+event name=cursor_rectangle
+  description summary=cursor rectangle
+Notify when the cursor rectangle relative to the input panel surface 
change.
+  /description
+  arg name=x type=int/
+  arg name=y type=int/
+  arg name=width type=int/
+  arg name=height type=int/
+/event
   /interface
 /protocol
diff --git a/src/input-panel.c b/src/input-panel.c
index 711c164..70b1125 100644
--- a/src/input-panel.c
+++ b/src/input-panel.c
@@ -138,17 +138,19 @@ hide_input_panels(struct wl_listener *listener, void 
*data)
 }
 
 static void
-overlay_panel_get_position(struct input_panel_surface *surface,
-  float *x, float *y)
+text_input_surface_get_cursor_rectangle(struct input_panel_surface *surface,
+   float *x1, float *y1,
+   float *x2, float *y2)
 {
struct input_panel *input_panel = surface-input_panel;
 
-   if (!surface-overlay_panel) {
+   if (!input_panel-text_input.surface || 
!weston_surface_is_mapped(input_panel-text_input.surface))
return;
-   }
 
-   *x = input_panel-text_input.surface-geometry.x + 
input_panel-text_input.cursor_rectangle.x2;
-   *y = input_panel-text_input.surface-geometry.y + 
input_panel-text_input.cursor_rectangle.y2;
+   *x1 = input_panel-text_input.surface-geometry.x + 
input_panel-text_input.cursor_rectangle.x1;
+   *y1 = input_panel-text_input.surface-geometry.y + 
input_panel-text_input.cursor_rectangle.y1;
+   *x2 = input_panel-text_input.surface-geometry.x + 
input_panel-text_input.cursor_rectangle.x2;
+   *y2 = input_panel-text_input.surface-geometry.y + 
input_panel-text_input.cursor_rectangle.y2;
 }
 
 static void
@@ -158,19 +160,24 @@ update_input_panels(struct wl_listener *listener, void 
*data)
container_of(listener, struct input_panel,
 update_input_panel_listener);
struct input_panel_surface *surface, *next;
-   float x = 0, y = 0;
+   float x1 = 0, y1 = 0, x2 = 0, y2 = 0;
 
memcpy(input_panel-text_input.cursor_rectangle, data, 
sizeof(pixman_box32_t));
 
wl_list_for_each_safe(surface, next,
  input_panel-surfaces, link) {
-   if (!surface-overlay_panel)
-   continue;
+   text_input_surface_get_cursor_rectangle(surface, x1, y1, x2, 
y2);
if (!weston_surface_is_mapped(surface-surface))
continue;
-   overlay_panel_get_position(surface, x, y);
-   weston_surface_set_position(surface-surface, x, y);
-   weston_surface_update_transform(surface-surface);
+   if (surface-overlay_panel) {
+   weston_surface_set_position(surface-surface, x2, y2);
+   weston_surface_update_transform(surface-surface);
+   }
+   wl_input_panel_surface_send_cursor_rectangle(surface-resource,
+x1 - 
surface-surface-geometry.x,
+y1 - 
surface-surface-geometry.y,
+x2 - 
surface-surface-geometry.x,
+y2 - 
surface-surface-geometry.y);
}
 }
 
@@ -187,7 +194,11 @@ input_panel_configure(struct weston_surface *surface, 
int32_t sx, int32_t sy, in
return;
 
if (ip_surface-overlay_panel) {
-   overlay_panel_get_position(ip_surface, x, y);
+   float x1, y1, x2, y2;
+   text_input_surface_get_cursor_rectangle(ip_surface, x1, y1, 
x2, y2);
+
+   x = x2;
+   y = y2;
} else {
mode = ip_surface-output-current;
 
-- 
1.8.1.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH v2 24/28] text: Improve protocol documentation.

2013-04-18 Thread Jan Arne Petersen
From: Jan Arne Petersen jpeter...@openismus.com

Signed-off-by: Jan Arne Petersen jpeter...@openismus.com
---
 protocol/input-method.xml | 98 +++
 protocol/text.xml | 52 -
 2 files changed, 106 insertions(+), 44 deletions(-)

diff --git a/protocol/input-method.xml b/protocol/input-method.xml
index d0e93db..d7b3f6b 100644
--- a/protocol/input-method.xml
+++ b/protocol/input-method.xml
@@ -34,6 +34,8 @@
   Input method contexts do not keep state after deactivation and should be
   destroyed after deactivation is handled.
 
+  Text is generally UTF-8 encoded, indices and lengths are in bytes.
+
   Serials are used to synchronize the state between the text input and
   an input method. New serials are sent by the text input in the
   commit_state request and are used by the input method to indicate
@@ -44,29 +46,39 @@
 request name=destroy type=destructor/
 request name=commit_string
   description summary=commit string
-Send the commit string text to the applications text model and
-set the cursor at index (as byte index) relative to the
-beginning of inserted text.
+Send the commit string text for insertion to the application.
+
+The text to commit could be either just a single character after a key
+press or the result of some composing (pre-edit). It could be also an
+empty text when some text should be removed (see
+delete_surrounding_text) or when the input cursor should be moved (see
+cursor_position).
+
+Any previously set composing text will be removed.
   /description
-  arg name=serial type=uint/
+  arg name=serial type=uint summary=serial of the latest known text 
input state/
   arg name=text type=string/
 /request
 request name=preedit_string
   description summary=pre-edit string
-Send the pre-edit string text to the applications text model. The 
commit
-text can be used to replace the preedit text on reset (for example on
-unfocus).
+Send the pre-edit string text to the application text input.
+
+The commit text can be used to replace the preedit text on reset (for
+example on unfocus).
+
+Also previously sent preedit_style and preedit_cursor requests are
+processed bt the text_input also.
   /description
-  arg name=serial type=uint/
+  arg name=serial type=uint summary=serial of the latest known text 
input state/
   arg name=text type=string/
   arg name=commit type=string/
 /request
 request name=preedit_styling
   description summary=pre-edit styling
 Sets styling information on composing text. The style is applied for
-length (in bytes) characters from index relative to the beginning of 
the
-composing text (as byte index). Multiple styles can be applied to a
-composing text.
+   length in bytes from index relative to the beginning of
+   the composing text (as byte offset). Multiple styles can
+   be applied to a composing text.
 
 This request should be sent before sending preedit_string request.
   /description
@@ -76,18 +88,37 @@
 /request
 request name=preedit_cursor
   description summary=pre-edit cursor
-Sets the cursor position inside the composing text (as byte index)
+Sets the cursor position inside the composing text (as byte offset)
 relative to the start of the composing text.
 
+When index is negative no cursor should be displayed.
+
 This request should be sent before sending preedit_string request.
   /description
   arg name=index type=int/
 /request
 request name=delete_surrounding_text
+  description summary=delete text
+
+
+This request will be handled on text_input side as part of a directly
+following commit_string request.
+  /description
   arg name=index type=int/
   arg name=length type=uint/
 /request
 request name=cursor_position
+  description summary=set cursor to a new position
+Sets the cursor and anchor to a new position. Index is the new cursor
+position in bytess (when = 0 relative to the end of inserted text
+else relative to beginning of inserted text). Anchor is the new anchor
+position in bytes (when = 0 relative to the end of inserted text, else
+relative to beginning of inserted text). When there should be no
+selected text anchor should be the same as index.
+
+This request will be handled on text_input side as part of a directly
+following commit_string request.
+  /description
   arg name=index type=int/
   arg name=anchor type=int/
 /request
@@ -101,7 +132,7 @@
 delete_surrounfing_text, etc. The key event follows the wl_keyboard key
 event convention. Sym is a XKB keysym, 

[PATCH v2 27/28] keyboard: Fix offsets when deleting text

2013-04-18 Thread Jan Arne Petersen
From: Jan Arne Petersen jpeter...@openismus.com

Signed-off-by: Jan Arne Petersen jpeter...@openismus.com
---
 clients/keyboard.c | 90 +++---
 1 file changed, 85 insertions(+), 5 deletions(-)

diff --git a/clients/keyboard.c b/clients/keyboard.c
index d83ca3c..a2fbded 100644
--- a/clients/keyboard.c
+++ b/clients/keyboard.c
@@ -50,6 +50,7 @@ struct virtual_keyboard {
uint32_t content_purpose;
char *preferred_language;
char *surrounding_text;
+   uint32_t surrounding_cursor;
struct keyboard *keyboard;
 };
 
@@ -380,9 +381,24 @@ resize_handler(struct widget *widget,
/* struct keyboard *keyboard = data; */
 }
 
+static char *
+insert_text(const char *text, uint32_t offset, const char *insert)
+{
+   char *new_text = malloc(strlen(text) + strlen(insert) + 1);
+
+   strncat(new_text, text, offset);
+   new_text[offset] = '\0';
+   strcat(new_text, insert);
+   strcat(new_text, text + offset);
+
+   return new_text;
+}
+
 static void
 virtual_keyboard_commit_preedit(struct virtual_keyboard *keyboard)
 {
+   char *surrounding_text;
+
if (!keyboard-preedit_string ||
strlen(keyboard-preedit_string) == 0)
return;
@@ -392,6 +408,19 @@ virtual_keyboard_commit_preedit(struct virtual_keyboard 
*keyboard)
wl_input_method_context_commit_string(keyboard-context,
  keyboard-serial,
  keyboard-preedit_string);
+
+   if (keyboard-surrounding_text) {
+   surrounding_text = insert_text(keyboard-surrounding_text,
+  keyboard-surrounding_cursor,
+  keyboard-preedit_string);
+   free(keyboard-surrounding_text);
+   keyboard-surrounding_text = surrounding_text;
+   keyboard-surrounding_cursor += 
strlen(keyboard-preedit_string);
+   } else {
+   keyboard-surrounding_text = strdup(keyboard-preedit_string);
+   keyboard-surrounding_cursor = strlen(keyboard-preedit_string);
+   }
+
free(keyboard-preedit_string);
keyboard-preedit_string = strdup();
 }
@@ -417,6 +446,59 @@ virtual_keyboard_send_preedit(struct virtual_keyboard 
*keyboard,
   keyboard-preedit_string);
 }
 
+static const char *
+prev_utf8_char(const char *s, const char *p)
+{
+   for (--p; p = s; --p) {
+   if ((*p  0xc0) != 0x80)
+   return p;
+   }
+   return NULL;
+}
+
+static const char *
+next_utf8_char(const char *p)
+{
+   if (*p == '\0')
+   return NULL;
+   for (++p; (*p  0xc0) == 0x80; ++p)
+   ;
+   return p;
+}
+
+static void
+delete_before_cursor(struct virtual_keyboard *keyboard)
+{
+   const char *start, *end;
+
+   if (!keyboard-surrounding_text) {
+   fprintf(stderr, delete_before_cursor: No surrounding text 
available\n);
+   return;
+   }
+
+   start = prev_utf8_char(keyboard-surrounding_text,
+  keyboard-surrounding_text + 
keyboard-surrounding_cursor);
+   if (!start) {
+   fprintf(stderr, delete_before_cursor: No previous character to 
delete\n);
+   return;
+   }
+
+   end = next_utf8_char(start);
+
+   wl_input_method_context_delete_surrounding_text(keyboard-context,
+   (start - 
keyboard-surrounding_text) - keyboard-surrounding_cursor,
+   end - start);
+   wl_input_method_context_commit_string(keyboard-context,
+ keyboard-serial,
+ );
+
+   /* Update surrounding text */
+   keyboard-surrounding_cursor = start - keyboard-surrounding_text;
+   keyboard-surrounding_text[keyboard-surrounding_cursor] = '\0';
+   if (*end)
+   memmove(keyboard-surrounding_text + 
keyboard-surrounding_cursor, end, strlen(end));
+}
+
 static void
 keyboard_handle_key(struct keyboard *keyboard, uint32_t time, const struct key 
*key, struct input *input, enum wl_pointer_button_state state)
 {
@@ -438,11 +520,7 @@ keyboard_handle_key(struct keyboard *keyboard, uint32_t 
time, const struct key *
break;
 
if (strlen(keyboard-keyboard-preedit_string) == 0) {
-   
wl_input_method_context_delete_surrounding_text(keyboard-keyboard-context,
-   
-1, 1);
-   
wl_input_method_context_commit_string(keyboard-keyboard-context,
- 
keyboard-keyboard-serial,

[PATCH v2 28/28] editor: Fix some offsets for multi-byte characters

2013-04-18 Thread Jan Arne Petersen
From: Jan Arne Petersen jpeter...@openismus.com

Signed-off-by: Jan Arne Petersen jpeter...@openismus.com
---
 clients/editor.c | 100 ++-
 1 file changed, 48 insertions(+), 52 deletions(-)

diff --git a/clients/editor.c b/clients/editor.c
index f6e6084..7c90ed9 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -82,32 +82,24 @@ struct editor {
 };
 
 static const char *
-utf8_start_char(const char *text, const char *p)
+utf8_end_char(const char *p)
 {
-   for (; p = text; --p) {
-   if ((*p  0xc0) != 0x80)
-   return p;
-   }
-   return NULL;
+   while ((*p  0xc0) == 0x80)
+   p++;
+   return p;
 }
 
 static const char *
-utf8_prev_char(const char *text, const char *p)
+utf8_prev_char(const char *s, const char *p)
 {
-   if (p  text)
-   return utf8_start_char(text, --p);
+   for (--p; p = s; --p) {
+   if ((*p  0xc0) != 0x80)
+   return p;
+   }
return NULL;
 }
 
 static const char *
-utf8_end_char(const char *p)
-{
-   while ((*p  0xc0) == 0x80)
-   p++;
-   return p;
-}
-
-static const char *
 utf8_next_char(const char *p)
 {
if (*p != 0)
@@ -200,7 +192,7 @@ text_input_delete_surrounding_text(void *data,
entry-pending_commit.delete_index = entry-cursor + index;
entry-pending_commit.delete_length = length;
 
-   text_length = utf8_characters(entry-text);
+   text_length = strlen(entry-text);
 
if (entry-pending_commit.delete_index  text_length) {
fprintf(stderr, Invalid cursor index %d\n, index);
@@ -328,11 +320,12 @@ text_input_keysym(void *data,
 
if (new_char != NULL) {
entry-cursor = new_char - entry-text;
-   if (!(modifiers  entry-keysym.shift_mask))
-   entry-anchor = entry-cursor;
-   widget_schedule_redraw(entry-widget);
}
 
+   if (!(modifiers  entry-keysym.shift_mask))
+   entry-anchor = entry-cursor;
+   widget_schedule_redraw(entry-widget);
+
return;
}
 
@@ -345,11 +338,11 @@ text_input_keysym(void *data,
text_entry_commit_and_reset(entry);
 
start = utf8_prev_char(entry-text, entry-text + 
entry-cursor);
+   end = utf8_next_char(start);
 
if (start == NULL)
return;
 
-   end = utf8_end_char(entry-text + entry-cursor);
text_entry_delete_text(entry,
   start - entry-text,
   end - start);
@@ -582,8 +575,8 @@ text_entry_update_layout(struct text_entry *entry)
char *text;
PangoAttrList *attr_list;
 
-   assert((entry-cursor) = strlen(entry-text) +
-  (entry-preedit.text ? strlen(entry-preedit.text) : 0));
+   assert(entry-cursor = (strlen(entry-text) +
+  (entry-preedit.text ? strlen(entry-preedit.text) : 0)));
 
if (entry-preedit.text) {
text = malloc(strlen(entry-text) + strlen(entry-preedit.text) 
+ 1);
@@ -681,6 +674,7 @@ text_entry_insert_at_cursor(struct text_entry *entry, const 
char *text,
entry-anchor = entry-cursor + strlen(text) + anchor;
else
entry-anchor = entry-cursor + 1 + anchor;
+
if (cursor = 0)
entry-cursor += strlen(text) + cursor;
else
@@ -753,6 +747,7 @@ text_entry_try_invoke_preedit_action(struct text_entry 
*entry,
 {
int index, trailing;
uint32_t cursor;
+   const char *text;
 
if (!entry-preedit.text)
return 0;
@@ -760,7 +755,9 @@ text_entry_try_invoke_preedit_action(struct text_entry 
*entry,
pango_layout_xy_to_index(entry-layout,
 x * PANGO_SCALE, y * PANGO_SCALE,
 index, trailing);
-   cursor = index + trailing;
+
+   text = pango_layout_get_text(entry-layout);
+   cursor = g_utf8_offset_to_pointer(text + index, trailing) - text;
 
if (cursor  entry-cursor ||
cursor  entry-cursor + strlen(entry-preedit.text)) {
@@ -780,13 +777,16 @@ text_entry_set_cursor_position(struct text_entry *entry,
   int32_t x, int32_t y)
 {
int index, trailing;
+   const char *text;
 
text_entry_commit_and_reset(entry);
 
pango_layout_xy_to_index(entry-layout,
 x * PANGO_SCALE, y * PANGO_SCALE,
 index, trailing);
-   entry-cursor = index + trailing;
+
+   text = pango_layout_get_text(entry-layout);
+   entry-cursor = g_utf8_offset_to_pointer(text + index, trailing) - text;
 
text_entry_update_layout(entry);
 
@@ -800,11 +800,14 @@ 

[PATCH v2 25/28] text: Rename input_method to wl_input_method

2013-04-18 Thread Jan Arne Petersen
From: Jan Arne Petersen jpeter...@openismus.com

Also rename input_method_context to wl_input_method_context,
input_panel to wl_input_panel and input_panel_surface to
wl_input_panel_surface.

Signed-off-by: Jan Arne Petersen jpeter...@openismus.com
---
 clients/keyboard.c | 162 ++---
 clients/weston-simple-im.c | 124 +-
 protocol/input-method.xml  |  14 ++--
 src/input-panel.c  |  16 ++---
 src/text-backend.c |  44 ++--
 5 files changed, 180 insertions(+), 180 deletions(-)

diff --git a/clients/keyboard.c b/clients/keyboard.c
index 6c5ddd7..d83ca3c 100644
--- a/clients/keyboard.c
+++ b/clients/keyboard.c
@@ -35,9 +35,9 @@
 struct keyboard;
 
 struct virtual_keyboard {
-   struct input_panel *input_panel;
-   struct input_method *input_method;
-   struct input_method_context *context;
+   struct wl_input_panel *input_panel;
+   struct wl_input_method *input_method;
+   struct wl_input_method_context *context;
struct display *display;
struct output *output;
char *preedit_string;
@@ -387,11 +387,11 @@ virtual_keyboard_commit_preedit(struct virtual_keyboard 
*keyboard)
strlen(keyboard-preedit_string) == 0)
return;
 
-   input_method_context_cursor_position(keyboard-context,
-0, 0);
-   input_method_context_commit_string(keyboard-context,
-  keyboard-serial,
-  keyboard-preedit_string);
+   wl_input_method_context_cursor_position(keyboard-context,
+   0, 0);
+   wl_input_method_context_commit_string(keyboard-context,
+ keyboard-serial,
+ keyboard-preedit_string);
free(keyboard-preedit_string);
keyboard-preedit_string = strdup();
 }
@@ -403,18 +403,18 @@ virtual_keyboard_send_preedit(struct virtual_keyboard 
*keyboard,
uint32_t index = strlen(keyboard-preedit_string);
 
if (keyboard-preedit_style)
-   input_method_context_preedit_styling(keyboard-context,
-0,
-
strlen(keyboard-preedit_string),
-keyboard-preedit_style);
+   wl_input_method_context_preedit_styling(keyboard-context,
+   0,
+   
strlen(keyboard-preedit_string),
+   
keyboard-preedit_style);
if (cursor  0)
index = cursor;
-   input_method_context_preedit_cursor(keyboard-context,
-   index);
-   input_method_context_preedit_string(keyboard-context,
-   keyboard-serial,
-   keyboard-preedit_string,
-   keyboard-preedit_string);
+   wl_input_method_context_preedit_cursor(keyboard-context,
+  index);
+   wl_input_method_context_preedit_string(keyboard-context,
+  keyboard-serial,
+  keyboard-preedit_string,
+  keyboard-preedit_string);
 }
 
 static void
@@ -438,11 +438,11 @@ keyboard_handle_key(struct keyboard *keyboard, uint32_t 
time, const struct key *
break;
 
if (strlen(keyboard-keyboard-preedit_string) == 0) {
-   
input_method_context_delete_surrounding_text(keyboard-keyboard-context,
-
-1, 1);
-   
input_method_context_commit_string(keyboard-keyboard-context,
-  
keyboard-keyboard-serial,
-  );
+   
wl_input_method_context_delete_surrounding_text(keyboard-keyboard-context,
+   
-1, 1);
+   
wl_input_method_context_commit_string(keyboard-keyboard-context,
+ 
keyboard-keyboard-serial,
+ );
} else {

keyboard-keyboard-preedit_string[strlen(keyboard-keyboard-preedit_string) - 
1] = '\0';


RE: Seats support

2013-04-18 Thread Singh, Satyeshwar
Hi Jason,

 As of right now, weston doesn't have a way (as far as I know) to split
 your devices into multiple seats.  Then again, I don't really see why
 you would want to unless you plan to have two people working on the
 same computer simultaneously (I guess that's a possibility).

In a car, where the real estate is limited, there is only one monitor but dual 
view (so that the driver sees one content and the front seat passenger sees 
another). They both have their own trackpads and this requires two input 
devices to be routed to two different Wayland outputs (each view is a 
wl_output) and can simultaneously control their own view. 

-Satyeshwar

-Original Message-
From: wayland-devel-bounces+satyeshwar.singh=intel@lists.freedesktop.org 
[mailto:wayland-devel-bounces+satyeshwar.singh=intel@lists.freedesktop.org] 
On Behalf Of Jason Ekstrand
Sent: Wednesday, April 17, 2013 1:49 PM
To: Andrew Voron
Cc: wayland-devel@lists.freedesktop.org
Subject: Re: Seats support

Andrew,
The seat concept is meant for each seat to correspond to one human
interface to the desktop.  For example, say you have a fancy laptop
with a touchscreen as well as both a trackpad and a nub.  And let's
say that we further complicate the situation by plugging in an
external keyboard/mouse.  All of those devices would be one one seat.
The wl_pointer would be an agrigate from all three pointing devices
and the wl_keyboard would get key events from both keyboards.  the
wl_touch would just be the one touch screen in this case.

As of right now, weston doesn't have a way (as far as I know) to split
your devices into multiple seats.  Then again, I don't really see why
you would want to unless you plan to have two people working on the
same computer simultaneously (I guess that's a possibility).

The only back-end that currently provides multiple seats is
Hardening's RDP back-end that provides one seat for each connected RDP
client.

I hope that helps,
--Jason Ekstrand

On Wed, Apr 17, 2013 at 3:26 AM, Andrew Voron volan...@gmail.com wrote:
 Hello.

 I want to clarify a seats supporting by wayland(and weston). By seats
 support I mean an ability to define in weston.ini file some seats and
 imput(keyboard, mouse) and output (monitors) channels for each of that
 seats. If the answer is YES, can you point me any docs related to this
 stuff. If NO, could you explain, please, a seat metaphor of the protocol,
 and how it maps in weston implementation (I saw the wl_seat struct is goes
 through all the code for ex.)

 Tnx for advance.


 ___
 wayland-devel mailing list
 wayland-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/wayland-devel

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland] protocol: Make it clear that returned one-shot objects are destroyed

2013-04-18 Thread Kristian Høgsberg
On Wed, Apr 17, 2013 at 06:28:42PM +0100, Rob Bradford wrote:
 From: Rob Bradford r...@linux.intel.com
 
 The objects returned by the frame and sync request are destroyed by the
 compositor after the done event on the wl_callback interface is fired.
 ---
  protocol/wayland.xml | 8 
  1 file changed, 8 insertions(+)

Ah, I remember we talked about that.  Thanks, applied.

Kristian

 diff --git a/protocol/wayland.xml b/protocol/wayland.xml
 index 9d71c23..023067a 100644
 --- a/protocol/wayland.xml
 +++ b/protocol/wayland.xml
 @@ -40,6 +40,10 @@
   handled in-order and events are delivered in-order, this can
   used as a barrier to ensure all previous requests and the
   resulting events have been handled.
 +
 + The object returned by this request will be destroyed by the
 + compositor after the callback is fired and as such the client must not
 + attempt to use it after that point.
/description
arg name=callback type=new_id interface=wl_callback/
  /request
 @@ -1012,6 +1016,10 @@
   damage, or any other state changes. wl_surface.commit triggers a
   display update, so the callback event will arrive after the next
   output refresh where the surface is visible.
 +
 + The object returned by this request will be destroyed by the
 + compositor after the callback is fired and as such the client must not
 + attempt to use it after that point.
/description
  
arg name=callback type=new_id interface=wl_callback/
 -- 
 1.8.1.4
 
 ___
 wayland-devel mailing list
 wayland-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/wayland-devel
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Input and games.

2013-04-18 Thread Todd Showalter
I'm a game developer, and we're hoping to have our games working
properly with Wayland.  Input is a particular point of interest for
me. The traditional desktop input model is what tends to drive input
interfaces, but games have somewhat unique requirements that at times
mesh badly with the standard desktop model.

Is there a roadmap for input support I can look over?  Is there
anything I can do to help make Wayland game-friendly?

Todd.

--
 Todd Showalter, President,
 Electron Jump Games, Inc.
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [UPDATED PATCH wayland] protocol: Add a request and event to identify the visible area for a surface

2013-04-18 Thread Bill Spitzak



Rob Bradford wrote:

From: Rob Bradford r...@linux.intel.com

Add a probe_area request to the wl_shell_surface interface along with a
visible_area event to communicate the result of the probe.

The intention of this request and event is to allow the client to try and
refine the placement of popup windows that would otherwise be unusable.
---
 protocol/wayland.xml | 40 
 1 file changed, 40 insertions(+)

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index edb8a03..023067a 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -874,6 +874,46 @@
to the client owning the popup surface.
   /description
 /event
+
+request name=probe_area


I think this needs to take the extra argument that popup takes, which is 
used to determine if the window is above/below the panel.



+  /description
+  arg name=x type=int/
+  arg name=y type=int/
+  arg name=width type=int/
+  arg name=height type=int/
+  arg name=result type=new_id interface=wl_probe_result/
+/request
+  /interface
+
+  interface name=wl_probe_result version=1
+event name=visible_area
+  description summary=the area that would be visible for a proposed transient 
surface
+This event is fired in response to the probe_area request on the
+object returned for that request. It returns the visible area that
+the surface would occupy when taking into consideration the
+output's edges. If the width or height is zero this indicates that the
+window would not be visible at all in that dimension. In that case the
+x and y values represent the distance to the edge of the viewable
+area.


May want to either say that negative sizes indicate empty, or that 
negative sizes are not allowed to be returned. Basically I think it 
should be the shell's responsibility to return positive width and height.


In your sample implementation the x/y is the maximum of the top-left of 
the visible area and the top-left of the rectangle passed to the 
request. Your intention to return the nearest point on the edge of the 
visible rectangle is a good one, however.


I think you better check what the sample implementation does for rotated 
outputs. Arbitrary transforms are a pain. IMHO the caller does not 
literally want the unclipped rectangle and a rectangle with the same 
area and center and matching for 90 degree rotations will work and 
popups will appear pretty good on rotated clients. This (assuming I 
extracted it correctly from some sample code I had) returns the 
rectangle for the affine transform matrix (ac0,bd0,XY1):


  w' = hypot(aw,ch)
  h' = hypot(bw,dh)
  x' = a(x+w/2)+c(y+h/2)+X-w'/2
  y' = b(x+w/2)+d(y+h/2)+Y-h'/2
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: Input and games.

2013-04-18 Thread Jonas Kulla
2013/4/18 Todd Showalter t...@electronjump.com

 I'm a game developer, and we're hoping to have our games working
 properly with Wayland.  Input is a particular point of interest for
 me. The traditional desktop input model is what tends to drive input
 interfaces, but games have somewhat unique requirements that at times
 mesh badly with the standard desktop model.

 Is there a roadmap for input support I can look over?  Is there
 anything I can do to help make Wayland game-friendly?

 Todd.

 --
  Todd Showalter, President,
  Electron Jump Games, Inc.


Hi Todd!

What exactly do you mean by unique requirements, can you be a little
bit more specific? In general I think the current consensus (correct me if
I'm wrong) is that using the default wayland pointer and keyboard events
plus Joypad support via SDL is sufficient for most purposes.

Personally, I'd be interested in seeing joypads become first class input
devices on wayland (as a capability of wl_seat alongside mice/keyboard
etc.),
seeing that there are already evdev drivers existing for most gamepads.
But I'm unfortunately lacking experience and knowledge in that field,
otherwise I'd give it a hacking attempt myself.

So yeah, for now I think SDL should serve you perfectly well =)

Jonas
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: Seats support

2013-04-18 Thread Jason Ekstrand
Singh,
On Thu, Apr 18, 2013 at 12:35 PM, Singh, Satyeshwar 
satyeshwar.si...@intel.com wrote:

 Hi Jason,

  As of right now, weston doesn't have a way (as far as I know) to split
  your devices into multiple seats.  Then again, I don't really see why
  you would want to unless you plan to have two people working on the
  same computer simultaneously (I guess that's a possibility).

 In a car, where the real estate is limited, there is only one monitor but
 dual view (so that the driver sees one content and the front seat passenger
 sees another). They both have their own trackpads and this requires two
 input devices to be routed to two different Wayland outputs (each view is a
 wl_output) and can simultaneously control their own view.


If this is the case (two different output, two different seats), then why
not have two different compositors?  Perhaps you need some syncing between
them?  Is there something else I'm missing here?

I don't know for sure, but It should be possible (perhaps with a little
modification) to have two simultaneous weston sessions running.  I don't
think that's supported yet, but it may not take much.

--Jason



 -Satyeshwar

 -Original Message-
 From: wayland-devel-bounces+satyeshwar.singh=
 intel@lists.freedesktop.org [mailto:
 wayland-devel-bounces+satyeshwar.singh=intel@lists.freedesktop.org]
 On Behalf Of Jason Ekstrand
 Sent: Wednesday, April 17, 2013 1:49 PM
 To: Andrew Voron
 Cc: wayland-devel@lists.freedesktop.org
 Subject: Re: Seats support

 Andrew,
 The seat concept is meant for each seat to correspond to one human
 interface to the desktop.  For example, say you have a fancy laptop
 with a touchscreen as well as both a trackpad and a nub.  And let's
 say that we further complicate the situation by plugging in an
 external keyboard/mouse.  All of those devices would be one one seat.
 The wl_pointer would be an agrigate from all three pointing devices
 and the wl_keyboard would get key events from both keyboards.  the
 wl_touch would just be the one touch screen in this case.

 As of right now, weston doesn't have a way (as far as I know) to split
 your devices into multiple seats.  Then again, I don't really see why
 you would want to unless you plan to have two people working on the
 same computer simultaneously (I guess that's a possibility).

 The only back-end that currently provides multiple seats is
 Hardening's RDP back-end that provides one seat for each connected RDP
 client.

 I hope that helps,
 --Jason Ekstrand

 On Wed, Apr 17, 2013 at 3:26 AM, Andrew Voron volan...@gmail.com wrote:
  Hello.
 
  I want to clarify a seats supporting by wayland(and weston). By seats
  support I mean an ability to define in weston.ini file some seats and
  imput(keyboard, mouse) and output (monitors) channels for each of that
  seats. If the answer is YES, can you point me any docs related to this
  stuff. If NO, could you explain, please, a seat metaphor of the
 protocol,
  and how it maps in weston implementation (I saw the wl_seat struct is
 goes
  through all the code for ex.)
 
  Tnx for advance.
 
 
  ___
  wayland-devel mailing list
  wayland-devel@lists.freedesktop.org
  http://lists.freedesktop.org/mailman/listinfo/wayland-devel
 
 ___
 wayland-devel mailing list
 wayland-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/wayland-devel

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: Trying to understand how to show a surface

2013-04-18 Thread João Jerónimo

Em 19-04-2013 01:52, dar...@chaosreigns.com escreveu:

Might be useful to post the code.


Ok. I'll post it then.
I'm linking only the wayland libraries. One also needs to use the 
-std=gnu++11 flag.


#include cstdio
#include iostream
#include string
#include cstring
#include wayland-client.h
#include wayland-client-protocol.h
#include unistd.h
#include sys/mman.h
#include cstdlib
#include cerrno
#include fcntl.h
#include assert.h

#define SHM_FILENAME/tmp/shm.bufferXX
#define SHM_SIZE10*1024*1024

using namespace std;

struct display_data_s {
struct wl_compositor *compositor;
struct wl_shell *shell;
struct wl_shm *shm;
struct wl_seat *seat;
struct wl_output *output;

struct wl_shm_pool *shm_pool;
} display_data;

namespace registry_listeners {
void global(void *data,
   struct wl_registry *registry,
   uint32_t id,
   const char *interface,
   uint32_t version)
{
display_data_s *ddata = (display_data_s*)data;
printf(Wayland object reported: %-25s %d;\n, interface, id);

if (strcmp(interface, wl_compositor) == 0) {
ddata-compositor = (struct 
wl_compositor*)wl_registry_bind(registry, id,

 wl_compositor_interface, 1);
} else if (strcmp(interface, wl_shell) == 0) {
ddata-shell = (struct wl_shell*)wl_registry_bind(registry, 
id, wl_shell_interface, 1);

} else if (strcmp(interface, wl_seat) == 0) {
ddata-seat = (struct wl_seat*)wl_registry_bind(registry, id,
 wl_seat_interface, 1);
//wl_seat_add_listener(input-wl_seat, seat_listener, input);
} else if (strcmp(interface, wl_shm) == 0) {
ddata-shm = (struct wl_shm*)wl_registry_bind(registry, id,
 wl_shm_interface, 1);
//wl_shm_add_listener(client-wl_shm, shm_listener, client);
} else if (strcmp(interface, wl_output) == 0) {
ddata-output = (struct 
wl_output*)wl_registry_bind(registry, id,

 wl_output_interface, 1);
//wl_output_add_listener(output-wl_output, 
output_listener, output);

}
}

void global_remove(void *data,
  struct wl_registry *wl_registry,
  uint32_t name)
{
return;
}

}

namespace surface_listeners {
void enter(void *data,
  struct wl_surface *wl_surface,
  struct wl_output *output)
{
cout  surface enters an output  endl;
}

void leave(void *data,
  struct wl_surface *wl_surface,
  struct wl_output *output)
{
cout  surface leaves an output  endl;

}
}

int main()
{
try {
printf(Hello world! Example Wayland client...\n);

// Connect
struct wl_display *display;
display = wl_display_connect(NULL);
if (!display) throw string(Could not connect to display);
cout  Connect ok\n  endl;

// Registry... Listing objects
cout  Listing globals:  endl;
struct wl_registry *reg = wl_display_get_registry(display);
struct wl_registry_listener reg_listener;
reg_listener.global = registry_listeners::global;
reg_listener.global_remove = registry_listeners::global_remove;
wl_registry_add_listener(reg, reg_listener, 
(void*)display_data);


wl_display_dispatch(display);
wl_display_roundtrip(display);
cout  End of globals...  endl  endl;

// Create surface
struct wl_surface *surface = 
wl_compositor_create_surface(display_data.compositor);

assert(surface);
struct wl_surface_listener surface_listener;
surface_listener.enter = surface_listeners::enter;
surface_listener.leave = surface_listeners::leave;
wl_surface_add_listener(surface, surface_listener, NULL);
//wl_display_dispatch(display);

// Shell surface... later.
//struct wl_shell_surface *shell_surface;
//shell_surface = 
wl_shell_get_shell_surface(display_data.shell, surface);


char shm_filename[] = SHM_FILENAME;
int shmfd = mkostemp(shm_filename, O_CLOEXEC);
if (shmfd == -1) throw (string(could not create shm buffer 
file... errno is ) + to_string(errno));

ftruncate(shmfd, SHM_SIZE);
uint32_t *buffer = (uint32_t*)mmap(NULL, SHM_SIZE, 
PROT_READ|PROT_WRITE, MAP_SHARED, shmfd, 0);
if (buffer == MAP_FAILED) throw (string(mmap failed... errno 
is ) + to_string(errno));
display_data.shm_pool = wl_shm_create_pool(display_data.shm, 
shmfd, SHM_SIZE);
struct wl_buffer *buffer_wl = (struct 
wl_buffer*)wl_shm_pool_create_buffer(display_data.shm_pool, 0,

 100, 200,// Largura, Altura
 100*4 /*stride*/, 
WL_SHM_FORMAT_ARGB