[PATCH] QA: Add log for wayland performance analysis

2015-02-06 Thread Quanxian Wang
Overview

This patch is to provide the mechanism to track weston rendering performance.

With these log information,
A tool is provided separately to analyze Wayland Apps or Server rendering
performance data and show them with FPS performance charts. These charts
give a clear image of rendering performance status. More important is 
the chart gives developer a hint which step cause the performance issue.
In the wiki page, you can find more successful test cases with FPS chart.

If wayland developer like it, we can push the code into weston upstream.
(writen with python)

Tools source code:
https://github.com/quanxianwang/wr-graph.git

You can find more information in wiki page.
https://wiki.tizen.org/wiki/Wayland_Rendering_Analysis_Tool

Quanxian Wang (1):
  Add wayland rendering performance log

 clients/perf_log_client.h | 51 ++
 clients/simple-egl.c  |  6 ++
 clients/window.c  |  5 +
 desktop-shell/shell.c | 12 ---
 desktop-shell/shell.h |  1 -
 src/compositor.c  |  8 
 src/input.c   | 52 +++
 src/log.c | 23 -
 src/perf_log_server.h | 38 ++
 9 files changed, 187 insertions(+), 9 deletions(-)
 create mode 100644 clients/perf_log_client.h
 create mode 100644 src/perf_log_server.h

-- 
1.8.1.2

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


[PATCH] weston: Add weston rendering performance log

2015-02-06 Thread Quanxian Wang
With PERF_DEBUG is enabled, the performance log will be recorded
for every key rendering path.

At the same time, with a tool provided, performance chart of weston apps
could be generated.

This patch provides following changes.
1) Add performance log mechanism for server and client.
   just like weston_log, weston_plog is used for performance log.
2) Touch performance log is added to monitor touch performance.
3) Some weston native apps performance logs are added.
   For example weston-simple-egl, weston-terminal

Performance Anaylis Tools source code is located:
https://github.com/quanxianwang/wr-graph.git

Related tools wiki:
https://wiki.tizen.org/wiki/Wayland_Rendering_Analysis_Tool

Signed-Off-By Quanxian Wang 
Signed-Off-By Xiaoyanx Zhang 
---
 clients/perf_log_client.h | 51 ++
 clients/simple-egl.c  |  6 ++
 clients/window.c  |  5 +
 desktop-shell/shell.c | 12 ---
 desktop-shell/shell.h |  1 -
 src/compositor.c  |  8 
 src/input.c   | 52 +++
 src/log.c | 23 -
 src/perf_log_server.h | 38 ++
 9 files changed, 187 insertions(+), 9 deletions(-)
 create mode 100644 clients/perf_log_client.h
 create mode 100644 src/perf_log_server.h

diff --git a/clients/perf_log_client.h b/clients/perf_log_client.h
new file mode 100644
index 000..919a4c3
--- /dev/null
+++ b/clients/perf_log_client.h
@@ -0,0 +1,51 @@
+#ifndef __PERF_LOG__
+#define __PERF_LOG__
+#include 
+#include 
+#include 
+#include 
+
+static const char *flag_str[4] = {"start", "end", "id", "point"};
+
+enum PERF_FLAG {
+   PERF_START,
+   PERF_END,
+   PERF_ID,
+   PERF_POINT
+};
+
+#define PERF_LOG(msg, flag) \
+   do { \
+   struct timeval tv; \
+   struct tm *brokendown_time;\
+   char string[128];\
+   gettimeofday(&tv, NULL);\
+   brokendown_time = localtime(&tv.tv_sec);\
+   strftime(string, sizeof(string),\
+"%H:%M:%S", brokendown_time);\
+   fprintf(stderr, "[%s.%06li] perf_%s:%s\n",\
+   string, tv.tv_usec, flag_str[flag], msg); \
+   } while (0)
+
+inline void
+print_plog(struct wl_proxy *proxy, const char *msg, int flag)
+{
+   char str[32] = {};
+   uint32_t id;
+
+   if (proxy)
+   id = wl_proxy_get_id(proxy);
+   else {
+   PERF_LOG(msg, flag);
+   return;
+   }
+
+   if (msg)
+   sprintf(str, "%s_%d", msg, id);
+   else
+   sprintf(str, "%d", id);
+
+   PERF_LOG(str, flag);
+}
+
+#endif
diff --git a/clients/simple-egl.c b/clients/simple-egl.c
index d3c205f..0450373 100644
--- a/clients/simple-egl.c
+++ b/clients/simple-egl.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include "perf_log_client.h"
 
 #include "xdg-shell-client-protocol.h"
 #include 
@@ -486,6 +487,9 @@ redraw(void *data, struct wl_callback *callback, uint32_t 
time)
eglQuerySurface(display->egl.dpy, window->egl_surface,
EGL_BUFFER_AGE_EXT, &buffer_age);
 
+   print_plog((struct wl_proxy *)window->surface, "client", PERF_START);
+   print_plog((struct wl_proxy *)window->surface, NULL, PERF_ID);
+
glViewport(0, 0, window->geometry.width, window->geometry.height);
 
glUniformMatrix4fv(window->gl.rotation_uniform, 1, GL_FALSE,
@@ -515,6 +519,8 @@ redraw(void *data, struct wl_callback *callback, uint32_t 
time)
wl_surface_set_opaque_region(window->surface, NULL);
}
 
+   print_plog((struct wl_proxy *)window->surface, "client", PERF_END);
+
if (display->swap_buffers_with_damage && buffer_age > 0) {
rect[0] = window->geometry.width / 4 - 1;
rect[1] = window->geometry.height / 4 - 1;
diff --git a/clients/window.c b/clients/window.c
index c5082ba..6b8e883 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -71,6 +71,7 @@ typedef void *EGLContext;
 #include "../shared/os-compatibility.h"
 
 #include "window.h"
+#include "perf_log_client.h"
 
 #include 
 #include "ivi-application-client-protocol.h"
@@ -2393,6 +2394,10 @@ frame_handle_status(struct window_frame *frame, struct 
input *input,
 
if ((status & FRAME_STATUS_MOVE) && window->xdg_surface) {
input_ungrab(input);
+
+   print_plog((struct wl_proxy *)window->main_surface->surface,
+  "client process", PERF_END);
+
xdg_surface_move(window->xdg_surface,
  

[PATCH V4 1/7] weston: Add weston randr protocol

2014-04-24 Thread Quanxian Wang
Weston randr protocol will provide interfaces to
1) Scaling
   Scale the output to be more than 1.
2) Transform
   Rotate output to be 8 type of angles.
   0, 90, 180, 270, flip-0, flip-90, flip-180, flip-270
3) Mode Set
   Fuzzy set: First matched, first active.
   Exact set:
  a) Exact Timing set
  b) Exact mode number set (select the nth mode from mode list)
4) New a mode of output
   a) newmode for RDP
  RDP developers should add additional newmode backend interface for that.
   b) newtiming for drm backend
5) Delete a mode of output
   All matched, all deleted.
   Fuzzy and exact match are supported as described above
6) Re-position of output
   Primary, auto, leftof, rightof, above, below are supported.
   Primary: let output to the top left most output (x=0, y=0).
   Auto: re-organize all outputs to be horizontal with extended mode.
   leftof: left of relative output. So rightof, above, and below.
7) Support configure file
   Client could put all configure request in one file with
   defined format and submit it from randr interface.
8) Provide a set of actions above in one commit
9) Support multiple outputs operations with one commit.

This protocol is not exposed to public. It is only for
QA testing and Admin configuration currently.

Signed-off-by: Quanxian Wang 
---
 protocol/Makefile.am |   1 +
 protocol/randr.xml   | 316 +++
 2 files changed, 317 insertions(+)
 create mode 100644 protocol/randr.xml

diff --git a/protocol/Makefile.am b/protocol/Makefile.am
index 5e331a7..df2e070 100644
--- a/protocol/Makefile.am
+++ b/protocol/Makefile.am
@@ -5,6 +5,7 @@ protocol_sources =  \
text.xml\
input-method.xml\
workspaces.xml  \
+   randr.xml   \
text-cursor-position.xml\
wayland-test.xml\
xdg-shell.xml   \
diff --git a/protocol/randr.xml b/protocol/randr.xml
new file mode 100644
index 000..e6476f5
--- /dev/null
+++ b/protocol/randr.xml
@@ -0,0 +1,316 @@
+
+
+
+  
+Copyright © 2014 Quanxian Wang
+Copyright © 2014 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.
+  
+
+  
+
+  This interface contains all data types used by weston randr protocol.
+
+
+
+  
+   Weston operation type
+  
+  
+  
+
+
+
+  
+   Output operation type
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+
+
+
+  
+   Weston randr operation return type
+  
+  
+  
+  
+  
+
+  
+
+  
+
+   The weston randr interface provides output property setting
+   capabilities. The properties include output mode setting,
+   scale, transform, layout, and etc. The interface is not
+   exposed to public while it is designed for QA testing and Admin.
+   This interface refers to the design idea of xrandr protocol.
+
+
+
+  
+   Destroy the weston_randr object which will not be used anymore.
+  
+
+
+
+  
+   The flag describes properties of an output mode.
+   Once clients get the mode change with these flags,
+   they should take the related action. For example,
+   del flag tells clients that mode is not used anymore.
+   Clients should delete it at once.
+  
+  
+  
+
+
+
+  
+   Set the nth mode
+  
+  
+  
+
+
+
+  
+   Fuzzy output mode setting
+  
+  
+  
+  
+  
+
+
+
+  
+   Exact output mo

[PATCH V4 4/7] Add new mode function in drm backend

2014-04-24 Thread Quanxian Wang
provide drm_output_new_mode interface to create new mode
from outsite instead of only from edid or configure.

Signed-off-by: Quanxian Wang 
---
 src/compositor-drm.c | 92 
 1 file changed, 92 insertions(+)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 154e15e..f988692 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -1390,6 +1390,96 @@ drm_output_add_mode(struct drm_output *output, 
drmModeModeInfo *info)
 }
 
 static int
+drm_output_compare_timing(struct weston_mode *mode,
+ uint32_t clock,
+ int hdisplay,
+ int hsync_start,
+ int hsync_end,
+ int htotal,
+ int vdisplay,
+ int vsync_start,
+ int vsync_end,
+ int vtotal,
+ int vscan,
+ uint32_t flags)
+{
+   struct drm_mode *drmmode = (struct drm_mode *)mode;
+   drmModeModeInfo *modeinfo = &drmmode->mode_info;
+
+   return (modeinfo->clock == clock &&
+   modeinfo->hdisplay == hdisplay &&
+   modeinfo->hsync_start == hsync_start &&
+   modeinfo->hsync_end == hsync_end &&
+   modeinfo->htotal == htotal &&
+   modeinfo->vdisplay == vdisplay &&
+   modeinfo->vsync_start == vsync_start &&
+   modeinfo->vsync_end == vsync_end &&
+   modeinfo->vtotal == vtotal &&
+   modeinfo->vscan == vscan &&
+   modeinfo->flags == flags);
+}
+
+static struct weston_mode *
+drm_output_new_timing(struct weston_output *output,
+ uint32_t clock,
+ int hdisplay,
+ int hsync_start,
+ int hsync_end,
+ int htotal,
+ int vdisplay,
+ int vsync_start,
+ int vsync_end,
+ int vtotal,
+ int vscan,
+ uint32_t flags)
+{
+   drmModeModeInfo *modeinfo;
+   struct drm_mode *mode = NULL;
+   uint64_t refresh;
+
+   modeinfo = zalloc(sizeof(*modeinfo));
+   if (modeinfo == NULL)
+   return NULL;
+
+   modeinfo->type = DRM_MODE_TYPE_USERDEF;
+   modeinfo->hskew = 0;
+   modeinfo->hdisplay = hdisplay;
+   modeinfo->hsync_start = hsync_start;
+   modeinfo->hsync_end = hsync_end;
+   modeinfo->htotal = htotal;
+   modeinfo->vdisplay = vdisplay;
+   modeinfo->vsync_start = vsync_start;
+   modeinfo->vsync_end = vsync_end;
+   modeinfo->vtotal = vtotal;
+   modeinfo->vscan = vscan;
+   modeinfo->flags = flags;
+   modeinfo->clock = clock;
+
+   /* Calculate higher precision (mHz) refresh rate */
+   refresh = (clock * 100LL / htotal +
+  vtotal / 2) / vtotal;
+
+   if (flags & DRM_MODE_FLAG_INTERLACE)
+   refresh *= 2;
+   if (flags & DRM_MODE_FLAG_DBLSCAN)
+   refresh /= 2;
+   if (vscan > 1)
+   refresh /= vscan;
+
+   /* For new timing, there is no set for vrefresh.
+* But in choose_mode, it will check with refresh value.
+* So set vrefresh value to be refresh.
+*/
+   modeinfo->vrefresh = refresh;
+
+   mode = drm_output_add_mode((struct drm_output *)output, modeinfo);
+   if (mode)
+   return &mode->base;
+   else
+   return NULL;
+}
+
+static int
 drm_subpixel_to_wayland(int drm_value)
 {
switch (drm_value) {
@@ -2046,6 +2136,8 @@ create_output_for_connector(struct drm_compositor *ec,
output->base.assign_planes = drm_assign_planes;
output->base.set_dpms = drm_set_dpms;
output->base.switch_mode = drm_output_switch_mode;
+   output->base.new_timing = drm_output_new_timing;
+   output->base.compare_timing = drm_output_compare_timing;
 
output->base.gamma_size = output->original_crtc->gamma_size;
output->base.set_gamma = drm_output_set_gamma;
-- 
1.8.1.2

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


[PATCH V4 0/7] Add weston randr protocol

2014-04-24 Thread Quanxian Wang
It should be the final feature updates. Next I will focus on
the comment from developers and send the updates.
If more features are needed, it will be better to be implemented in next 
release.

Sorry for thousands of code. Before submit, I have done strictly grammar check, 
coding style check
and testing and try to let code to be readable. Wish this could let reviewer 
spend less effort on review.

Changes in V4:
a) Configure file is supported. Thanks Bryce's commment.
   configure file parser is provided.
b) Output movement algorithm is done to support movements including rightof, 
leftof, above, below
auto, and primary.
c) Clone and output disable/enable are also added into algorithm but it needs 
support from compositor.
   It will be easy to enable if compositor is ready.
d) Some bug fixes and previous V3 code review from Hardening.

Thanks for your great support.

Regards

Quanxian Wang

GENERAL SUMMARY:

Important Notes:
This protocol is not exposed to public. It is only for
QA testing and Admin configuration at the moment.

Objective:
The idea is from xrandr provided by xserver. *Dynamic* output mode
setting is the main objective of this protocol. Remember,
it is one shot operation. For example, if setting the mode,
just call one request weston_randr_set_mode and commit them.
Result will be returned in done event.

With this protocol, weston-wrandr application is developed to help 
implement randr protocol in command line just like xrandr command 
in xserver.

FEATURES:
1) Scaling
   Scale the output to be more than 1.
2) Transform
   Rotate output to be 8 type of angles.
   0, 90, 180, 270, flip-0, flip-90, flip-180, flip-270
3) Mode Set
   Fuzzy set: First matched, first active.
  For example: weston-wrandr --output HDMI3 --mode 1280x1024
 This will select the first matched mode with
 width=1280 and height=1024.
   Exact set:
  a) Exact Timing set
 For example:
 weston-wrandr --output HDMI3 
--timing='4,800,840,968,1056,0,600,601,605,628,0,+hsync'
  b) Exact mode number set (select the nth mode from mode list)
 For example:
 weston-wrandr --output HDMI3 --mode 2
4) New a mode of output
   a) newmode for RDP (RDP developers should add additional newmode backend 
interface for that.)
  Example:
  weston-wrandr --output HDMI3 --newmode='1280x1024@5'
   b) newtiming for drm backend
  Example:
  weston-wrandr --output HDMI3 
--newtiming='4,800,840,968,1056,0,600,601,605,628,0,+hsync'

   NOTICE: This action is bound with output.
5) Delete a mode of output
   All matched, all deleted.
   Fuzzy and exact match are supported as described above.

6) Re-position of output
   Primary, auto, leftof, rightof, above, below are supported.
   Primary: let output to the top left most output (x=0, y=0).
   Auto: re-organize all outputs to be horizontal with extended mode.
   leftof: left of relative output. So rightof, above, and below.
   Example: weston-wrandr --output HDMI3 --leftof VGA1

7) Support configure file
   Client can put all configure request in one file with
   defined format and submit it from randr interface.
   This option will be more flexible for future extension.
   Thanks for Bryce's idea for that.

   For example:
   weston-wrandr --configure /home/tizen/monitor.txt

   The content of configure file will be like that:
   
   [compositor]
   auto=1
   [HDMI3]
   mode=1
   scale=2
   [VGA1]
   mode=1024x768
   transform=0
   scale=2
8) Provide a set of actions above in one commit 
   Requests can be combined together in one commit.
   like configure file.
   For example:
   weston-randr --output HDMI3 --transform 3 --scale 2 --mode 2 -leftof VGA1
9) Support multiple outputs operations with one commit.
   Just like configure file example. There are two outputs are processed.

