Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support client focus proxy window #35

Merged
merged 1 commit into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions clients/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,18 @@ if get_option('shell-ivi')
)
env_modmap += 'weston-ivi-shell-user-interface=@0@;'.format(exe_shell_ivi_ui.full_path())
endif


if get_option('shell-rdprail')
exe_shell_rdprail = executable(
'weston-rdprail-shell',
'rdprail-shell.c',
weston_rdprail_shell_client_protocol_h,
weston_rdprail_shell_protocol_c,
include_directories: common_inc,
dependencies: dep_toytoolkit,
install: true,
install_dir: get_option('libexecdir')
)
env_modmap += 'weston-rdprail-shell=@0@;'.format(exe_shell_rdprail.full_path())
endif
182 changes: 182 additions & 0 deletions clients/rdprail-shell.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
/*
* Copyright © 2011 Kristian Høgsberg
* Copyright © 2011 Collabora, Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/

#include "config.h"

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <math.h>
#include <cairo.h>
#include <sys/wait.h>
#include <linux/input.h>
#include <libgen.h>
#include <ctype.h>
#include <time.h>
#include <assert.h>

#include <wayland-client.h>
#include "window.h"
#include "shared/cairo-util.h"
#include <libweston/config-parser.h>
#include "shared/helpers.h"
#include "shared/xalloc.h"
#include <libweston/zalloc.h>
#include "shared/file-util.h"

#include "weston-rdprail-shell-client-protocol.h"

struct focus_proxy_window {
struct window *window;
struct widget *widget;
};

struct desktop {
struct display *display;
struct weston_rdprail_shell *shell;

struct focus_proxy_window *focus_proxy_window;
};

static void
focus_proxy_window_redraw_handler(struct widget *widget, void *data)
{
}

static void
focus_proxy_window_resize_handler(struct widget *widget,
int32_t width, int32_t height, void *data)
{
}

static struct focus_proxy_window *
focus_proxy_create(struct desktop *desktop)
{
struct focus_proxy_window *focus_proxy_window = NULL;

focus_proxy_window = xzalloc(sizeof *focus_proxy_window);
if (!focus_proxy_window)
goto error_exit;

focus_proxy_window->window = window_create(desktop->display);
if (!focus_proxy_window->window)
goto error_exit;

focus_proxy_window->widget = window_add_widget(focus_proxy_window->window, focus_proxy_window);
if (!focus_proxy_window->widget)
goto error_exit;

widget_set_allocation(focus_proxy_window->widget, 0, 0, 0, 0);

window_set_title(focus_proxy_window->window, "rdprail-shell focus proxy window");
window_set_user_data(focus_proxy_window->window, focus_proxy_window);

widget_set_redraw_handler(focus_proxy_window->widget, focus_proxy_window_redraw_handler);
widget_set_resize_handler(focus_proxy_window->widget, focus_proxy_window_resize_handler);

struct wl_surface *s = window_get_wl_surface(focus_proxy_window->window);
weston_rdprail_shell_set_focus_proxy(desktop->shell, s);

return focus_proxy_window;

error_exit:
if (focus_proxy_window && focus_proxy_window->widget)
widget_destroy(focus_proxy_window->widget);

if (focus_proxy_window && focus_proxy_window->window)
window_destroy(focus_proxy_window->window);

if (focus_proxy_window)
free(focus_proxy_window);

return NULL;
}

static void
focus_proxy_destroy(struct focus_proxy_window* focus_proxy_window)
{
widget_destroy(focus_proxy_window->widget);
window_destroy(focus_proxy_window->window);

free(focus_proxy_window);
}

static void
global_handler(struct display *display, uint32_t id,
const char *interface, uint32_t version, void *data)
{
struct desktop *desktop = data;

if (!strcmp(interface, "weston_rdprail_shell")) {
desktop->shell = display_bind(desktop->display,
id,
&weston_rdprail_shell_interface,
1);
}
}

static void
sigchild_handler(int s)
{
int status;
pid_t pid;

while (pid = waitpid(-1, &status, WNOHANG), pid > 0)
fprintf(stderr, "child %d exited\n", pid);
}

int main(int argc, char *argv[])
{
struct desktop desktop = { 0 };

desktop.display = display_create(&argc, argv);
if (desktop.display == NULL) {
fprintf(stderr, "failed to create display: %s\n",
strerror(errno));
return -1;
}

display_set_user_data(desktop.display, &desktop);
display_set_global_handler(desktop.display, global_handler);

desktop.focus_proxy_window = focus_proxy_create(&desktop);
if (desktop.focus_proxy_window == NULL) {
fprintf(stderr, "failed to create focus proxy window.\n");
return -1;
}

signal(SIGCHLD, sigchild_handler);

display_run(desktop.display);

focus_proxy_destroy(desktop.focus_proxy_window);
weston_rdprail_shell_destroy(desktop.shell);
display_destroy(desktop.display);

return 0;
}
1 change: 1 addition & 0 deletions protocol/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ generated_protocols = [
[ 'viewporter', 'stable' ],
[ 'weston-debug', 'internal' ],
[ 'weston-desktop-shell', 'internal' ],
[ 'weston-rdprail-shell', 'internal' ],
[ 'weston-screenshooter', 'internal' ],
[ 'weston-content-protection', 'internal' ],
[ 'weston-test', 'internal' ],
Expand Down
35 changes: 35 additions & 0 deletions protocol/weston-rdprail-shell.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<protocol name="weston_rdprail">

<interface name="weston_rdprail_shell" version="1">
<description summary="RDPRAIL-shell interface">
This interface defines RDP-RAIL shell specific methods.
</description>

<request name="set_focus_proxy">
<arg name="surface" type="object" interface="wl_surface"/>
</request>

<enum name="cursor">
<entry name="none" value="0"/>

<entry name="resize_top" value="1"/>
<entry name="resize_bottom" value="2"/>

<entry name="arrow" value="3"/>

<entry name="resize_left" value="4"/>
<entry name="resize_top_left" value="5"/>
<entry name="resize_bottom_left" value="6"/>

<entry name="move" value="7"/>

<entry name="resize_right" value="8"/>
<entry name="resize_top_right" value="9"/>
<entry name="resize_bottom_right" value="10"/>

<entry name="busy" value="11"/>
</enum>

</interface>

</protocol>
4 changes: 2 additions & 2 deletions rdprail-shell/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ if get_option('shell-rdprail')
'input-panel.c',
'app-list.c',
'img-load.c',
weston_desktop_shell_server_protocol_h,
weston_desktop_shell_protocol_c,
weston_rdprail_shell_server_protocol_h,
weston_rdprail_shell_protocol_c,
input_method_unstable_v1_server_protocol_h,
input_method_unstable_v1_protocol_c,
]
Expand Down
Loading