neuswc

patched neuswc library (tracked)
git clone https://git.daat.foo/neuswc.git
Log | Files | Refs | README | LICENSE

kde_decoration.c (3273B)


      1 /* swc: libswc/kde_decoration.c
      2  *
      3  * Copyright (c) 2020 Michael Forney
      4  *
      5  * Permission is hereby granted, free of charge, to any person obtaining a copy
      6  * of this software and associated documentation files (the "Software"), to deal
      7  * in the Software without restriction, including without limitation the rights
      8  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      9  * copies of the Software, and to permit persons to whom the Software is
     10  * furnished to do so, subject to the following conditions:
     11  *
     12  * The above copyright notice and this permission notice shall be included in
     13  * all copies or substantial portions of the Software.
     14  *
     15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     21  * SOFTWARE.
     22  */
     23 
     24 #include "kde_decoration.h"
     25 #include "util.h"
     26 
     27 #include "server-decoration-server-protocol.h"
     28 #include <wayland-server.h>
     29 
     30 static void
     31 request_mode(struct wl_client *client, struct wl_resource *resource,
     32              uint32_t mode)
     33 {
     34 	/* Server is required to send back the mode requested by
     35 	 * the client, we just don't plan to do anything with it. */
     36 	org_kde_kwin_server_decoration_send_mode(resource, mode);
     37 }
     38 
     39 static const struct org_kde_kwin_server_decoration_interface decoration_impl = {
     40     .release = destroy_resource,
     41     .request_mode = request_mode,
     42 };
     43 
     44 static void
     45 create(struct wl_client *client, struct wl_resource *resource, uint32_t id,
     46        struct wl_resource *toplevel_resource)
     47 {
     48 	struct wl_resource *decoration;
     49 
     50 	decoration =
     51 	    wl_resource_create(client, &org_kde_kwin_server_decoration_interface,
     52 	                       wl_resource_get_version(resource), id);
     53 	if (!decoration) {
     54 		wl_resource_post_no_memory(resource);
     55 		return;
     56 	}
     57 	wl_resource_set_implementation(decoration, &decoration_impl, NULL, NULL);
     58 	org_kde_kwin_server_decoration_send_mode(
     59 	    decoration, ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER);
     60 }
     61 
     62 static const struct org_kde_kwin_server_decoration_manager_interface
     63     decoration_manager_impl = {
     64         .create = create,
     65 };
     66 
     67 static void
     68 bind_decoration_manager(struct wl_client *client, void *data, uint32_t version,
     69                         uint32_t id)
     70 {
     71 	struct wl_resource *resource;
     72 
     73 	resource = wl_resource_create(
     74 	    client, &org_kde_kwin_server_decoration_manager_interface, version, id);
     75 	if (!resource) {
     76 		wl_client_post_no_memory(client);
     77 		return;
     78 	}
     79 	wl_resource_set_implementation(resource, &decoration_manager_impl, NULL,
     80 	                               NULL);
     81 	org_kde_kwin_server_decoration_manager_send_default_mode(
     82 	    resource, ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER);
     83 }
     84 
     85 struct wl_global *
     86 kde_decoration_manager_create(struct wl_display *display)
     87 {
     88 	return wl_global_create(display,
     89 	                        &org_kde_kwin_server_decoration_manager_interface,
     90 	                        1, NULL, &bind_decoration_manager);
     91 }