OTHERS IMPORTANT:
a) Movement algorithm has included horizontal movement, vertical movement
   and clone operation. This algorithm is specailly designed for weston
   compositor as a common module. The algorithm detailed introduction has
   been included in the header file(module/wrandr/randr_layout_algorithm.h). 
   In weston compositor, it can be included if moving output.
   Generally it can be used in weston.ini which contains layout configure or
   other interfaces which want to move/initialize outputs if weston.ini support 
layout.
   By the way, movement algorithm is designed to support any number of outputs.

b) Clone, disable/enable output method are left for future development.
   Depends on the compositor process. Once compositor supports them, it
   will be enabled in randr interface.

PATCH DEPENDENCY:
1) [PATCH 0/3] Add wl_output name event
2) [PATCH] desktop-shell: Bug fix client apps because of output change

BUIDLING and INSTALLING:
When you build weston, add option --enable-wrandr to enable building of this 
module.
 ./autogen.sh --enable-wrandr ...
When you run wes

[PATCH V4 2/7] weston: Add the weston randr support in compositor.h

2014-04-24 Thread Quanxian Wang
1) Add weston_randr definition and randr_backend intreface.
2) Export functions used in compositor.c so that module wrandr
   could use them. For example, weston_output_transform_scale_init.
3) Support new_mode backend interface in output structure.

Signed-off-by: Quanxian Wang 
---
 src/compositor.h | 53 +
 1 file changed, 53 insertions(+)

diff --git a/src/compositor.h b/src/compositor.h
index ace75da..008b0f2 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -172,6 +172,23 @@ enum weston_mode_switch_op {
WESTON_MODE_SWITCH_RESTORE_NATIVE
 };
 
+enum weston_output_rel_motion {
+   MOVE_LEFTOF,
+   MOVE_RIGHTOF,
+   MOVE_ABOVE,
+   MOVE_BELOW
+};
+
+struct wrandr {
+   struct weston_compositor *compositor;
+   struct wl_global *global;
+   struct wl_resource *resource;
+   struct wl_listener destroy_listener;
+   struct {
+   struct wl_list request_list;
+   } pending;
+};
+
 struct weston_output {
uint32_t id;
char *name;
@@ -179,6 +196,9 @@ struct weston_output {
void *renderer_state;
 
struct wl_list link;
+   struct wl_list hlink; /* horizontal link */
+   struct wl_list vlink; /* vertical link */
+   struct wl_list clink; /* clone link */
struct wl_list resource_list;
struct wl_global *global;
struct weston_compositor *compositor;
@@ -218,6 +238,33 @@ struct weston_output {
void (*destroy)(struct weston_output *output);
void (*assign_planes)(struct weston_output *output);
int (*switch_mode)(struct weston_output *output, struct weston_mode 
*mode);
+   struct weston_mode * (*new_timing)(struct weston_output *output,
+  uint32_t clock,
+  int hdisplay,
+  int hsync_start,
+  int hsync_end,
+  int htotal,
+  int vdisplay,
+  int vsync_start,
+  int vsync_end,
+  int vtotal,
+  int vscan,
+  uint32_t flags);
+
+   int (*compare_timing)(struct weston_mode *mode,
+ uint32_t clock,
+ int hdisplay,
+ int hsync_start,
+ int hsync_end,
+ int htotal,
+ int vdisplay,
+ int vsync_start,
+ int vsync_end,
+ int vtotal,
+ int vscan,
+ uint32_t flags);
+
+   struct weston_mode * (*new_mode)(int width, int height, int refresh);
 
/* backlight values are on 0-255 range, where higher is brighter */
int32_t backlight_current;
@@ -567,6 +614,7 @@ struct weston_compositor {
struct wl_display *wl_display;
struct weston_shell_interface shell_interface;
struct weston_config *config;
+   struct weston_output *primary;
 
/* surface signals */
struct wl_signal activate_signal;
@@ -635,6 +683,7 @@ struct weston_compositor {
 
/* Raw keyboard processing (no libxkbcommon initialization or handling) 
*/
int use_xkbcommon;
+   struct wrandr *randr;
 };
 
 struct weston_buffer {
@@ -1359,6 +1408,10 @@ weston_surface_set_color(struct weston_surface *surface,
 void
 weston_surface_destroy(struct weston_surface *surface);
 
+void
+weston_output_transform_scale_init(struct weston_output *output,
+  uint32_t transform, uint32_t scale);
+
 int
 weston_output_switch_mode(struct weston_output *output, struct weston_mode 
*mode,
int32_t scale, enum weston_mode_switch_op op);
-- 
1.8.1.2

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


[PATCH V4 3/7] weston: Add enable-wrandr option and export common functions

2014-04-24 Thread Quanxian Wang
When starting weston with parameter --enable-wrandr,
it will automatically load wrandr.so module. This is
for QA testing and Admin configuration.

weston_output_transform_scale_init will be used by
weston randr module.

Signed-off-by: Quanxian Wang 
---
 src/compositor.c | 35 +--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index c031edc..5708e4e 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -88,7 +88,7 @@ sigchld_handler(int signal_number, void *data)
return 1;
 }
 
-static void
+WL_EXPORT void
 weston_output_transform_scale_init(struct weston_output *output,
   uint32_t transform, uint32_t scale);
 
@@ -3297,7 +3297,7 @@ weston_output_update_matrix(struct weston_output *output)
output->dirty = 0;
 }
 
-static void
+WL_EXPORT void
 weston_output_transform_scale_init(struct weston_output *output, uint32_t 
transform, uint32_t scale)
 {
output->transform = transform;
@@ -4140,10 +4140,12 @@ int main(int argc, char *argv[])
char *log = NULL;
int32_t idle_time = 300;
int32_t help = 0;
+   int32_t enable_wrandr = 0;
char *socket_name = "wayland-0";
int32_t version = 0;
struct weston_config *config;
struct weston_config_section *section;
+   struct weston_output *last, *output;
 
const struct weston_option core_options[] = {
{ WESTON_OPTION_STRING, "backend", 'B', &option_backend },
@@ -4151,6 +4153,7 @@ int main(int argc, char *argv[])
{ WESTON_OPTION_STRING, "socket", 'S', &socket_name },
{ WESTON_OPTION_INTEGER, "idle-time", 'i', &idle_time },
{ WESTON_OPTION_STRING, "modules", 0, &option_modules },
+   { WESTON_OPTION_STRING, "enable-wrandr", 0, &enable_wrandr},
{ WESTON_OPTION_STRING, "log", 0, &log },
{ WESTON_OPTION_BOOLEAN, "help", 'h', &help },
{ WESTON_OPTION_BOOLEAN, "version", 0, &version },
@@ -4233,6 +4236,34 @@ int main(int argc, char *argv[])
ec->idle_time = idle_time;
ec->default_pointer_grab = NULL;
 
+   /* Initialize all links of output */
+   last = NULL;
+   wl_list_for_each(output, &ec->output_list, link) {
+   if (last) {
+   last->hlink.next = &output->hlink;
+   output->hlink.prev = &last->hlink;
+   } else {
+   output->hlink.prev = NULL;
+   }
+   last = output;
+   }
+
+   /* Set default most left up output. */
+   wl_list_for_each(output, &ec->output_list, link) {
+   if (output->x == 0 && output->y == 0) {
+   ec->primary = output;
+   break;
+   }
+   }
+
+   /* Add wrandr module */
+   if (enable_wrandr) {
+   if (!option_modules)
+   option_modules = strdup("wrandr.so");
+   else
+   option_modules = strcat(option_modules, ",wrandr.so");
+   }
+
setenv("WAYLAND_DISPLAY", socket_name, 1);
 
if (option_shell)
-- 
1.8.1.2

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


[PATCH V4 7/7] Apps: Add weston-randr application

2014-04-24 Thread Quanxian Wang
Functions implemented in this application
1) Query output mode list
2) Scaling and Transform
   Scale the output to be more than 1.
   Rotate output to be 8 type of angles.
   0, 90, 180, 270, flip-0, flip-90, flip-180, flip-270
3) Mode Set
   Fuzzy set: First matched, first active.
   Exact set:
  a) Exact Timing set
  b) Exact mode number set (select the nth mode from mode list)
4) New a mode of output
   a) newmode for RDP
  RDP developers should add additional newmode backend interface for that.
   b) newtiming for drm backend
5) Delete a mode of output
   All matched, all deleted.
   Fuzzy and exact match are supported as described above
6) Re-position of output
   Primary, auto, leftof, rightof, above, below are supported.
   Primary: let output to the top left most output (x=0, y=0).
   Auto: re-organize all outputs to be horizontal with extended mode.
   leftof: left of relative output. So rightof, above, and below.
7) Support configure file
   Client could put all configure request in one file with
   defined format and submit it from randr interface.
8) Provide a set of actions above in one commit
9) Support multiple outputs operations in configure file

More details, please run "weston-wrandr -h"

Signed-off-by: Quanxian Wang 
---
 clients/Makefile.am |9 +
 clients/wrandr.c| 1314 +++
 2 files changed, 1323 insertions(+)
 create mode 100644 clients/wrandr.c

diff --git a/clients/Makefile.am b/clients/Makefile.am
index 6052503..9116b02 100644
--- a/clients/Makefile.am
+++ b/clients/Makefile.am
@@ -60,6 +60,7 @@ libexec_PROGRAMS =\
weston-desktop-shell\
weston-screenshooter\
$(screensaver)  \
+   weston-wrandr   \
weston-keyboard \
weston-simple-im
 
@@ -103,6 +104,12 @@ libtoytoolkit_la_LIBADD =  \
 weston_flower_SOURCES = flower.c
 weston_flower_LDADD = libtoytoolkit.la
 
+weston_wrandr_SOURCES =\
+   wrandr.c\
+   randr-protocol.c\
+   randr-client-protocol.h
+weston_wrandr_LDADD = libtoytoolkit.la $(CLIENT_LIBS)
+
 weston_screenshooter_SOURCES = \
screenshot.c\
screenshooter-protocol.c\
@@ -213,6 +220,8 @@ BUILT_SOURCES = \
text-cursor-position-protocol.c \
text-protocol.c \
text-client-protocol.h  \
+   randr-protocol.c\
+   randr-client-protocol.h \
input-method-protocol.c \
input-method-client-protocol.h  \
desktop-shell-client-protocol.h \
diff --git a/clients/wrandr.c b/clients/wrandr.c
new file mode 100644
index 000..2409788
--- /dev/null
+++ b/clients/wrandr.c
@@ -0,0 +1,1314 @@
+/*
+ * Copyright © 2014 Quanxian Wang
+ * Copyright © 2014 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "randr-client-protocol.h"
+#include 
+#include 
+#include "../shared/config-parser.h"
+
+#define NAME_SIZE 64
+#define ARRAY_LENGTH(a) (sizeof(a) / sizeof(a)[0])
+
+enum randr_next_action {
+   RANDR_EXIT = 0,
+   RANDR_COMMIT = 1,
+};
+
+#ifndef MOVE_LEFTOF
+enum randr_output_rel_motion {
+   MOVE_LEFTOF,
+   MOVE_RIGHTOF,
+   MOVE_ABOVE,
+   MOVE_BELOW
+};
+#endif
+
+static int running = 1;
+
+struct output;
+
+struct timing {
+   int refresh;
+   

[PATCH V4 6/7] weston: Add configure to support wrandr.

2014-04-24 Thread Quanxian Wang
Signed-off-by: Quanxian Wang 
---
 Makefile.am  | 5 +
 configure.ac | 8 
 2 files changed, 13 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index f22c542..254cde7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,11 +6,16 @@ if ENABLE_XWAYLAND
 xwayland_subdir = xwayland
 endif
 
+if BUILD_WRANDR
+randr_dir = module/wrandr
+endif
+
 SUBDIRS =  \
shared  \
src \
$(xwayland_subdir)  \
desktop-shell   \
+   $(randr_dir)\
clients \
data\
protocol\
diff --git a/configure.ac b/configure.ac
index cce1850..01e7429 100644
--- a/configure.ac
+++ b/configure.ac
@@ -409,6 +409,12 @@ if test "x$enable_dbus" != "xno"; then
 fi
 AM_CONDITIONAL(ENABLE_DBUS, test "x$enable_dbus" = "xyes")
 
+AC_ARG_ENABLE(wrandr, [  --disable-wrandr],, enable_wrandr=no)
+AM_CONDITIONAL(BUILD_WRANDR, test x$enable_wrandr = xyes)
+if test x$enable_wrandr = xyes; then
+  AC_DEFINE([BUILD_WRANDR], [1], [Build the wrandr])
+fi
+
 AC_ARG_ENABLE(wcap-tools, [  --disable-wcap-tools],, enable_wcap_tools=yes)
 AM_CONDITIONAL(BUILD_WCAP_TOOLS, test x$enable_wcap_tools = xyes)
 if test x$enable_wcap_tools = xyes; then
@@ -498,6 +504,8 @@ AC_CONFIG_FILES([Makefile
 src/Makefile
 xwayland/Makefile
 desktop-shell/Makefile
+module/Makefile
+module/wrandr/Makefile
 src/version.h
 src/weston.pc
 clients/Makefile
-- 
1.8.1.2

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


[PATCH V3 6/7] weston: Add configure to support wrandr.

2014-04-07 Thread Quanxian Wang
Signed-off-by: Quanxian Wang 
---
 Makefile.am  | 5 +
 configure.ac | 8 
 2 files changed, 13 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index f22c542..254cde7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,11 +6,16 @@ if ENABLE_XWAYLAND
 xwayland_subdir = xwayland
 endif
 
+if BUILD_WRANDR
+randr_dir = module/wrandr
+endif
+
 SUBDIRS =  \
shared  \
src \
$(xwayland_subdir)  \
desktop-shell   \
+   $(randr_dir)\
clients \
data\
protocol\
diff --git a/configure.ac b/configure.ac
index cce1850..01e7429 100644
--- a/configure.ac
+++ b/configure.ac
@@ -409,6 +409,12 @@ if test "x$enable_dbus" != "xno"; then
 fi
 AM_CONDITIONAL(ENABLE_DBUS, test "x$enable_dbus" = "xyes")
 
+AC_ARG_ENABLE(wrandr, [  --disable-wrandr],, enable_wrandr=no)
+AM_CONDITIONAL(BUILD_WRANDR, test x$enable_wrandr = xyes)
+if test x$enable_wrandr = xyes; then
+  AC_DEFINE([BUILD_WRANDR], [1], [Build the wrandr])
+fi
+
 AC_ARG_ENABLE(wcap-tools, [  --disable-wcap-tools],, enable_wcap_tools=yes)
 AM_CONDITIONAL(BUILD_WCAP_TOOLS, test x$enable_wcap_tools = xyes)
 if test x$enable_wcap_tools = xyes; then
@@ -498,6 +504,8 @@ AC_CONFIG_FILES([Makefile
 src/Makefile
 xwayland/Makefile
 desktop-shell/Makefile
+module/Makefile
+module/wrandr/Makefile
 src/version.h
 src/weston.pc
 clients/Makefile
-- 
1.8.1.2

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


[PATCH V3 1/7] weston: Add weston randr protocol

2014-04-07 Thread Quanxian Wang
Weston randr protocol will provide interfaces to
1) Mode set of output (scale, transform, mode setting)
   For mode setting, three match methods are provided.
2) Position of output (currently support leftof, rightof)
   More need to be done, above, below and any positoion of output with (x,y).
3) New a custom mode
   This action will bind with output automatically.
4) Delete mode
   Three match methods are provided.
5) Provide a set of actions above in one shot
   1-4 actions could be combined together in one shot.
6) Support multiple outputs operation with one commit.
   The result event will be sent with output parameter one by one.

This protocol is not exposed to public. It is only for
QA testing and Admin configuration currently.

Signed-off-by: Quanxian Wang 
---
 protocol/Makefile.am |   1 +
 protocol/randr.xml   | 260 +++
 2 files changed, 261 insertions(+)
 create mode 100644 protocol/randr.xml

diff --git a/protocol/Makefile.am b/protocol/Makefile.am
index 5e331a7..df2e070 100644
--- a/protocol/Makefile.am
+++ b/protocol/Makefile.am
@@ -5,6 +5,7 @@ protocol_sources =  \
text.xml\
input-method.xml\
workspaces.xml  \
+   randr.xml   \
text-cursor-position.xml\
wayland-test.xml\
xdg-shell.xml   \
diff --git a/protocol/randr.xml b/protocol/randr.xml
new file mode 100644
index 000..5ac508a
--- /dev/null
+++ b/protocol/randr.xml
@@ -0,0 +1,260 @@
+
+
+
+  
+Copyright © 2014 Quanxian Wang
+Copyright © 2014 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.
+  
+
+  
+
+  This interface is to define the data type used by weston randr protocol.
+
+
+
+  
+   Weston operation type
+  
+  
+
+
+
+  
+   Output operation type
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+
+
+
+  
+   Weston randr operation return type
+  
+  
+  
+  
+
+  
+
+  
+
+   The weston randr interface provides output property setting
+   capabilities. The properties include output mode setting,
+   scale, transform, layout, and etc. The interface is not
+   exposed to public while it is designed for QA testing and Admin.
+   This interface refers to the design idea of xrandr protocol.
+
+
+
+  
+   Destroy the weston_randr object which will not be used anymore.
+  
+
+
+
+  
+   The flag describes properties of an output mode.
+   Once clients get the mode change with these flags,
+   they should take the related action. For example,
+   del flag tells clients that mode is not used anymore.
+   Clients should delete it at once.
+  
+  
+  
+
+
+
+  
+   Select the nth mode
+  
+  
+  
+
+
+
+  
+   Fuzzy output mode setting
+  
+  
+  
+  
+  
+
+
+
+  
+   Set output transform and the values should
+   be 0-7. They means 0, 90, 180, 270, FLIP-0, FLIP-90,
+   FLIP-180, FLIP-270. These terms are from
+   the wl_output protocol.
+  
+  
+  
+
+
+
+  
+   Scale output.
+  
+  
+  
+
+
+
+  
+   The data type defines different movements of output.
+  
+  
+  
+  
+  
+
+
+
+  
+   Position output relative to target output.
+  
+  
+  
+  
+
+
+
+  
+   Delete the nth mode of output.
+  
+  
+  
+
+
+
+  
+   Fuzzy d

[PATCH V3 2/7] weston: Add the weston randr support in compositor.h

2014-04-07 Thread Quanxian Wang
1) Add weston_randr definition and randr_backend intreface.
2) Export functions used in compositor.c so that module wrandr
   could use them. For example, weston_output_transform_scale_init.
3) Support new_mode backend interface in output structure.

Signed-off-by: Quanxian Wang 
---
 src/compositor.h | 43 +++
 1 file changed, 43 insertions(+)

diff --git a/src/compositor.h b/src/compositor.h
index 22a485f..c728ffe 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -172,6 +172,17 @@ enum weston_mode_switch_op {
WESTON_MODE_SWITCH_RESTORE_NATIVE
 };
 
+struct wrandr {
+   struct weston_compositor *compositor;
+   struct wl_global *global;
+   struct wl_resource *resource;
+   struct wl_listener destroy_listener;
+   struct {
+   struct wl_list request_list;
+   struct wl_list randr_callback_list;
+   } pending;
+};
+
 struct weston_output {
uint32_t id;
char *name;
@@ -218,6 +229,33 @@ struct weston_output {
void (*destroy)(struct weston_output *output);
void (*assign_planes)(struct weston_output *output);
int (*switch_mode)(struct weston_output *output, struct weston_mode 
*mode);
+   struct weston_mode * (*new_timing)(struct weston_output *output,
+  uint32_t clock,
+  int hdisplay,
+  int hsync_start,
+  int hsync_end,
+  int htotal,
+  int vdisplay,
+  int vsync_start,
+  int vsync_end,
+  int vtotal,
+  int vscan,
+  uint32_t flags);
+
+   int (*compare_timing)(struct weston_mode *mode,
+ uint32_t clock,
+ int hdisplay,
+ int hsync_start,
+ int hsync_end,
+ int htotal,
+ int vdisplay,
+ int vsync_start,
+ int vsync_end,
+ int vtotal,
+ int vscan,
+ uint32_t flags);
+
+   struct weston_mode * (*new_mode)(int width, int height, int refresh);
 
/* backlight values are on 0-255 range, where higher is brighter */
int32_t backlight_current;
@@ -632,6 +670,7 @@ struct weston_compositor {
 
/* Raw keyboard processing (no libxkbcommon initialization or handling) 
*/
int use_xkbcommon;
+   struct wrandr *randr;
 };
 
 struct weston_buffer {
@@ -1356,6 +1395,10 @@ weston_surface_set_color(struct weston_surface *surface,
 void
 weston_surface_destroy(struct weston_surface *surface);
 
+void
+weston_output_transform_scale_init(struct weston_output *output,
+  uint32_t transform, uint32_t scale);
+
 int
 weston_output_switch_mode(struct weston_output *output, struct weston_mode 
*mode,
int32_t scale, enum weston_mode_switch_op op);
-- 
1.8.1.2

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


[PATCH V3 3/7] weston: Add enable-wrandr option and export common functions

2014-04-07 Thread Quanxian Wang
When starting weston with parameter --enable-wrandr,
it will automatically load wrandr.so module. This is
for QA testing and Admin configuration.

weston_output_transform_scale_init will be used by
weston randr module.

Signed-off-by: Quanxian Wang 
---
 src/compositor.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index c031edc..3e57651 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -88,7 +88,7 @@ sigchld_handler(int signal_number, void *data)
return 1;
 }
 
-static void
+WL_EXPORT void
 weston_output_transform_scale_init(struct weston_output *output,
   uint32_t transform, uint32_t scale);
 
@@ -3297,7 +3297,7 @@ weston_output_update_matrix(struct weston_output *output)
output->dirty = 0;
 }
 
-static void
+WL_EXPORT void
 weston_output_transform_scale_init(struct weston_output *output, uint32_t 
transform, uint32_t scale)
 {
output->transform = transform;
@@ -4140,6 +4140,7 @@ int main(int argc, char *argv[])
char *log = NULL;
int32_t idle_time = 300;
int32_t help = 0;
+   int32_t enable_wrandr = 0;
char *socket_name = "wayland-0";
int32_t version = 0;
struct weston_config *config;
@@ -4151,6 +4152,7 @@ int main(int argc, char *argv[])
{ WESTON_OPTION_STRING, "socket", 'S', &socket_name },
{ WESTON_OPTION_INTEGER, "idle-time", 'i', &idle_time },
{ WESTON_OPTION_STRING, "modules", 0, &option_modules },
+   { WESTON_OPTION_STRING, "enable-wrandr", 0, &enable_wrandr},
{ WESTON_OPTION_STRING, "log", 0, &log },
{ WESTON_OPTION_BOOLEAN, "help", 'h', &help },
{ WESTON_OPTION_BOOLEAN, "version", 0, &version },
@@ -4233,6 +4235,14 @@ int main(int argc, char *argv[])
ec->idle_time = idle_time;
ec->default_pointer_grab = NULL;
 
+   /* Add wrandr module */
+   if (enable_wrandr) {
+   if (!option_modules)
+   option_modules = strdup("wrandr.so");
+   else
+   option_modules = strcat(option_modules, ",wrandr.so");
+   }
+
setenv("WAYLAND_DISPLAY", socket_name, 1);
 
if (option_shell)
-- 
1.8.1.2

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


[PATCH V3 0/7] Add weston randr protocol

2014-04-07 Thread Quanxian Wang
Important Changes compared with V2:

1) Provide 2 methods to mode match for mode setting and mode delete.
   a) Exact mode number match
   Client selects the mode number according to query information.

   b) Fuzzy match for width, height and refresh
   Set: First matches, first takes effect.
   Delete: All matched, all deleted.

2) Support multiple outputs operations in one commit.
   With discussion, request structure is adjusted to support multiple outputs.
   One request will contain several output requests. Done event will be sent
   with output parameter (Null means for total, not null means for output).

3) Enhance new timing flags support
   Currently +hsync, -hsync, -vsync, +vsync, csync, +csync, -csync are 
supported.

4) Add Randr data type interface
   This interface will store all the data type used by other weston randr 
interfaces.
   The main reason is that the name of type is too long. I have to find a 
better way to use a
   human-readable type with short name.

5) Add above and below move action of output.
   Currently it is the empty because compositor's related functions are not 
ready.

6) Newmode request is provided for RDP backend, but it should be implemented in 
backend by RDP developer.
   Provide newmode option in apps(widthxheight or widthxheight@refresh)
   Provide newmode request in randr protocol to create a simple mode without 
detail timing information.

7) With suggestion from Bryce, provide a configure method to submit configure 
file
   But it is a empty function, parser is not ready for configure file.

8) Delete randr_start request and request id. 

9) The implemented code is ready for review.

TODO List:
1) Configure request is added to randr protocol. But the parser is not ready 
and needs more work.
2) Move above and below are not ready. But it depends on compositor development 
for that.

Hints:
This patches series has been tested. Until now it works fine.
If you want to have a try, you need two patches I send before.
1) [PATCH 0/3] Add wl_output name event
2) [PATCH] desktop-shell: Bug fix client apps because of output change
When you build weston, add option --enable-wrandr to enable building of weston 
randr module.
Like that: ./autogen.sh --enable-wrandr ...

Thanks

Regards

Quanxian Wang

General Information:

Note:
This protocol is not exposed to public. It is only for
QA testing and Admin configuration at the moment.

Objective:
The idea is from xrandr provided by xserver. *Dynamic* output mode
setting is the main objective of this protocol. Remember,
it is one shot operation. For example, if setting the mode,
just call one request weston_randr_set_mode and commit them.
Result will be returned in done event.

With this protocol, weston-wrandr application is developed to help 
implement randr protocol in command line just like xrandr command 
in xserver.

Weston randr protocol will provide interfaces to
1) Mode set of output (scale, transform, mode setting)
   For mode setting, three match methods are provided.

2) Position of output (currently support leftof, rightof)
   More need to be done, above, below and any positoion of output with (x,y).

3) New a custom mode
   This action should be bound with output.
   It acts like combination of newmode and addmode in xrandr.
   The reason is compositor does not have the mechanism to store all modes.

4) Delete mode

5) Provide a set of actions above in one commit 
   1-4 actions could be combined together in one commit.

6) Support multiple outputs operations with one commit.
   The result event will be sent with output parameter one by one.

USER CASES:

1. Query all mode info

Command: weston-wrandr --output HDMI3 -q
1)1440x900@59887(current)
2)1920x1200@59950
3)1680x1050@59883
...

2. weston-randr --output HDMI3 --mode 2 # which will set mode as 1920x1200
or weston-randr --output HDMI3 --mode 1920x1200@59950
or weston-randr --output HDMI3 --mode 1920x1200

3. weston-randr --output HDMI3 --delmode 1 # Delete mode
or weston-randr --output HDMI3 --delmode 1920x1200@59950
or weston-randr --output HDMI3 --delmode 1920x1200

4. weston-randr --output HDMI3 --transform 1 # rotate HDMI3 output 90 degree

5. weston-randr --output HDMI3 --leftof VGA1 # put HDMI3 output leftof VGA1

6. weston-randr --output HDMI3 --scale 2 # scale the output HDMI3

7. weston-randton-wrandr --output HDMI3 --newmode='1000x1900@1034'
   weston-randton-wrandr --output HDMI3 
--newtiming='1000,300,100,120,150,400,350,370,399,0,+hsync,-vsync'

Group operations example:
8. weston-randr --output HDMI3 --transform 3 --scale 2 --mode 2 -leftof VGA1
9. weston-randton-wrandr --output HDMI3 --transform 1 --scale 2 --mode 2 
--rightof VGA1 
--newtiming='1000,300,100,120,150,400,350,370,399,0,+hsync,-vsync'

The result format will be like that:
Command: weston-randton-wrandr --output HDMI3 --transform 1 --scale 2 --mode 2 
--rightof VGA1 --newtiming='1000,300,100,120,150,400,350,370,399,+hsync,-vsync'
Resu

[PATCH V3 7/7] Apps: Add weston-randr application

2014-04-07 Thread Quanxian Wang
Functions implemented in this application
1) Query output mode list
2) Update properties of output (transform, scale, mode setting)
3) Position of output (leftof and rightof are supported.)
4) Custom a mode for output.
5) Delete mode of output.
6) Combination of above 2-5 in one shot.

More details, please run "weston-wrandr -h"

Signed-off-by: Quanxian Wang 
---
 clients/Makefile.am |9 +
 clients/wrandr.c| 1213 +++
 2 files changed, 1222 insertions(+)
 create mode 100644 clients/wrandr.c

diff --git a/clients/Makefile.am b/clients/Makefile.am
index 4f8d4a6..757dba3 100644
--- a/clients/Makefile.am
+++ b/clients/Makefile.am
@@ -60,6 +60,7 @@ libexec_PROGRAMS =\
weston-desktop-shell\
weston-screenshooter\
$(screensaver)  \
+   weston-wrandr   \
weston-keyboard \
weston-simple-im
 
@@ -101,6 +102,12 @@ libtoytoolkit_la_LIBADD =  \
 weston_flower_SOURCES = flower.c
 weston_flower_LDADD = libtoytoolkit.la
 
+weston_wrandr_SOURCES =\
+   wrandr.c\
+   randr-protocol.c\
+   randr-client-protocol.h
+weston_wrandr_LDADD = libtoytoolkit.la $(CLIENT_LIBS)
+
 weston_screenshooter_SOURCES = \
screenshot.c\
screenshooter-protocol.c\
@@ -211,6 +218,8 @@ BUILT_SOURCES = \
text-cursor-position-protocol.c \
text-protocol.c \
text-client-protocol.h  \
+   randr-protocol.c\
+   randr-client-protocol.h \
input-method-protocol.c \
input-method-client-protocol.h  \
desktop-shell-client-protocol.h \
diff --git a/clients/wrandr.c b/clients/wrandr.c
new file mode 100644
index 000..57b7e0a
--- /dev/null
+++ b/clients/wrandr.c
@@ -0,0 +1,1213 @@
+/*
+ * Copyright © 2014 Quanxian Wang
+ * Copyright © 2014 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "randr-client-protocol.h"
+#include 
+#include 
+#include "../shared/config-parser.h"
+
+#define NAME_SIZE 64
+#define ARRAY_LENGTH(a) (sizeof(a) / sizeof(a)[0])
+
+enum randr_next_action {
+   RANDR_EXIT = 0,
+   RANDR_COMMIT = 1,
+};
+
+static int running = 1;
+
+struct output;
+
+struct timing {
+   int refresh;
+   uint32_t clock;
+   int hdisplay;
+   int hsync_start;
+   int hsync_end;
+   int htotal;
+   int vdisplay;
+   int vsync_start;
+   int vsync_end;
+   int vtotal;
+   int vscan;
+   uint32_t i_flags; /* mode information flags */
+};
+
+struct mode {
+   struct wl_list link;
+   int width;
+   int height;
+   int refresh;
+   uint32_t m_flags;
+};
+
+struct randr {
+   struct wl_display *display;
+   struct wl_registry *registry;
+   struct wl_compositor *compositor;
+   struct weston_randr *randr;
+   struct wl_list output_list;
+   struct wl_output *loutput;
+   struct wl_output *routput;
+   struct wl_output *aoutput;
+   struct wl_output *boutput;
+   struct output *output;
+   struct wl_output *wayland_output;
+   struct mode mode;
+   struct mode delmode;
+   struct mode *newmode;
+   struct timing *newtiming;
+   int mode_num;
+   int delmode_num;
+};
+
+struct output {
+   struct wl_list link;
+   

[PATCH V3 5/7] weston:Add the weston randr protocol implementation

2014-04-07 Thread Quanxian Wang
Signed-off-by: Quanxian Wang 
---
 module/Makefile.am|3 +
 module/wrandr/Makefile.am |   32 ++
 module/wrandr/wrandr.c| 1262 +
 3 files changed, 1297 insertions(+)
 create mode 100644 module/Makefile.am
 create mode 100644 module/wrandr/Makefile.am
 create mode 100644 module/wrandr/wrandr.c

diff --git a/module/Makefile.am b/module/Makefile.am
new file mode 100644
index 000..1a10e65
--- /dev/null
+++ b/module/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS =
+
+SUBDIRS += wrandr
diff --git a/module/wrandr/Makefile.am b/module/wrandr/Makefile.am
new file mode 100644
index 000..b0f2e6b
--- /dev/null
+++ b/module/wrandr/Makefile.am
@@ -0,0 +1,32 @@
+moduledir = $(libdir)/weston
+module_LTLIBRARIES = $(wrandr)
+
+AM_CPPFLAGS =  \
+   -I$(top_srcdir)/shared  \
+   -I$(top_srcdir)/src \
+   -I$(top_builddir)/src   \
+   -DDATADIR='"$(datadir)"'\
+   -DMODULEDIR='"$(moduledir)"'\
+   -DLIBEXECDIR='"$(libexecdir)"'  \
+   -DIN_WESTON
+
+if BUILD_WRANDR
+wrandr = wrandr.la
+wrandr_la_LDFLAGS = -module -avoid-version
+wrandr_la_LIBADD = $(COMPOSITOR_LIBS)  \
+   $(top_srcdir)/shared/libshared.la
+wrandr_la_CFLAGS = $(GCC_CFLAGS) $(COMPOSITOR_CFLAGS)
+wrandr_la_SOURCES =\
+   wrandr.c\
+   randr-protocol.c\
+   randr-server-protocol.h
+endif
+
+BUILT_SOURCES =\
+   randr-protocol.c\
+   randr-server-protocol.h
+
+CLEANFILES = $(BUILT_SOURCES)
+
+wayland_protocoldir = $(top_srcdir)/protocol
+include $(top_srcdir)/wayland-scanner.mk
diff --git a/module/wrandr/wrandr.c b/module/wrandr/wrandr.c
new file mode 100644
index 000..baa5628
--- /dev/null
+++ b/module/wrandr/wrandr.c
@@ -0,0 +1,1262 @@
+/*
+ * Copyright © 2014 Quanxian Wang
+ * Copyright © 2014 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "compositor.h"
+#include "randr-server-protocol.h"
+
+#define RESULT_MASK 0x3
+
+struct randr_mode {
+   int width;
+   int height;
+   int refresh;
+   time_t modi_time;
+};
+
+struct randr_timing {
+   uint32_t clock;
+   int hdisplay;
+   int hsync_start;
+   int hsync_end;
+   int htotal;
+   int vdisplay;
+   int vsync_start;
+   int vsync_end;
+   int vtotal;
+   int vscan;
+   uint32_t flags;
+};
+
+struct randr_request {
+   struct wl_list link;
+   struct wl_client *client;
+   struct wl_list output_request_list;
+   char *config_file;
+   int flags;
+};
+
+struct randr_output_request {
+   struct wl_list link;
+   struct weston_output *output;
+   int flags;
+
+   struct weston_output *loutput;
+   struct weston_output *routput;
+   struct weston_output *aoutput;
+   struct weston_output *boutput;
+
+   struct randr_mode *mode;
+
+   struct {
+   time_t modi_time;
+   int num;
+   } modenum;
+
+   int delmodenum;
+   struct randr_mode *delmode;
+
+   int scale;
+   int32_t transform;
+   struct randr_mode *newmode;
+   struct randr_timing *newtiming;
+};
+
+static void
+del_orequest(struct randr_output_request *orequest)
+{
+   wl_list_remove(&orequest->link);
+
+   if (orequest->mode)
+   free(orequest->mode);
+
+   if (orequest->delmode)
+   free(orequest->delmode);
+
+   if (orequest->newmode)
+   free(orequest-

[PATCH V3 4/7] Add new mode function in drm backend

2014-04-07 Thread Quanxian Wang
provide drm_output_new_mode interface to create new mode
from outsite instead of only from edid or configure.

Signed-off-by: Quanxian Wang 
---
 src/compositor-drm.c | 76 
 1 file changed, 76 insertions(+)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 154e15e..57e0585 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -1390,6 +1390,80 @@ drm_output_add_mode(struct drm_output *output, 
drmModeModeInfo *info)
 }
 
 static int
+drm_output_compare_timing(struct weston_mode *mode,
+ uint32_t clock,
+ int hdisplay,
+ int hsync_start,
+ int hsync_end,
+ int htotal,
+ int vdisplay,
+ int vsync_start,
+ int vsync_end,
+ int vtotal,
+ int vscan,
+ uint32_t flags)
+{
+   struct drm_mode *drmmode = (struct drm_mode *)mode;
+   drmModeModeInfo *modeinfo = &drmmode->mode_info;
+
+   return (modeinfo->clock == clock &&
+   modeinfo->hdisplay == hdisplay &&
+   modeinfo->hsync_start == hsync_start &&
+   modeinfo->hsync_end == hsync_end &&
+   modeinfo->htotal == htotal &&
+   modeinfo->vdisplay == vdisplay &&
+   modeinfo->vsync_start == vsync_start &&
+   modeinfo->vsync_end == vsync_end &&
+   modeinfo->vtotal == vtotal &&
+   modeinfo->vscan == vscan &&
+   modeinfo->flags == flags);
+}
+
+static struct weston_mode *
+drm_output_new_timing(struct weston_output *output,
+ uint32_t clock,
+ int hdisplay,
+ int hsync_start,
+ int hsync_end,
+ int htotal,
+ int vdisplay,
+ int vsync_start,
+ int vsync_end,
+ int vtotal,
+ int vscan,
+ uint32_t flags)
+{
+   drmModeModeInfo *modeinfo;
+   struct drm_mode *mode = NULL;
+
+   modeinfo = malloc(sizeof(*modeinfo));
+   if (modeinfo == NULL)
+   return NULL;
+   memset(modeinfo, 0x0, sizeof(*modeinfo));
+
+   modeinfo->type = DRM_MODE_TYPE_USERDEF;
+   modeinfo->hskew = 0;
+   modeinfo->vrefresh = 0;
+   modeinfo->hdisplay = hdisplay;
+   modeinfo->hsync_start = hsync_start;
+   modeinfo->hsync_end = hsync_end;
+   modeinfo->htotal = htotal;
+   modeinfo->vdisplay = vdisplay;
+   modeinfo->vsync_start = vsync_start;
+   modeinfo->vsync_end = vsync_end;
+   modeinfo->vtotal = vtotal;
+   modeinfo->vscan = vscan;
+   modeinfo->flags = flags;
+   modeinfo->clock = clock;
+
+   mode = drm_output_add_mode((struct drm_output *)output, modeinfo);
+   if (mode)
+   return &mode->base;
+   else
+   return NULL;
+}
+
+static int
 drm_subpixel_to_wayland(int drm_value)
 {
switch (drm_value) {
@@ -2046,6 +2120,8 @@ create_output_for_connector(struct drm_compositor *ec,
output->base.assign_planes = drm_assign_planes;
output->base.set_dpms = drm_set_dpms;
output->base.switch_mode = drm_output_switch_mode;
+   output->base.new_timing = drm_output_new_timing;
+   output->base.compare_timing = drm_output_compare_timing;
 
output->base.gamma_size = output->original_crtc->gamma_size;
output->base.set_gamma = drm_output_set_gamma;
-- 
1.8.1.2

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


[PATCH V2 8/8] Add request_id for request set to be distinguished from others

2014-03-24 Thread Quanxian Wang
For example, when you run start randr, will send 5 request,
while you go to 3th request, somebody operates on the same output
and commit his request, it will interrupt you. This will affect
your complete actions on the output.

In order to avoid this case, take request_id, client, output as the
unique id to generate a request set in compositor randr, others
will not do any operation on your private request structure.
After you commit, you only commit your request and without
submitting others requests.

If only one thread/process uses client and output, just take
request_id as 0 is enough. If more threads/process use the same
client and output at the same time, client app needs generate
a request id to be distinguished from others.

Signed-off-by: Quanxian Wang 
---
 clients/wrandr.c   | 35 ++-
 module/wrandr/wrandr.c | 31 +--
 protocol/randr.xml |  8 
 3 files changed, 55 insertions(+), 19 deletions(-)

diff --git a/clients/wrandr.c b/clients/wrandr.c
index 86e58a1..05cbd21 100644
--- a/clients/wrandr.c
+++ b/clients/wrandr.c
@@ -558,10 +558,12 @@ randr_printmode(struct output *output)
 
 static void
 randr_commit(struct randr *randr,
-struct wl_output *wayland_output)
+struct wl_output *wayland_output,
+uint32_t request_id)
 {
weston_randr_commit(randr->randr,
-   wayland_output);
+   wayland_output,
+   request_id);
 }
 
 static void
@@ -695,7 +697,8 @@ query_output(struct randr *randr,
 
 static int
 del_new_mode(struct randr *randr,
-struct argument *argument)
+struct argument *argument,
+uint32_t request_id)
 {
int ret = RANDR_EXIT;
 
@@ -703,6 +706,7 @@ del_new_mode(struct randr *randr,
if (argument->delmode) {
weston_randr_del_mode(randr->randr,
  randr->wayland_output,
+ request_id,
  randr->delmode->width,
  randr->delmode->height,
  randr->delmode->refresh);
@@ -713,6 +717,7 @@ del_new_mode(struct randr *randr,
if (argument->newmode) {
weston_randr_new_mode(randr->randr,
  randr->wayland_output,
+ request_id,
  randr->newmode.clock,
  randr->newmode.hdisplay,
  randr->newmode.hsync_start,
@@ -733,7 +738,8 @@ del_new_mode(struct randr *randr,
 
 static int
 output_modeset(struct randr *randr,
-  struct argument *argument)
+  struct argument *argument,
+  uint32_t request_id)
 {
int ret = RANDR_EXIT;
 
@@ -741,6 +747,7 @@ output_modeset(struct randr *randr,
if (randr->mode) {
weston_randr_set_mode(randr->randr,
  randr->wayland_output,
+ request_id,
  randr->mode->width,
  randr->mode->height,
  randr->mode->refresh);
@@ -750,6 +757,7 @@ output_modeset(struct randr *randr,
if (argument->scale != -1) {
weston_randr_set_scale(randr->randr,
   randr->wayland_output,
+  request_id,
   argument->scale);
ret = RANDR_COMMIT;
}
@@ -757,6 +765,7 @@ output_modeset(struct randr *randr,
if (argument->transform >= 0) {
weston_randr_set_transform(randr->randr,
   randr->wayland_output,
+  request_id,
   argument->transform);
ret = RANDR_COMMIT;
 
@@ -765,6 +774,7 @@ output_modeset(struct randr *randr,
if (randr->loutput) {
weston_randr_move(randr->randr,
  randr->wayland_output,
+ request_id,
  randr->loutput,
  WESTON_RANDR_MOVE_LEFTOF);
ret = RANDR_COMMIT;
@@ -773,6 +783,7 @@ output_modeset(struct randr *randr,
if (randr->routput) {
weston_randr_move(randr->randr,
  randr->wayland_output,
+ request_id,
  randr->routput,
  WESTON_RANDR_MOVE_RIGHTOF);
ret = RANDR_COMMIT;

[PATCH V2 7/8] Apps: Add weston-randr application

2014-03-24 Thread Quanxian Wang
Functions implemented in this application
1) Query output mode list
2) Update properties of output (transform, scale, mode setting)
3) Position of output (leftof and rightof are supported.)
4) Custom a mode for output.
5) Delete mode of output.
6) Combination of above 2-5 in one shot.

Note:
Does not support operations on multiple outputs in one time.

More details, please run "weston-wrandr -h"

Signed-off-by: Quanxian Wang 
---
 clients/Makefile.am |   9 +
 clients/wrandr.c| 862 
 2 files changed, 871 insertions(+)
 create mode 100644 clients/wrandr.c

diff --git a/clients/Makefile.am b/clients/Makefile.am
index 4f8d4a6..757dba3 100644
--- a/clients/Makefile.am
+++ b/clients/Makefile.am
@@ -60,6 +60,7 @@ libexec_PROGRAMS =\
weston-desktop-shell\
weston-screenshooter\
$(screensaver)  \
+   weston-wrandr   \
weston-keyboard \
weston-simple-im
 
@@ -101,6 +102,12 @@ libtoytoolkit_la_LIBADD =  \
 weston_flower_SOURCES = flower.c
 weston_flower_LDADD = libtoytoolkit.la
 
+weston_wrandr_SOURCES =\
+   wrandr.c\
+   randr-protocol.c\
+   randr-client-protocol.h
+weston_wrandr_LDADD = libtoytoolkit.la $(CLIENT_LIBS)
+
 weston_screenshooter_SOURCES = \
screenshot.c\
screenshooter-protocol.c\
@@ -211,6 +218,8 @@ BUILT_SOURCES = \
text-cursor-position-protocol.c \
text-protocol.c \
text-client-protocol.h  \
+   randr-protocol.c\
+   randr-client-protocol.h \
input-method-protocol.c \
input-method-client-protocol.h  \
desktop-shell-client-protocol.h \
diff --git a/clients/wrandr.c b/clients/wrandr.c
new file mode 100644
index 000..86e58a1
--- /dev/null
+++ b/clients/wrandr.c
@@ -0,0 +1,862 @@
+/*
+ * Copyright © 2014 Quanxian Wang
+ * Copyright © 2014 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "randr-client-protocol.h"
+#include 
+#include 
+#include "../shared/config-parser.h"
+
+#ifndef HZ
+#define HZ 1000
+#endif
+
+#define ARRAY_LENGTH(a) (sizeof(a) / sizeof(a)[0])
+
+enum randr_status {
+   RANDR_EXIT = 0,
+   RANDR_COMMIT = 1,
+};
+
+static int running = 1;
+
+struct output;
+struct mode;
+
+struct randr {
+   struct wl_display *display;
+   struct wl_registry *registry;
+   struct wl_compositor *compositor;
+   struct weston_randr *randr;
+   struct wl_list output_list;
+   struct wl_output *loutput;
+   struct wl_output *routput;
+   struct output *output;
+   struct wl_output *wayland_output;
+   struct mode *delmode;
+   struct mode *mode;
+   struct {
+   int clock;
+   int hdisplay;
+   int hsync_start;
+   int hsync_end;
+   int htotal;
+   int vdisplay;
+   int vsync_start;
+   int vsync_end;
+   int vtotal;
+   char hsync[128];
+   char vsync[128];
+   } newmode;
+   struct wrandr_callback *callback;
+};
+
+struct mode {
+   struct wl_list link;
+   int height;
+   int width;
+   int refresh;
+   uint32_t flags;
+};
+
+struct output {
+   struct wl_list link;
+   struct wl_list mode_list;
+  

[PATCH V2 1/8] wesston: Add weston randr protocol

2014-03-24 Thread Quanxian Wang
Weston protocol wrandr will provide interface to
1) Mode set of output (scale, transform, mode)
2) Position of output (currently support leftof, rightof)
3) New a custom mode
4) Delete mode

This protocol is not expose public. It is only for
QA testing and Admin configuration currently.

Signed-off-by: Quanxian Wang 
---
 protocol/Makefile.am |   1 +
 protocol/randr.xml   | 228 +++
 2 files changed, 229 insertions(+)
 create mode 100644 protocol/randr.xml

diff --git a/protocol/Makefile.am b/protocol/Makefile.am
index 5e331a7..df2e070 100644
--- a/protocol/Makefile.am
+++ b/protocol/Makefile.am
@@ -5,6 +5,7 @@ protocol_sources =  \
text.xml\
input-method.xml\
workspaces.xml  \
+   randr.xml   \
text-cursor-position.xml\
wayland-test.xml\
xdg-shell.xml   \
diff --git a/protocol/randr.xml b/protocol/randr.xml
new file mode 100644
index 000..07f83a4
--- /dev/null
+++ b/protocol/randr.xml
@@ -0,0 +1,228 @@
+
+
+
+  
+Copyright © 2014 Quanxian Wang
+Copyright © 2014 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.
+  
+
+  
+
+  The global interface exposing randr capabilities.
+  As a weston_randr, that provides the interfaces for apps to more 
operations
+  on output.
+
+  The aim of weston_randr is to get modes list, choose preferred mode,
+  layout the output including position, rotate, and en/disable.
+  The idea is from xrandr protocoal of xserver. It is very convenient for
+  weston/wayland user to operates on mode setting of output.
+
+
+
+  
+   Informs the server that the client will not be using this
+   protocol object anymore. This does not affect any other
+   objects, weston_randr objects included.
+  
+
+
+
+  
+   It is request notification when the next output randr commit
+   is coming and is useful for notifying client the result of
+   operations on the output. The randr request will take effect
+   on the next weston_randr.commit. The notification will only be
+   posted for one randr request unless requested again.
+  
+  
+  
+
+
+
+  
+   These flags describe properties of an output mode.
+   They are used in the flags bitfield of the mode event.
+   Here we take the last 28-32th bit as additional flags
+   which is different with original output mode.
+  
+  
+  
+
+
+
+  
+   Set the mode of output.
+  
+  
+  
+  
+  
+
+
+
+  
+   Set the transform of output, the valuable value should
+   be 0-7. This means 0, 90, 180, 270, FLIP-0, FLIP-90,
+   FLIP-180, FLIP-270. The values are referred from
+   the wl_output specification.
+  
+  
+  
+
+
+
+  
+   Set the scale of output.
+  
+  
+  
+
+
+
+  
+   The purpose is mainly to allow clients move target output to
+the position of source output.
+  
+  
+  
+
+
+
+  
+   Move the target output to be leftof/rightof source output.
+  
+  
+  
+  
+
+
+
+  
+   Set the mode of output.
+  
+  
+  
+  
+  
+
+
+
+  
+   Set the mode of output.
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+
+
+
+  
+   Commit all the previous output changes from the client.
+   Before the commit, the chagne request will be stored in wrandr 
interface.
+   

[PATCH V2 4/8] Add new mode function in drm backend

2014-03-24 Thread Quanxian Wang
Provide drm_output_new_mode interface to create new mode
from outsite instead of only from edid or configure.

Signed-off-by: Quanxian Wang 
---
 src/compositor-drm.c | 67 
 1 file changed, 67 insertions(+)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 154e15e..577d02f 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -1389,6 +1389,72 @@ drm_output_add_mode(struct drm_output *output, 
drmModeModeInfo *info)
return mode;
 }
 
+static struct weston_mode *
+drm_output_new_mode(struct weston_output *output,
+   int fclock,
+   int hdisplay,
+   int hsync_start,
+   int hsync_end,
+   int htotal,
+   int vdisplay,
+   int vsync_start,
+   int vsync_end,
+   int vtotal,
+   const char *hsync,
+   const char *vsync)
+{
+   drmModeModeInfo *modeinfo;
+   struct drm_mode *mode = NULL;
+
+   modeinfo = malloc(sizeof(*modeinfo));
+   if (modeinfo == NULL)
+   return NULL;
+   memset(modeinfo, 0x0, sizeof(*modeinfo));
+
+   modeinfo->type = DRM_MODE_TYPE_USERDEF;
+   modeinfo->hskew = 0;
+   modeinfo->vscan = 0;
+   modeinfo->vrefresh = 0;
+   modeinfo->flags = 0;
+
+   modeinfo->hdisplay = hdisplay;
+   modeinfo->hsync_start = hsync_start;
+   modeinfo->hsync_end = hsync_end;
+   modeinfo->htotal = htotal;
+   modeinfo->vdisplay = vdisplay;
+   modeinfo->vsync_start = vsync_start;
+   modeinfo->vsync_end = vsync_end;
+   modeinfo->vtotal = vtotal;
+
+   modeinfo->clock = fclock * 1000;
+
+   if (strcmp(hsync, "+hsync") == 0)
+   modeinfo->flags |= DRM_MODE_FLAG_PHSYNC;
+   else if (strcmp(hsync, "-hsync") == 0)
+   modeinfo->flags |= DRM_MODE_FLAG_NHSYNC;
+   else {
+   weston_log("Invalid hsync parameter %s.\n", hsync);
+   free(modeinfo);
+   return NULL;
+   }
+
+   if (strcmp(vsync, "+vsync") == 0)
+   modeinfo->flags |= DRM_MODE_FLAG_PVSYNC;
+   else if (strcmp(vsync, "-vsync") == 0)
+   modeinfo->flags |= DRM_MODE_FLAG_NVSYNC;
+   else {
+   weston_log("Invalid vsync parameter %s.\n", vsync);
+   free(modeinfo);
+   return NULL;
+   }
+
+   mode = drm_output_add_mode((struct drm_output *)output, modeinfo);
+   if (mode)
+   return &mode->base;
+   else
+   return NULL;
+}
+
 static int
 drm_subpixel_to_wayland(int drm_value)
 {
@@ -2046,6 +2112,7 @@ create_output_for_connector(struct drm_compositor *ec,
output->base.assign_planes = drm_assign_planes;
output->base.set_dpms = drm_set_dpms;
output->base.switch_mode = drm_output_switch_mode;
+   output->base.new_mode = drm_output_new_mode;
 
output->base.gamma_size = output->original_crtc->gamma_size;
output->base.set_gamma = drm_output_set_gamma;
-- 
1.8.1.2

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


[PATCH V2 6/8] weston: Add configure to support wrandr.

2014-03-24 Thread Quanxian Wang
Signed-off-by: Quanxian Wang 
---
 Makefile.am  | 5 +
 configure.ac | 8 
 2 files changed, 13 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index f22c542..254cde7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,11 +6,16 @@ if ENABLE_XWAYLAND
 xwayland_subdir = xwayland
 endif
 
+if BUILD_WRANDR
+randr_dir = module/wrandr
+endif
+
 SUBDIRS =  \
shared  \
src \
$(xwayland_subdir)  \
desktop-shell   \
+   $(randr_dir)\
clients \
data\
protocol\
diff --git a/configure.ac b/configure.ac
index cce1850..01e7429 100644
--- a/configure.ac
+++ b/configure.ac
@@ -409,6 +409,12 @@ if test "x$enable_dbus" != "xno"; then
 fi
 AM_CONDITIONAL(ENABLE_DBUS, test "x$enable_dbus" = "xyes")
 
+AC_ARG_ENABLE(wrandr, [  --disable-wrandr],, enable_wrandr=no)
+AM_CONDITIONAL(BUILD_WRANDR, test x$enable_wrandr = xyes)
+if test x$enable_wrandr = xyes; then
+  AC_DEFINE([BUILD_WRANDR], [1], [Build the wrandr])
+fi
+
 AC_ARG_ENABLE(wcap-tools, [  --disable-wcap-tools],, enable_wcap_tools=yes)
 AM_CONDITIONAL(BUILD_WCAP_TOOLS, test x$enable_wcap_tools = xyes)
 if test x$enable_wcap_tools = xyes; then
@@ -498,6 +504,8 @@ AC_CONFIG_FILES([Makefile
 src/Makefile
 xwayland/Makefile
 desktop-shell/Makefile
+module/Makefile
+module/wrandr/Makefile
 src/version.h
 src/weston.pc
 clients/Makefile
-- 
1.8.1.2

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


[PATCH V2 2/8] weston: Add the weston randr support in compositor.h

2014-03-24 Thread Quanxian Wang
1) Add weston_randr definition and randr_backend intreface.
2) Export functions used in compositor.c so that module wrandr
   could use them. For example, weston_output_transform_scale_init.
3) Support new_mode backend interface in output structure.

Signed-off-by: Quanxian Wang 
---
 src/compositor.h | 28 
 1 file changed, 28 insertions(+)

diff --git a/src/compositor.h b/src/compositor.h
index 22a485f..19d0f7b 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -172,6 +172,17 @@ enum weston_mode_switch_op {
WESTON_MODE_SWITCH_RESTORE_NATIVE
 };
 
+struct wrandr {
+   struct weston_compositor *compositor;
+   struct wl_global *global;
+   struct wl_resource *resource;
+   struct wl_listener destroy_listener;
+   struct {
+   struct wl_list request_list;
+   struct wl_list randr_callback_list;
+   } pending;
+};
+
 struct weston_output {
uint32_t id;
char *name;
@@ -218,6 +229,18 @@ struct weston_output {
void (*destroy)(struct weston_output *output);
void (*assign_planes)(struct weston_output *output);
int (*switch_mode)(struct weston_output *output, struct weston_mode 
*mode);
+   struct weston_mode * (*new_mode)(struct weston_output *output,
+int fclock,
+int hdisplay,
+int hsync_start,
+int hsync_end,
+int htotal,
+int vdisplay,
+int vsync_start,
+int vsync_end,
+int vtotal,
+const char *hsync,
+const char *vsync);
 
/* backlight values are on 0-255 range, where higher is brighter */
int32_t backlight_current;
@@ -632,6 +655,7 @@ struct weston_compositor {
 
/* Raw keyboard processing (no libxkbcommon initialization or handling) 
*/
int use_xkbcommon;
+   struct wrandr *randr;
 };
 
 struct weston_buffer {
@@ -1356,6 +1380,10 @@ weston_surface_set_color(struct weston_surface *surface,
 void
 weston_surface_destroy(struct weston_surface *surface);
 
+void
+weston_output_transform_scale_init(struct weston_output *output,
+  uint32_t transform, uint32_t scale);
+
 int
 weston_output_switch_mode(struct weston_output *output, struct weston_mode 
*mode,
int32_t scale, enum weston_mode_switch_op op);
-- 
1.8.1.2

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


[PATCH V2 5/8] weston:Add the weston randr protocol implementation

2014-03-24 Thread Quanxian Wang
Signed-off-by: Quanxian Wang 
---
 module/Makefile.am|   3 +
 module/wrandr/Makefile.am |  32 ++
 module/wrandr/wrandr.c| 792 ++
 3 files changed, 827 insertions(+)
 create mode 100644 module/Makefile.am
 create mode 100644 module/wrandr/Makefile.am
 create mode 100644 module/wrandr/wrandr.c

diff --git a/module/Makefile.am b/module/Makefile.am
new file mode 100644
index 000..1a10e65
--- /dev/null
+++ b/module/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS =
+
+SUBDIRS += wrandr
diff --git a/module/wrandr/Makefile.am b/module/wrandr/Makefile.am
new file mode 100644
index 000..b0f2e6b
--- /dev/null
+++ b/module/wrandr/Makefile.am
@@ -0,0 +1,32 @@
+moduledir = $(libdir)/weston
+module_LTLIBRARIES = $(wrandr)
+
+AM_CPPFLAGS =  \
+   -I$(top_srcdir)/shared  \
+   -I$(top_srcdir)/src \
+   -I$(top_builddir)/src   \
+   -DDATADIR='"$(datadir)"'\
+   -DMODULEDIR='"$(moduledir)"'\
+   -DLIBEXECDIR='"$(libexecdir)"'  \
+   -DIN_WESTON
+
+if BUILD_WRANDR
+wrandr = wrandr.la
+wrandr_la_LDFLAGS = -module -avoid-version
+wrandr_la_LIBADD = $(COMPOSITOR_LIBS)  \
+   $(top_srcdir)/shared/libshared.la
+wrandr_la_CFLAGS = $(GCC_CFLAGS) $(COMPOSITOR_CFLAGS)
+wrandr_la_SOURCES =\
+   wrandr.c\
+   randr-protocol.c\
+   randr-server-protocol.h
+endif
+
+BUILT_SOURCES =\
+   randr-protocol.c\
+   randr-server-protocol.h
+
+CLEANFILES = $(BUILT_SOURCES)
+
+wayland_protocoldir = $(top_srcdir)/protocol
+include $(top_srcdir)/wayland-scanner.mk
diff --git a/module/wrandr/wrandr.c b/module/wrandr/wrandr.c
new file mode 100644
index 000..b97d101
--- /dev/null
+++ b/module/wrandr/wrandr.c
@@ -0,0 +1,792 @@
+/*
+ * Copyright © 2012-2013 Collabora, Ltd.
+
+ * 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 
+#include 
+#include 
+#include 
+
+#include "compositor.h"
+#include "randr-server-protocol.h"
+
+#define RESULT_MASK 0x3
+
+struct randr_request {
+   struct wl_list link;
+   int flags;
+   struct wl_resource *callback;
+
+   /* Client and output compose unique id
+* of these request.*/
+   struct wl_client *client;
+   struct weston_output *output;
+
+   /* output move */
+   struct weston_output *loutput;
+   struct weston_output *routput;
+
+   /* mode set */
+   int height;
+   int width;
+   int refresh;
+
+   int scale;
+   int32_t transform;
+
+   struct {
+   int clock;
+   int hdisplay;
+   int hsync_start;
+   int hsync_end;
+   int htotal;
+   int vdisplay;
+   int vsync_start;
+   int vsync_end;
+   int vtotal;
+   char *hsync;
+   char *vsync;
+   } newmode;
+
+   struct {
+   int height;
+   int width;
+   int refresh;
+   } delmode;
+};
+
+static void
+del_request(struct randr_request *request)
+{
+   wl_list_remove(&request->link);
+
+   if (request->callback)
+   wl_resource_destroy(request->callback);
+
+   if (request->newmode.hsync)
+   free(request->newmode.hsync);
+
+   if (request->newmode.vsync)
+   free(request->newmode.vsync);
+
+   free(request);
+}
+
+static struct randr_request *
+get_request(struct wl_resource *resource,
+   struct wl_client *client,
+   struct weston_output *o

[PATCH V2 3/8] weston: Add enable-wrandr option in compositor to load wrandr.so

2014-03-24 Thread Quanxian Wang
When starting weston with parameter --enable-wrandr,
it will automatically load wrandr.so module. This is
for QA testing and Admin configuration.

Signed-off-by: Quanxian Wang 
---
 src/compositor.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index c031edc..0d37ab8 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -88,7 +88,7 @@ sigchld_handler(int signal_number, void *data)
return 1;
 }
 
-static void
+WL_EXPORT void
 weston_output_transform_scale_init(struct weston_output *output,
   uint32_t transform, uint32_t scale);
 
@@ -3297,7 +3297,7 @@ weston_output_update_matrix(struct weston_output *output)
output->dirty = 0;
 }
 
-static void
+WL_EXPORT void
 weston_output_transform_scale_init(struct weston_output *output, uint32_t 
transform, uint32_t scale)
 {
output->transform = transform;
@@ -4140,6 +4140,7 @@ int main(int argc, char *argv[])
char *log = NULL;
int32_t idle_time = 300;
int32_t help = 0;
+   int32_t enable_wrandr = 0;
char *socket_name = "wayland-0";
int32_t version = 0;
struct weston_config *config;
@@ -4151,6 +4152,7 @@ int main(int argc, char *argv[])
{ WESTON_OPTION_STRING, "socket", 'S', &socket_name },
{ WESTON_OPTION_INTEGER, "idle-time", 'i', &idle_time },
{ WESTON_OPTION_STRING, "modules", 0, &option_modules },
+   { WESTON_OPTION_STRING, "enable-wrandr", 0, &enable_wrandr},
{ WESTON_OPTION_STRING, "log", 0, &log },
{ WESTON_OPTION_BOOLEAN, "help", 'h', &help },
{ WESTON_OPTION_BOOLEAN, "version", 0, &version },
@@ -4233,6 +4235,14 @@ int main(int argc, char *argv[])
ec->idle_time = idle_time;
ec->default_pointer_grab = NULL;
 
+   /* Add wrandr modules */
+   if (enable_wrandr) {
+   if (!option_modules)
+   option_modules = strdup("wrandr.so");
+   else
+   option_modules = strcat(option_modules, ",wrandr.so");
+   }
+
setenv("WAYLAND_DISPLAY", socket_name, 1);
 
if (option_shell)
-- 
1.8.1.2

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


[PATCH V2 0/8] Add weston randr protocol

2014-03-24 Thread Quanxian Wang
Important Changes:

1) Adding randr_commit, randr_delmode, randr_newmode, randr_start
   randr_commit: will commit all requests in one time.
   randr_delmode: delete one mode
   randr_newmode: new one mode
   randr_start: as the randr beginning, it will generate a callback
interface to keep tunning the commit.
2) Add wrandr_callback interface for tunning. (randr_start)
3) Add new request structure in compositor to store all the requests.
   This structure is easy to control every client request set on one output.
4) Delete original design: one request has one default commit. It is not 
convenient
for group operations. Using commit request to submit all the request
in one time.
5) Take wrandr as a module
6) Add --enable-wrandr option to enable wrandr.
7) For 8th patch, it is still under consideration. It is only one choice.
   But I am not sure if other agrees with that. 

Hints:
This patches series has been tested. Until now it works fine.
If you want to have a try, you need two patches I send before.
1) [PATCH 0/3] Add wl_output name event
2) [PATCH] desktop-shell: Bug fix client apps because of output change
When you build weston, add option --enable-wrandr to enable the build of weston 
randr.

TODO:
>From Pq's comment, delete mode or set mode could not identify one unique mode 
>using
parameters width, height and refresh. Currently there is no method to get 
drmModeinfo
from compistor. (wl_output_send_mode only send width, height and refresh). 
Using new mode, user knows the parameter. However mode delete or mode set,
user could not get the detailed parameters from client. I will check with 
others to
get more idea to make sure how to implement that. Any comment is welcome.

By the way, currently we are focus on the protocol design. The implemented code 
is just 
a reference. However it will be helpful for reviewer to have a test and get the 
clear
idea of protocol. I like your comment to make this protocol stronger. Thanks.
Especially thanks to Pq. He gives me more valuable information. I will continue 
keep
tuning your comment and make the change.

Thanks for your support.

Regards

Quanxian Wang

General Information:

Objective:
Randr interface will not be exposed. It is only for weston-specific.
and it is only for testing and configuration. 

The idea is from xrandr provided by xserver. *Dynamic* mode
setting is the main objective of this protocol. Remember,
it is one shot operation. For example, if setting the mode,
just call one request wl_randr_set_mode. If you want to make
sure if it is successful, you need to keep tuning done event.
after all, it is a protocol communication.

With this protocol, weston-wrandr application is developped to help 
implement randr protocol in command line just like xrandr command 
in xserver.

Weston protocol wrandr will provide interface to
1) Mode set of output (scale, transform, mode)
2) Position of output (currently support leftof, rightof)
3) New a custom mode
4) Delete mode

Here are some use cases.

1. weston-randr -q # query all output mode info and disconnected output

HDMI3
1)1440x900@60 (current)
2)1920x1200@60
3)1680x1050@60
...

VGA1
1)1280x1024@60 (current)
2)1152x864@60
3)1024x768@60
...

2. weston-randr --output HDMI3 # query HDMI3 output mode info

HDMI3
1)1440x900@60 (current)
2)1920x1200@60
3)1680x1050@60

3. weston-randr --output HDMI3 --mode 2 # which will set mode as 1920x1200
or weston-randr --output HDMI3 --mode 1920x1200@60
or weston-randr --output HDMI3 --mode 1920x1200

4. weston-randr --output HDMI3 --transform 1 # rotate HDMI3 output 90 degree

5. weston-randr --output HDMI3 --leftof VGA1 # put HDMI3 output leftof VGA1

Group operations example:
5. weston-randr --output HDMI3 --transform 3 --scale 2 --mode 2 -leftof VGA1
6. weston-randton-wrandr --output HDMI3 --transform 1 --scale 2 --mode 2 
--rightof VGA1 --newmode='1000,300,100,120,150,400,350,370,399,+hsync,-vsync'
7. weston-randton-wrandr --output HDMI3 --delmode 3
or weston-randton-wrandr --output HDMI3 --delmode 1920x1200@60

Quanxian Wang (8):
  wesston: Add weston randr protocol
  weston: Add the weston randr support in compositor.h
  weston: Add enable-wrandr option in compositor to load wrandr.so
  Add new mode function in drm backend
  weston:Add the weston randr protocol implementation
  weston: Add configure to support wrandr.
  Apps: Add weston-randr application
  Add request_id for request set to be distinguished from others

 Makefile.am   |   5 +
 clients/Makefile.am   |   9 +
 clients/wrandr.c  | 879 ++
 configure.ac  |   8 +
 module/Makefile.am|   3 +
 module/wrandr/Makefile.am |  32 ++
 module/wrandr/wrandr.c| 803 ++
 protocol/Makefile.am  |   1 +
 protocol/randr.xml| 236 +
 src/compositor-drm.c  |  67 
 src/compositor.c  |  14 +-
 src/compositor.h   

[PATCH 3/3] shell: Add wl_output name event

2014-03-18 Thread Quanxian Wang
Signed-off-by: Quanxian Wang 
---
 clients/desktop-shell.c | 12 ++--
 clients/window.c| 12 ++--
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index a0c6b6d..9b15e3c 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -1172,6 +1172,13 @@ output_handle_mode(void *data,
 }
 
 static void
+output_handle_name(void *data,
+  struct wl_output *wl_output,
+  const char *name)
+{
+}
+
+static void
 output_handle_done(void *data,
struct wl_output *wl_output)
 {
@@ -1192,7 +1199,8 @@ static const struct wl_output_listener output_listener = {
output_handle_geometry,
output_handle_mode,
output_handle_done,
-   output_handle_scale
+   output_handle_scale,
+   output_handle_name
 };
 
 static void
@@ -1221,7 +1229,7 @@ create_output(struct desktop *desktop, uint32_t id)
return;
 
output->output =
-   display_bind(desktop->display, id, &wl_output_interface, 2);
+   display_bind(desktop->display, id, &wl_output_interface, 3);
output->server_output_id = id;
 
wl_output_add_listener(output->output, &output_listener, output);
diff --git a/clients/window.c b/clients/window.c
index c8287e2..c3e9633 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -4758,11 +4758,19 @@ display_handle_mode(void *data,
}
 }
 
+static void
+display_handle_name(void *data,
+   struct wl_output *wl_output,
+   const char *name)
+{
+}
+
 static const struct wl_output_listener output_listener = {
display_handle_geometry,
display_handle_mode,
display_handle_done,
-   display_handle_scale
+   display_handle_scale,
+   display_handle_name
 };
 
 static void
@@ -4774,7 +4782,7 @@ display_add_output(struct display *d, uint32_t id)
output->display = d;
output->scale = 1;
output->output =
-   wl_registry_bind(d->registry, id, &wl_output_interface, 2);
+   wl_registry_bind(d->registry, id, &wl_output_interface, 3);
output->server_output_id = id;
wl_list_insert(d->output_list.prev, &output->link);
 
-- 
1.8.1.2

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


[PATCH 0/3] Add wl_output name event

2014-03-18 Thread Quanxian Wang
This event contains a human-readable name of output.
It may be sent after binding the output object.
It is intended that the client can use this output name
as a parameter or display it in logs.

For example, in weston randr application, output name can
be a parameter in command line to stand for an output.

Quanxian Wang (3):
  wayland: Add wl_output name event
  shell: Add wl_output name event
  weston:Add wl_output name event

Wayland:
 protocol/wayland.xml | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Shell:
 clients/desktop-shell.c | 12 ++--
 clients/window.c| 12 ++--
 2 files changed, 20 insertions(+), 4 deletions(-)

Weston:
 src/compositor.c|  7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

-- 
1.8.1.2

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


[PATCH 2/3] weston:Add wl_output name event

2014-03-18 Thread Quanxian Wang
Signed-off-by: Quanxian Wang 
---
 src/compositor.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 40e4b11..78e2b48 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3115,7 +3115,7 @@ bind_output(struct wl_client *client,
struct wl_resource *resource;
 
resource = wl_resource_create(client, &wl_output_interface,
- MIN(version, 2), id);
+ MIN(version, 3), id);
if (resource == NULL) {
wl_client_post_no_memory(client);
return;
@@ -3144,6 +3144,9 @@ bind_output(struct wl_client *client,
mode->refresh);
}
 
+   if (version >= 3)
+   wl_output_send_name(resource, output->name);
+
if (version >= 2)
wl_output_send_done(resource);
 }
@@ -3400,7 +3403,7 @@ weston_output_init(struct weston_output *output, struct 
weston_compositor *c,
output->compositor->output_id_pool |= 1 << output->id;
 
output->global =
-   wl_global_create(c->wl_display, &wl_output_interface, 2,
+   wl_global_create(c->wl_display, &wl_output_interface, 3,
 output, bind_output);
wl_signal_emit(&c->output_created_signal, output);
 }
-- 
1.8.1.2

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


[PATCH 1/3] wayland: Add wl_output name event

2014-03-18 Thread Quanxian Wang
This event contains a human-readable name of output.
It may be sent after binding the output object.
It is intended that the client can use this output name
as a parameter or display it in logs.

For example, in weston randr application, output name can
be a parameter in command line to stand for an output.

Signed-off-by: Quanxian Wang 
---
 protocol/wayland.xml | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index d47ee62..881ebad 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -1618,7 +1618,7 @@
 
   
 
-  
+  
 
   An output describes part of the compositor geometry.  The
   compositor works in the 'compositor coordinate system' and an
@@ -1756,6 +1756,16 @@
   
   
 
+
+
+  
+   This event contains a human-readable name of output.
+   It may be sent after binding the output object.
+   It is intended that the client can use this output name
+   as a parameter or display it in logs.
+  
+  
+
   
 
   
-- 
1.8.1.2

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


[PATCH 3/3] shell: Add wl_output name event

2014-03-16 Thread Quanxian Wang
Signed-off-by: Quanxian Wang 
---
 clients/desktop-shell.c | 10 +-
 clients/window.c| 10 +-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index a0c6b6d..cefe936 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -1172,6 +1172,13 @@ output_handle_mode(void *data,
 }
 
 static void
+output_handle_name(void *data,
+  struct wl_output *wl_output,
+  const char *name)
+{
+}
+
+static void
 output_handle_done(void *data,
struct wl_output *wl_output)
 {
@@ -1192,7 +1199,8 @@ static const struct wl_output_listener output_listener = {
output_handle_geometry,
output_handle_mode,
output_handle_done,
-   output_handle_scale
+   output_handle_scale,
+   output_handle_name
 };
 
 static void
diff --git a/clients/window.c b/clients/window.c
index 3136a7d..4946b7a 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -4714,11 +4714,19 @@ display_handle_mode(void *data,
}
 }
 
+static void
+display_handle_name(void *data,
+   struct wl_output *wl_output,
+   const char *name)
+{
+}
+
 static const struct wl_output_listener output_listener = {
display_handle_geometry,
display_handle_mode,
display_handle_done,
-   display_handle_scale
+   display_handle_scale,
+   display_handle_name
 };
 
 static void
-- 
1.8.1.2

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


[PATCH 1/3] wayland: Add wl_output name event

2014-03-16 Thread Quanxian Wang
This event contains name of output. It may be sent after
binding the output object. It is intended that client could
input a character output name as a parameter or for log output.

Signed-off-by: Quanxian Wang 
---
 protocol/wayland.xml | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index d47ee62..0332e1a 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -1756,6 +1756,17 @@
   
   
 
+
+
+  
+   This event contains name of output. It may be sent after
+   binding the output object. It will provide useful name
+   for client when they generate the log for user.
+   Also it is intended that client could input a character
+   output name as a parameter or log.
+  
+  
+
   
 
   
-- 
1.8.1.2

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


[PATCH 0/3] Add wl_output name event

2014-03-16 Thread Quanxian Wang
This event contains name of output. It may be sent after
binding the output object. It is intended that client could
input a character output name as a parameter or for log output.

Mainly for client, provide a sensible character name
instead of object.

Quanxian Wang (3):
  wayland: Add wl_output name event
  shell: Add wl_output name event
  weston:Add wl_output name event

Wayland:
 protocol/wayland.xml | 11 +++
 1 file changed, 11 insertions(+)

Shell:
 clients/desktop-shell.c | 10 +-
 clients/window.c| 10 +-
 2 files changed, 18 insertions(+), 2 deletions(-)

Weston:
 src/compositor.c|  3 +++
 1 files changed, 3 insertions(+)

-- 
1.8.1.2

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


[PATCH 2/3] weston: Add wl_output name event

2014-03-16 Thread Quanxian Wang
Signed-off-by: Quanxian Wang 
---
 src/compositor.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/compositor.c b/src/compositor.c
index 98a4f6f..f82f771 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3044,6 +3044,9 @@ bind_output(struct wl_client *client,
mode->refresh);
}
 
+   if (version >= 3)
+   wl_output_send_name(resource, output->name);
+
if (version >= 2)
wl_output_send_done(resource);
 }
-- 
1.8.1.2

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


[PATCH] weston:Send done event with version 2 of wl_output

2014-03-13 Thread Quanxian Wang
With protocol of wl_output version 2, after the output change,
it should send done event to all clients bound with it.

Signed-off-by: Quanxian Wang 
---
 src/compositor.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/compositor.c b/src/compositor.c
index 7c29d51..98a4f6f 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3245,7 +3245,7 @@ weston_output_move(struct weston_output *output, int x, 
int y)
wl_signal_emit(&output->compositor->output_moved_signal, output);
 
/* Notify clients of the change for output position. */
-   wl_resource_for_each(resource, &output->resource_list)
+   wl_resource_for_each(resource, &output->resource_list) {
wl_output_send_geometry(resource,
output->x,
output->y,
@@ -3255,6 +3255,10 @@ weston_output_move(struct weston_output *output, int x, 
int y)
output->make,
output->model,
output->transform);
+
+   if (wl_resource_get_version(resource) >= 2)
+   wl_output_send_done(resource);
+   }
 }
 
 WL_EXPORT void
-- 
1.8.1.2

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


weston: weston randr protocol for testing and configuration

2014-03-13 Thread Quanxian Wang
Objective:
With discussion in mail list, currently we have an agreement. Randr interfaces 
will not be exposed public.
The objective will be only for testing and configuration. Thanks Pq, Jason, 
Jasper, Hardening, and other's comment.

Before sending the email, the function list below is implementedi(tested) 
except new mode creating(not testing).

Thanks for your support.

Updates:
1) Change wl_randr to weston_randr for weston-specific.
2) Unique operation issue
Given that one client has two more threads to do mode setting on the same 
output at the same time, how to identify what response (done event) is belong 
to one or another request when they want to get response? 

This is a design flaw in the first version of randr protocol.

The solution is to use the wayland/weston mechanism, every request will 
generate a resource which be used to send done event to the owner who start it. 
Owner could set the listener on that and keep tuning on the response event.

For example
In client:
randr_resource = 
wl_randr_set_transform(randr.randr,wayland_output,argument.transform);
wl_randr_add_listener(randr_resource, &randr_transform_listener, &randr);

In compositor:
randr_resource = wl_resource_create(client,&wl_randr_interface,1, action);
...
wl_randr_send_action_done(randr_resource, 1<
---
 protocol/randr.xml   | 166 +++
 1 files changed, 166 insertions(+)
 create mode 100644 protocol/randr.xml

diff --git a/protocol/randr.xml b/protocol/randr.xml
new file mode 100644
index 000..5c1d2d2
--- /dev/null
+++ b/protocol/randr.xml
@@ -0,0 +1,166 @@
+
+
+
+  
+    Copyright © 2014 Quanxian Wang
+Copyright © 2014 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.
+  
+
+  
+
+  The global interface exposing randr capabilities.
+  As a weston_randr, that provides the interfaces for apps to more 
operations
+  on output.
+
+  The aim of weston_randr is to get modes list, choose preferred mode,
+  layout the output including position, rotate, and en/disable.
+  The idea is from xrandr protocoal of xserver. It is very convenient for
+  weston/wayland user to operates on mode setting of output.
+
+
+
+  
+
+
+
+  
+   Informs the server that the client will not be using this
+   protocol object anymore. This does not affect any other
+   objects, weston_randr objects included.
+  
+
+
+
+  
+   Set the mode of output.
+  
+  
+  
+  
+  
+  
+
+
+
+  
+   Set the transform of output, the valuable value should
+   be 0-7. This means 0, 90, 180, 270, FLIP-0, FLIP-90,
+   FLIP-180, FLIP-270.
+  
+  
+  
+  
+
+
+
+  
+   Set the scale of output.
+  
+  
+  
+  
+
+
+
+  
+   The purpose is mainly to allow clients move target output to
+the position of source output.
+  
+  
+  
+
+
+
+  
+   Move the target output to be leftof/rightof source output.
+  
+  
+  
+  
+  
+
+
+
+  
+   Do multiple operations on target output. This allows uer
+   to do mode, scale , transform, move at the same time.
+   It will stop glitches for multiple actions
+   one by one when mode setting.
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+
+
+
+  
+   These flags show the status of every action excuted by randr.
+  
+  
+  
+  
+  
+
+
+
+  
+   Action result
+  
+  
+  
+  
+
+
+
+  
+   Notify the randr client that mode setting has been done.
+  
+  
+  
+
+  
+
-- 
1.8.1.2

___

[PATCH 2/3] weston:Add wl_output name event

2014-03-13 Thread Quanxian Wang
Signed-off-by: Quanxian Wang 
---
 src/compositor.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/compositor.c b/src/compositor.c
index 98a4f6f..8e8964b 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3045,6 +3045,9 @@ bind_output(struct wl_client *client,
}
 
if (version >= 2)
+   wl_output_send_name(resource, output->name);
+
+   if (version >= 2)
wl_output_send_done(resource);
 }
 
-- 
1.8.1.2

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


[PATCH 0/3] Add wl_output name event

2014-03-13 Thread Quanxian Wang
This event contains name of output. It may be sent after
binding the output object. It is intended that client could
input a character output name as a parameter or for log info.

Mainly for client, provide a sensible character name
instead of object.

Quanxian Wang (3):
  wayland: Add wl_output name event
  shell: Add wl_output name event
  weston:Add wl_output name event

Wayland:
 protocol/wayland.xml | 11 +++
 1 file changed, 11 insertions(+)

Shell:
 clients/desktop-shell.c | 10 +-
 clients/window.c| 10 +-
 2 files changed, 18 insertions(+), 2 deletions(-)

Weston:
 src/compositor.c|  3 +++
 1 files changed, 3 insertions(+)

-- 
1.8.1.2

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


[PATCH 3/3] shell: Add wl_output name event

2014-03-13 Thread Quanxian Wang
Signed-off-by: Quanxian Wang 
---
 clients/desktop-shell.c | 10 +-
 clients/window.c| 10 +-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index a0c6b6d..cefe936 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -1172,6 +1172,13 @@ output_handle_mode(void *data,
 }
 
 static void
+output_handle_name(void *data,
+  struct wl_output *wl_output,
+  const char *name)
+{
+}
+
+static void
 output_handle_done(void *data,
struct wl_output *wl_output)
 {
@@ -1192,7 +1199,8 @@ static const struct wl_output_listener output_listener = {
output_handle_geometry,
output_handle_mode,
output_handle_done,
-   output_handle_scale
+   output_handle_scale,
+   output_handle_name
 };
 
 static void
diff --git a/clients/window.c b/clients/window.c
index 3136a7d..4946b7a 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -4714,11 +4714,19 @@ display_handle_mode(void *data,
}
 }
 
+static void
+display_handle_name(void *data,
+   struct wl_output *wl_output,
+   const char *name)
+{
+}
+
 static const struct wl_output_listener output_listener = {
display_handle_geometry,
display_handle_mode,
display_handle_done,
-   display_handle_scale
+   display_handle_scale,
+   display_handle_name
 };
 
 static void
-- 
1.8.1.2

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


[PATCH 1/3] wayland: Add wl_output name event

2014-03-13 Thread Quanxian Wang
This event contains name of output. It may be sent after
binding the output object. It is intended that client could
input a character output name as a parameter or for log info.

Signed-off-by: Quanxian Wang 
---
 protocol/wayland.xml | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index d47ee62..c91a91a 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -1756,6 +1756,17 @@
   
   
 
+
+
+  
+   This event contains name of output. It may be sent after
+   binding the output object. It will provide sensible name
+   for client when they generate the log for user.
+   Also it is intended that client could input a character
+   output name as a parameter or log.
+  
+  
+
   
 
   
-- 
1.8.1.2

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


[PATCH] weston: Send done event with version 2 of wl_output

2014-03-13 Thread Quanxian Wang
With protocol of wl_output version 2, after the output change,
it should send done event to all clients bount with it.

Signed-off-by: Quanxian Wang 
---
 src/compositor.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/compositor.c b/src/compositor.c
index 7c29d51..98a4f6f 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3245,7 +3245,7 @@ weston_output_move(struct weston_output *output, int x, 
int y)
wl_signal_emit(&output->compositor->output_moved_signal, output);
 
/* Notify clients of the change for output position. */
-   wl_resource_for_each(resource, &output->resource_list)
+   wl_resource_for_each(resource, &output->resource_list) {
wl_output_send_geometry(resource,
output->x,
output->y,
@@ -3255,6 +3255,10 @@ weston_output_move(struct weston_output *output, int x, 
int y)
output->make,
output->model,
output->transform);
+
+   if (wl_resource_get_version(resource) >= 2)
+   wl_output_send_done(resource);
+   }
 }
 
 WL_EXPORT void
-- 
1.8.1.2

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


[PATCH] desktop-shell: Bug fix client apps because of output change

2014-03-11 Thread Quanxian Wang
1)
Width and height of Panel and Background depend on output's, therefore
they should be bound with output changes including mode, transform and
scale.

2)
Update the min_allocation before resize the panel and background
window. Add window_set_min_allocation function because it is invisible
outside window.c.

Signed-off-by: Quanxian Wang 
---
 clients/desktop-shell.c | 75 +++--
 clients/window.c|  7 +
 clients/window.h|  2 ++
 3 files changed, 81 insertions(+), 3 deletions(-)

diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index a0c6b6d..dc98ea1 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -103,6 +103,15 @@ struct output {
 
struct panel *panel;
struct background *background;
+   struct {
+   int height;
+   int width;
+   uint32_t refresh;
+   } mode;
+
+   uint32_t interface_version;
+   uint32_t transform;
+   uint32_t scale;
 };
 
 struct panel_launcher {
@@ -1145,6 +1154,39 @@ desktop_destroy_outputs(struct desktop *desktop)
 }
 
 static void
+update_output(struct output *output)
+{
+   struct panel *panel = output->panel;
+   struct background *background = output->background;
+   int width, height;
+
+   width = output->mode.width;
+   height = output->mode.height;
+
+   switch (output->transform) {
+   case WL_OUTPUT_TRANSFORM_90:
+   case WL_OUTPUT_TRANSFORM_270:
+   case WL_OUTPUT_TRANSFORM_FLIPPED_90:
+   case WL_OUTPUT_TRANSFORM_FLIPPED_270:
+   /* Swap width and height */
+   width = output->mode.height;
+   height = output->mode.width;
+   break;
+   default:
+   break;
+   }
+
+   width /= output->scale;
+   height /= output->scale;
+
+   window_set_min_allocation(panel->window, width, 32);
+   window_set_min_allocation(background->window, width, height);
+
+   window_schedule_resize(background->window, width, height);
+   window_schedule_resize(panel->window, width, 32);
+}
+
+static void
 output_handle_geometry(void *data,
struct wl_output *wl_output,
int x, int y,
@@ -1157,6 +1199,11 @@ output_handle_geometry(void *data,
 {
struct output *output = data;
 
+   output->transform = transform;
+
+   if (output->interface_version < 2)
+   update_output(output);
+
window_set_buffer_transform(output->panel->window, transform);
window_set_buffer_transform(output->background->window, transform);
 }
@@ -1169,12 +1216,28 @@ output_handle_mode(void *data,
   int height,
   int refresh)
 {
+   struct output *output = data;
+
+   if (flags & WL_OUTPUT_MODE_CURRENT) {
+   if (!output)
+   return;
+
+   output->mode.width = width;
+   output->mode.height = height;
+   output->mode.refresh = refresh;
+
+   if (output->interface_version < 2)
+   update_output(output);
+   }
 }
 
 static void
 output_handle_done(void *data,
struct wl_output *wl_output)
 {
+   struct output *output = data;
+
+   update_output(output);
 }
 
 static void
@@ -1184,6 +1247,8 @@ output_handle_scale(void *data,
 {
struct output *output = data;
 
+   output->scale  = scale;
+
window_set_buffer_scale(output->panel->window, scale);
window_set_buffer_scale(output->background->window, scale);
 }
@@ -1212,7 +1277,7 @@ output_init(struct output *output, struct desktop 
*desktop)
 }
 
 static void
-create_output(struct desktop *desktop, uint32_t id)
+create_output(struct desktop *desktop, uint32_t id, uint32_t version)
 {
struct output *output;
 
@@ -1220,9 +1285,13 @@ create_output(struct desktop *desktop, uint32_t id)
if (!output)
return;
 
+   output->interface_version = (version < 2) ? version : 2;
output->output =
-   display_bind(desktop->display, id, &wl_output_interface, 2);
+   display_bind(desktop->display, id,
+&wl_output_interface,
+output->interface_version);
output->server_output_id = id;
+   output->scale = 1;
 
wl_output_add_listener(output->output, &output_listener, output);
 
@@ -1247,7 +1316,7 @@ global_handler(struct display *display, uint32_t id,
  desktop->interface_version);
desktop_shell_add_listener(desktop->shell, &listener, desktop);
} else if (!strcmp(interface, "wl_output")) {
-   create_output(desktop, id);
+   create_output(desk

[PATCH] Bug fix client apps because of output change

2014-03-06 Thread Quanxian Wang
1)
Width and height of Panel and Background depend
on output's, therefore they should be bound
with output changes including mode, transform and scale.

2)
Update the min_allocation before resize the panel and
background window. Add window_set_min_allocation function
because it is invisible outside window.c.

Signed-off-by: Quanxian Wang 
---
 clients/desktop-shell.c | 80 +++--
 clients/window.c|  7 +
 clients/window.h|  2 ++
 3 files changed, 87 insertions(+), 2 deletions(-)

diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index a0c6b6d..4373448 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -103,6 +103,15 @@ struct output {
 
struct panel *panel;
struct background *background;
+   struct {
+   int height;
+   int width;
+   uint32_t refresh;
+   } mode;
+
+   uint32_t interface_version;
+   uint32_t transform;
+   uint32_t scale;
 };
 
 struct panel_launcher {
@@ -1145,6 +1154,45 @@ desktop_destroy_outputs(struct desktop *desktop)
 }
 
 static void
+update_output(struct output *output)
+{
+   struct panel *panel = output->panel;
+   struct background *background = output->background;
+   int width, height;
+
+   if (!output)
+   return;
+
+   width = output->mode.width;
+   height = output->mode.height;
+
+   switch (output->transform) {
+   case WL_OUTPUT_TRANSFORM_90:
+   case WL_OUTPUT_TRANSFORM_270:
+   case WL_OUTPUT_TRANSFORM_FLIPPED_90:
+   case WL_OUTPUT_TRANSFORM_FLIPPED_270:
+   /* Swap width and height */
+   width = output->mode.height;
+   height = output->mode.width;
+   break;
+   default:
+   break;
+   }
+
+   if (output->scale != 0) {
+   width /= output->scale;
+   height /= output->scale;
+   }
+
+   /* Set min_allocation of panel */
+   window_set_min_allocation(panel->window, width, 32);
+   window_set_min_allocation(background->window, width, height);
+
+   window_schedule_resize(background->window, width, height);
+   window_schedule_resize(panel->window, width, 32);
+}
+
+static void
 output_handle_geometry(void *data,
struct wl_output *wl_output,
int x, int y,
@@ -1157,6 +1205,11 @@ output_handle_geometry(void *data,
 {
struct output *output = data;
 
+   output->transform = transform;
+
+   if (output->interface_version < 2)
+   update_output(output);
+
window_set_buffer_transform(output->panel->window, transform);
window_set_buffer_transform(output->background->window, transform);
 }
@@ -1169,12 +1222,29 @@ output_handle_mode(void *data,
   int height,
   int refresh)
 {
+   struct output *output = data;
+
+   if (flags & WL_OUTPUT_MODE_CURRENT) {
+   if (!output)
+   return;
+
+   output->mode.width = width;
+   output->mode.height = height;
+   output->mode.refresh = refresh;
+
+   if (output->interface_version < 2)
+   update_output(output);
+   }
 }
 
 static void
 output_handle_done(void *data,
struct wl_output *wl_output)
 {
+   struct output *output = data;
+
+   if (output->interface_version >= 2)
+   update_output(output);
 }
 
 static void
@@ -1184,6 +1254,11 @@ output_handle_scale(void *data,
 {
struct output *output = data;
 
+   output->scale  = scale;
+
+   if (output->interface_version < 2)
+   update_output(output);
+
window_set_buffer_scale(output->panel->window, scale);
window_set_buffer_scale(output->background->window, scale);
 }
@@ -1212,7 +1287,7 @@ output_init(struct output *output, struct desktop 
*desktop)
 }
 
 static void
-create_output(struct desktop *desktop, uint32_t id)
+create_output(struct desktop *desktop, uint32_t id, uint32_t version)
 {
struct output *output;
 
@@ -1223,6 +1298,7 @@ create_output(struct desktop *desktop, uint32_t id)
output->output =
display_bind(desktop->display, id, &wl_output_interface, 2);
output->server_output_id = id;
+   output->interface_version = version;
 
wl_output_add_listener(output->output, &output_listener, output);
 
@@ -1247,7 +1323,7 @@ global_handler(struct display *display, uint32_t id,
  desktop->interface_version);
desktop_shell_add_listener(desktop->shell, &listener, desktop);
} else if (!strcmp(interface, "wl_output")) {
-   create_output(desktop, id);
+  

[PATCH] Bug fix client apps because of output change

2014-03-06 Thread Quanxian Wang
1)
Width and height of Panel and Background depend
on output's, therefore they should be bound
with output changes including mode, transform and scale.

2)
Update the min_allocation before resize the panel and
background window. Add window_set_min_allocation function
because it is invisible outside window.c.

Signed-off-by: Quanxian Wang 
---
 clients/desktop-shell.c | 70 +
 clients/window.c|  7 +
 clients/window.h|  2 ++
 3 files changed, 79 insertions(+)

diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index a0c6b6d..9ccba34 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -96,6 +96,12 @@ struct background {
uint32_t color;
 };
 
+struct mode {
+   int height;
+   int width;
+   uint32_t refresh;
+};
+
 struct output {
struct wl_output *output;
uint32_t server_output_id;
@@ -103,6 +109,9 @@ struct output {
 
struct panel *panel;
struct background *background;
+   struct mode *mode;
+   uint32_t transform;
+   uint32_t scale;
 };
 
 struct panel_launcher {
@@ -1128,6 +1137,10 @@ output_destroy(struct output *output)
 {
background_destroy(output->background);
panel_destroy(output->panel);
+
+   if (output->mode)
+   free(output->mode);
+
wl_output_destroy(output->output);
wl_list_remove(&output->link);
 
@@ -1145,6 +1158,44 @@ desktop_destroy_outputs(struct desktop *desktop)
 }
 
 static void
+update_output(struct output *output)
+{
+   struct panel *panel = output->panel;
+   struct background *background = output->background;
+   int width, height;
+
+   if (!output || !output->mode)
+   return;
+
+   width = output->mode->width;
+   height = output->mode->height;
+
+   switch (output->transform) {
+   case WL_OUTPUT_TRANSFORM_90:
+   case WL_OUTPUT_TRANSFORM_270:
+   case WL_OUTPUT_TRANSFORM_FLIPPED_90:
+   case WL_OUTPUT_TRANSFORM_FLIPPED_270:
+   /* Swap width and height */
+   width = output->mode->height;
+   height = output->mode->width;
+   break;
+   default:
+   break;
+   }
+
+   if (output->scale != 0) {
+   width /= output->scale;
+   height /= output->scale;
+   }
+
+   /* Set min_allocation of panel */
+   window_set_min_allocation(panel->window, width, 32);
+
+   window_schedule_resize(background->window, width, height);
+   window_schedule_resize(panel->window, width, 32);
+}
+
+static void
 output_handle_geometry(void *data,
struct wl_output *wl_output,
int x, int y,
@@ -1157,6 +1208,8 @@ output_handle_geometry(void *data,
 {
struct output *output = data;
 
+   output->transform = transform;
+   update_output(output);
window_set_buffer_transform(output->panel->window, transform);
window_set_buffer_transform(output->background->window, transform);
 }
@@ -1169,6 +1222,17 @@ output_handle_mode(void *data,
   int height,
   int refresh)
 {
+   struct output *output = data;
+
+   if (flags & WL_OUTPUT_MODE_CURRENT) {
+   if (!output && !output->mode)
+   return;
+
+   output->mode->width = width;
+   output->mode->height = height;
+   output->mode->refresh = refresh;
+   update_output(output);
+   }
 }
 
 static void
@@ -1184,6 +1248,8 @@ output_handle_scale(void *data,
 {
struct output *output = data;
 
+   output->scale  = scale;
+   update_output(output);
window_set_buffer_scale(output->panel->window, scale);
window_set_buffer_scale(output->background->window, scale);
 }
@@ -1206,6 +1272,10 @@ output_init(struct output *output, struct desktop 
*desktop)
output->output, surface);
 
output->background = background_create(desktop);
+   output->mode = (struct mode *)xzalloc(sizeof(*output->mode));
+   if (!output->mode)
+   fprintf(stderr, "No memory for mode allocation.\n");
+
surface = window_get_wl_surface(output->background->window);
desktop_shell_set_background(desktop->shell,
 output->output, surface);
diff --git a/clients/window.c b/clients/window.c
index c8287e2..6c01222 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -3839,6 +3839,13 @@ undo_resize(struct window *window)
 }
 
 void
+window_set_min_allocation(struct window *window, int width, int height)
+{
+   window->min_allocation.width = width;
+   window->min_allocation.height = height;
+}
+
+void
 window

[PATCH 5/6] Add weston-randr application

2014-02-26 Thread Quanxian Wang
Signed-off-by: Quanxian Wang 
Reviewed-by: Zhang, Xiong Y 
---
 clients/Makefile.am |   9 +
 clients/wrandr.c| 642 
 2 files changed, 651 insertions(+)
 create mode 100644 clients/wrandr.c

diff --git a/clients/Makefile.am b/clients/Makefile.am
index 4f8d4a6..cc509e9 100644
--- a/clients/Makefile.am
+++ b/clients/Makefile.am
@@ -60,6 +60,7 @@ libexec_PROGRAMS =\
weston-desktop-shell\
weston-screenshooter\
$(screensaver)  \
+   weston-wrandr   \
weston-keyboard \
weston-simple-im
 
@@ -101,6 +102,12 @@ libtoytoolkit_la_LIBADD =  \
 weston_flower_SOURCES = flower.c
 weston_flower_LDADD = libtoytoolkit.la
 
+weston_wrandr_SOURCES =\
+   wrandr.c\
+   randr-protocol.c\
+   randr-client-protocol.h
+weston_wrandr_LDADD = $(CLIENT_LIBS)
+
 weston_screenshooter_SOURCES = \
screenshot.c\
screenshooter-protocol.c\
@@ -211,6 +218,8 @@ BUILT_SOURCES = \
text-cursor-position-protocol.c \
text-protocol.c \
text-client-protocol.h  \
+   randr-protocol.c\
+   randr-client-protocol.h \
input-method-protocol.c \
input-method-client-protocol.h  \
desktop-shell-client-protocol.h \
diff --git a/clients/wrandr.c b/clients/wrandr.c
new file mode 100644
index 000..cc14a8d
--- /dev/null
+++ b/clients/wrandr.c
@@ -0,0 +1,642 @@
+/*
+ * Copyright © 2011 Benjamin Franzke
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "randr-client-protocol.h"
+#include 
+#include 
+
+#ifndef HZ
+#define HZ 1000
+#endif
+
+static int running = 1;
+
+struct randr {
+   struct wl_display *display;
+   struct wl_registry *registry;
+   struct wl_compositor *compositor;
+   struct wl_randr *randr;
+   struct wl_list output_list;
+};
+
+struct mode {
+   struct wl_list link;
+   int height;
+   int width;
+   int refresh;
+   uint32_t flags;
+};
+
+struct output {
+   struct wl_list link;
+   struct wl_list mode_list;
+   struct randr *randr;
+   struct wl_output *output;
+   char *name;
+   int x;
+   int y;
+   int physical_width;
+   int physical_height;
+   int subpixel;
+   char *make;
+   char *model;
+   int transform;
+   int scale;
+   int server_output_id;
+};
+
+struct argument {
+   char *output;
+   char *leftof;
+   char *rightof;
+   int query;
+   int mode;
+   int transform;
+};
+
+static void
+get_disoutputs(void *data,
+   struct wl_randr *wl_randr,
+   const char *output)
+{
+   running = 0;
+   printf("%s\n", output);
+}
+
+static void
+get_action_done(void *data,
+  struct wl_randr *wl_randr,
+  uint32_t flags,
+  int ret)
+{
+   char *result;
+   char *action;
+
+   switch (ret) {
+   case WL_RANDR_RESULT_FAIL:
+   result = "Fail";
+   break;
+   case WL_RANDR_RESULT_SUCCESS:
+   result = "Success";
+   break;
+   case WL_RANDR_RESULT_NOACT:
+   result = "Same as before, no action happens.";
+   break;
+   default:
+   result = "Success";
+ 

[PATCH 6/6] Change the size of Panel and Background after output's is changed

2014-02-26 Thread Quanxian Wang
Panel and background depend on the size of output,
So they have to be bound with output change including
mode, transform and scale.

Before resize the panel and background window,
their min_allocation has to be reset.
Add window_set_min_allocation function

Signed-off-by: Quanxian Wang 
Reviewed-by: Zhang, Xiong Y 
---
 clients/desktop-shell.c | 60 +
 clients/window.c|  7 ++
 clients/window.h|  2 ++
 3 files changed, 69 insertions(+)

diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index a0c6b6d..436e2e8 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -96,6 +96,12 @@ struct background {
uint32_t color;
 };
 
+struct mode {
+   int height;
+   int width;
+   uint32_t refresh;
+};
+
 struct output {
struct wl_output *output;
uint32_t server_output_id;
@@ -103,6 +109,8 @@ struct output {
 
struct panel *panel;
struct background *background;
+   struct mode *mode;
+   uint32_t transform;
 };
 
 struct panel_launcher {
@@ -1128,6 +1136,8 @@ output_destroy(struct output *output)
 {
background_destroy(output->background);
panel_destroy(output->panel);
+   if (output->mode)
+   free(output->mode);
wl_output_destroy(output->output);
wl_list_remove(&output->link);
 
@@ -1145,6 +1155,40 @@ desktop_destroy_outputs(struct desktop *desktop)
 }
 
 static void
+update_output(struct output *output, int transform)
+{
+   struct panel *panel = output->panel;
+   struct background *background = output->background;
+   int width, height;
+
+   output->transform = transform;
+
+   if (!output || !output->mode)
+   return;
+
+   width = output->mode->width;
+   height = output->mode->height;
+
+   switch (transform) {
+   case WL_OUTPUT_TRANSFORM_90:
+   case WL_OUTPUT_TRANSFORM_270:
+   case WL_OUTPUT_TRANSFORM_FLIPPED_90:
+   case WL_OUTPUT_TRANSFORM_FLIPPED_270:
+   /* Swap width and height */
+   width = output->mode->height;
+   height = output->mode->width;
+   break;
+   default:
+   break;
+   }
+
+   /* Set min_allocation of panel */
+   window_set_min_allocation(panel->window, width, 32);
+   window_schedule_resize(background->window, width, height);
+   window_schedule_resize(panel->window, width, 32);
+}
+
+static void
 output_handle_geometry(void *data,
struct wl_output *wl_output,
int x, int y,
@@ -1157,6 +1201,7 @@ output_handle_geometry(void *data,
 {
struct output *output = data;
 
+   update_output(output, transform);
window_set_buffer_transform(output->panel->window, transform);
window_set_buffer_transform(output->background->window, transform);
 }
@@ -1169,6 +1214,17 @@ output_handle_mode(void *data,
   int height,
   int refresh)
 {
+   struct output *output = data;
+
+   if (flags & WL_OUTPUT_MODE_CURRENT) {
+   if (!output && !output->mode)
+   return;
+
+   output->mode->width = width;
+   output->mode->height = height;
+   output->mode->refresh = refresh;
+   update_output(output, output->transform);
+   }
 }
 
 static void
@@ -1206,6 +1262,10 @@ output_init(struct output *output, struct desktop 
*desktop)
output->output, surface);
 
output->background = background_create(desktop);
+   output->mode = (struct mode *)xzalloc(sizeof(*output->mode));
+   if (!output->mode)
+   fprintf(stderr, "No memory for mode allocation.\n");
+
surface = window_get_wl_surface(output->background->window);
desktop_shell_set_background(desktop->shell,
 output->output, surface);
diff --git a/clients/window.c b/clients/window.c
index d8d79d0..5d797bb 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -3843,6 +3843,13 @@ undo_resize(struct window *window)
 }
 
 void
+window_set_min_allocation(struct window *window, int width, int height)
+{
+   window->min_allocation.width = width;
+   window->min_allocation.height = height;
+}
+
+void
 window_schedule_resize(struct window *window, int width, int height)
 {
/* We should probably get these numbers from the theme. */
diff --git a/clients/window.h b/clients/window.h
index dec133f..f66079c 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -336,6 +336,8 @@ void
 window_schedule_redraw(struct window *window);
 void
 window_schedule_resize(struct window *window, int width, int height);
+void
+window_set_min_allocation(struct window *window, in

[PATCH 1/6] Add weston randr protocol

2014-02-26 Thread Quanxian Wang
Weston protocol wrandr will provide interface to
1) set output mode
2) set output transform
3) move output to relative position
4) provide disconnected display port information

*Dynamic* mode setting is the main objective of this protocol.
Remember, it is one shot operation. For example, if setting the mode,
just call one request wl_randr_set_mode without any other operation.

Signed-off-by: Quanxian Wang 
Reviewed-by: Zhang, Xiong Y 
---
 protocol/Makefile.am |   1 +
 protocol/randr.xml   | 151 +++
 2 files changed, 152 insertions(+)
 create mode 100644 protocol/randr.xml

diff --git a/protocol/Makefile.am b/protocol/Makefile.am
index 5e331a7..df2e070 100644
--- a/protocol/Makefile.am
+++ b/protocol/Makefile.am
@@ -5,6 +5,7 @@ protocol_sources =  \
text.xml\
input-method.xml\
workspaces.xml  \
+   randr.xml   \
text-cursor-position.xml\
wayland-test.xml\
xdg-shell.xml   \
diff --git a/protocol/randr.xml b/protocol/randr.xml
new file mode 100644
index 000..f15e87a
--- /dev/null
+++ b/protocol/randr.xml
@@ -0,0 +1,151 @@
+
+
+
+  
+Copyright © 2012-2013 Collabora, Ltd.
+
+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.
+  
+
+  
+
+  The global interface exposing randr capabilities.
+  As a wl_randr, that provides the interfaces for apps to more operations
+  on output.
+
+  The aim of wl_randr is to get modes list, choose preferred mode,
+  layout the output including position, rotate, and en/disable.
+  The idea is from xrandr protocoal of xserver. It is very convenient for
+  weston/wayland user to operates on mode setting of output.
+
+
+
+  
+
+
+
+  
+   Informs the server that the client will not be using this
+   protocol object anymore. This does not affect any other
+   objects, wl_randr objects included.
+  
+
+
+
+  
+   set the mode of output
+  
+  
+  
+  
+  
+
+
+
+  
+   set the transform of output
+  
+  
+  
+
+
+
+  
+   The purpose is mainly to allow clients move target output to
+the position of source output.
+  
+  
+  
+
+
+
+  
+   position the target output leftof/rightof source output
+  
+  
+  
+  
+
+
+
+  
+   get the disconnected display port information
+  
+
+
+
+  
+   get the output name
+  
+  
+
+
+
+  
+   get output name of wl_output
+  
+  
+  
+
+
+
+  
+   Actions have been taken.
+  
+  
+  
+  
+
+
+
+  
+   Action result
+  
+  
+  
+  
+
+
+
+  
+   Notify the randr client mode set done.
+  
+  
+  
+
+
+
+  
+   Send back disconnected outputs information.
+  
+  
+
+  
+
+
-- 
1.8.1.2

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


[PATCH 2/6] Add weston_randr definition and randr_backend intreface

2014-02-26 Thread Quanxian Wang
Signed-off-by: Quanxian Wang 
Reviewed-by: Zhang, Xiong Y 
---
 src/compositor.h | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/src/compositor.h b/src/compositor.h
index 22a485f..6bc000f 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -172,6 +172,15 @@ enum weston_mode_switch_op {
WESTON_MODE_SWITCH_RESTORE_NATIVE
 };
 
+struct weston_randr {
+   struct weston_compositor *compositor;
+   struct wl_global *global;
+   struct wl_resource *resource;
+   void (*get_disoutputs)(struct weston_compositor *ec,
+  char *ret_str);
+   void (*destroy)(struct weston_compositor *ec);
+};
+
 struct weston_output {
uint32_t id;
char *name;
@@ -632,6 +641,7 @@ struct weston_compositor {
 
/* Raw keyboard processing (no libxkbcommon initialization or handling) 
*/
int use_xkbcommon;
+   struct weston_randr *randr;
 };
 
 struct weston_buffer {
@@ -1254,6 +1264,10 @@ weston_compositor_xkb_init(struct weston_compositor *ec,
 void
 weston_compositor_xkb_destroy(struct weston_compositor *ec);
 
+/* define randr interface */
+int
+weston_randr_init(struct weston_randr *randr, struct weston_compositor *ec);
+
 /* String literal of spaces, the same width as the timestamp. */
 #define STAMP_SPACE "   "
 
-- 
1.8.1.2

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


[PATCH 0/6] Add weston randr protocol

2014-02-26 Thread Quanxian Wang
These patches will provide weston randr protocol,
its implementation and randr application.

The idea is from xrandr provided by xserver. *Dynamic* mode
setting is the main objective of this protocol. Remember,
it is one shot operation. For example, if setting the mode,
just call one request wl_randr_set_mode without any other operation.

With this protocol, weston-wrandr application is developped to help 
user implement randr protocol in command line just like xrandr command 
in xserver.

For wayland customer, this application could *DYNAMICALLY*
do mode setting in command line.

For wayland application developer, weston randr protocol provide
a external interface to *DYNAMICALLY* do mode setting instead of
static configuring weston at the very beginning.

Weston protocol wrandr will provide interface to 
1) set output mode
2) set output transform
3) move output to relative position
4) provide disconnected output information

Currently randr has more functions to be defined and implemented.
Some other functions are planned. But at first we need support.
If this protocol is accepted, we could have the chance moving on.

The advantage is
randr architecture have been defined at this commit. New function will
be very easy to be added in the protocol.

One note:
Currently wl_output doesn't provide wl_output_send_name function,
I have to implemented it in randr protocol. Actually it will be very
easily implemented in wl_output interface. If this commit series is
accepted, I will provide the patch to add wl_output_send_name to make
issue simply resolved instead of in randr protocol.
'

Here are some test cases.

1. weston-randr -q # query all output mode info and disconnected output

HDMI3
1)1440x900@60 (current)
2)1920x1200@60
3)1680x1050@60
...

VGA1
1)1280x1024@60 (current)
2)1152x864@60
3)1024x768@60
...

HDMI1 disconnected
HDMI2 disconnected
DP1 disconnected
DP2 disconnected
...

2. weston-randr --output HDMI3 # query HDMI3 output mode info

HDMI3
1)1440x900@60 (current)
2)1920x1200@60
3)1680x1050@60

3. weston-randr --output HDMI3 -m 2 # which will set mode as 1920x1200

4. weston-randr --output HDMI3 -R 1 # rotate HDMI3 output 90 degree

5. weston-randr --output HDMI3 -leftof VGA1 # put HDMI3 output leftof VGA1

6. weston-randr --output HDMI3 -rightof VGA1 # put HDMI3 output rightof VGA1

Quanxian Wang (6):
  Add weston randr protocol
  Add weston_randr definition and randr_backend intreface
  Add the detailed implementation of randr protocol
  Initialize the randr interface in drm backend
  Add weston-randr application
  Change the size of Panel and Background after output's is changed

 clients/Makefile.am |   9 +
 clients/desktop-shell.c |  60 +
 clients/window.c|   7 +
 clients/window.h|   2 +
 clients/wrandr.c| 642 
 protocol/Makefile.am|   1 +
 protocol/randr.xml  | 151 
 src/Makefile.am |   4 +
 src/compositor-drm.c|  67 +
 src/compositor.c| 466 +++
 src/compositor.h|  14 ++
 11 files changed, 1376 insertions(+), 47 deletions(-)
 create mode 100644 clients/wrandr.c
 create mode 100644 protocol/randr.xml

-- 
1.8.1.2

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


[PATCH 4/6] Initialize the randr interface in drm backend

2014-02-26 Thread Quanxian Wang
Function get_disoutputs is added in order to provide
display port information embedded on the machine.

Signed-off-by: Quanxian Wang 
Reviewed-by: Zhang, Xiong Y 
---
 src/compositor-drm.c | 67 
 1 file changed, 67 insertions(+)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 154e15e..1f43071 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -,6 +,54 @@ create_outputs(struct drm_compositor *ec, uint32_t 
option_connector,
 }
 
 static void
+get_disoutputs(struct weston_compositor *ec,
+   char *ret_str)
+{
+   struct drm_compositor *drm_ec =
+   container_of(ec, struct drm_compositor, base);
+   drmModeConnector *connector;
+   drmModeRes *resources;
+   char name[128];
+   const char *type_name;
+   int i;
+
+   if (!ret_str)
+   return;
+   memset(ret_str, 0x0, strlen(ret_str));
+
+   resources = drmModeGetResources(drm_ec->drm.fd);
+   if (!resources) {
+   weston_log("drmModeGetResources failed\n");
+   return;
+   }
+
+   /* Collect disconnected connects */
+   for (i = 0; i < resources->count_connectors; i++) {
+   int connector_id = resources->connectors[i];
+
+   connector = drmModeGetConnector(drm_ec->drm.fd, connector_id);
+   if (connector == NULL)
+   continue;
+
+   if (connector->connection != DRM_MODE_CONNECTED) {
+   type_name =
+   connector_type_names[connector->connector_type];
+   if (connector->connector_type >=
+   ARRAY_LENGTH(connector_type_names))
+   type_name = "UNKNOWN";
+
+   snprintf(name, 128, "%s%d disconnected.\n",
+type_name, connector->connector_type_id);
+   strcat(ret_str, name);
+
+   drmModeFreeConnector(connector);
+   }
+   }
+
+   return;
+}
+
+static void
 update_outputs(struct drm_compositor *ec, struct udev_device *drm_device)
 {
drmModeConnector *connector;
@@ -2652,6 +2700,22 @@ renderer_switch_binding(struct weston_seat *seat, 
uint32_t time, uint32_t key,
switch_to_gl_renderer(c);
 }
 
+static void
+randr_init(struct weston_compositor *ec)
+{
+   /* Initialize randr */
+   ec->randr = zalloc(sizeof *(ec->randr));
+   if (!ec->randr)
+   return;
+
+   ec->randr->get_disoutputs = get_disoutputs;
+
+   if (weston_randr_init(ec->randr, ec) < 0) {
+   free(ec->randr);
+   weston_log("Failed to initialize randr interface.\n");
+   }
+}
+
 static struct weston_compositor *
 drm_compositor_create(struct wl_display *display,
  struct drm_parameters *param,
@@ -2769,6 +2833,9 @@ drm_compositor_create(struct wl_display *display,
goto err_sprite;
}
 
+   /* Initialize randr */
+   randr_init(&ec->base);
+
loop = wl_display_get_event_loop(ec->base.wl_display);
ec->drm_source =
wl_event_loop_add_fd(loop, ec->drm.fd,
-- 
1.8.1.2

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


[PATCH 3/6] Add the detailed implementation of randr protocol

2014-02-26 Thread Quanxian Wang
1) add the initialization of randr protocol
2) add the randr request implementation

Signed-off-by: Quanxian Wang 
Reviewed-by: Zhang, Xiong Y 
---
 src/Makefile.am  |   4 +
 src/compositor.c | 466 +--
 2 files changed, 423 insertions(+), 47 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 446639c..5a19a7f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -34,6 +34,8 @@ weston_SOURCES =  \
text-server-protocol.h  \
input-method-protocol.c \
input-method-server-protocol.h  \
+   randr-protocol.c\
+   randr-server-protocol.h \
workspaces-protocol.c   \
workspaces-server-protocol.h\
scaler-protocol.c   \
@@ -321,6 +323,8 @@ BUILT_SOURCES = \
text-server-protocol.h  \
input-method-protocol.c \
input-method-server-protocol.h  \
+   randr-protocol.c\
+   randr-server-protocol.h \
workspaces-server-protocol.h\
workspaces-protocol.c   \
scaler-server-protocol.h\
diff --git a/src/compositor.c b/src/compositor.c
index 40e4b11..3306c99 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -54,6 +54,7 @@
 
 #include "compositor.h"
 #include "scaler-server-protocol.h"
+#include "randr-server-protocol.h"
 #include "../shared/os-compatibility.h"
 #include "git-version.h"
 #include "version.h"
@@ -95,12 +96,90 @@ weston_output_transform_scale_init(struct weston_output 
*output,
 static void
 weston_compositor_build_view_list(struct weston_compositor *compositor);
 
+static void
+adjust_pointer(struct weston_output *output,
+  pixman_region32_t *old_output_region)
+{
+   struct weston_seat *seat;
+   int32_t x, y;
+   struct weston_pointer *pointer;
+
+   /* If a pointer falls outside the outputs new geometry, move it to its
+* lower-right corner. */
+   wl_list_for_each(seat, &output->compositor->seat_list, link) {
+   pointer = seat->pointer;
+   if (!pointer)
+   continue;
+
+   x = wl_fixed_to_int(pointer->x);
+   y = wl_fixed_to_int(pointer->y);
+
+   if (!pixman_region32_contains_point(old_output_region,
+   x, y, NULL) ||
+   pixman_region32_contains_point(&output->region,
+  x, y, NULL))
+   continue;
+
+   if (x >= output->x + output->width)
+   x = output->x + output->width - 1;
+   if (y >= output->y + output->height)
+   y = output->y + output->height - 1;
+
+   pointer->x = wl_fixed_from_int(x);
+   pointer->y = wl_fixed_from_int(y);
+   }
+}
+
+static void
+notify_change(struct weston_output *output,
+ struct weston_mode *mode,
+ int mode_changed,
+ int scale_changed,
+ int transform_changed,
+ int32_t scale)
+{
+   struct wl_resource *resource;
+
+   if (!mode_changed && !scale_changed &&
+   !transform_changed)
+   return;
+
+   /* Notify clients of the changes */
+   wl_resource_for_each(resource,
+&output->resource_list) {
+   if (mode_changed) {
+   wl_output_send_mode(resource,
+   mode->flags |
+   WL_OUTPUT_MODE_CURRENT,
+   mode->width,
+   mode->height,
+   mode->refresh);
+   }
+
+   if (transform_changed) {
+   wl_output_send_geometry(resource,
+   output->x,
+   output->y,
+   output->mm_width,
+   output->mm_height,
+   output->subpixel,
+   output->make,
+   output->model,
+   output->transform);
+   }
+
+   if (scale_changed)
+   wl_output_send_scale(resource, scale);
+
+   if (wl_reso