swc.h (24797B)
1 /* swc: libswc/swc.h 2 * 3 * Copyright (c) 2013 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 #ifndef SWC_H 25 #define SWC_H 26 27 #include <stdbool.h> 28 #include <stdint.h> 29 #include <sys/types.h> 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 struct libinput_device; 36 struct wl_display; 37 struct wl_event_loop; 38 struct wld_buffer; 39 40 /** 41 * Get the current cursor position. 42 * 43 * The returned coordinates are in compositor-global space, in wl_fixed_t 44 * (24.8) fixed-point units, but exposed as raw int32_t to avoid needing 45 * wayland headers. 46 * 47 */ 48 bool 49 swc_cursor_position(int32_t *x, int32_t *y); 50 51 /** 52 * Set the cursor position. 53 * 54 * The coordinates are in compositor-global space, exposed as raw int32_t 55 * to avoid needing wayland headers. This has the same effect as the 56 * cursor being moved there by an input device. 57 */ 58 bool 59 swc_cursor_set_position(int32_t x, int32_t y); 60 61 /** 62 * Feed a button event to the seat, through the bindings. 63 * button is a linux input code. 64 */ 65 bool 66 swc_button(uint32_t button, uint32_t state); 67 68 /** 69 * Feed a key event to the seat. key is an evdev code. 70 */ 71 bool 72 swc_key(uint32_t key, uint32_t state); 73 74 /** 75 * Find the key and level (0 bare, 1 shift) that produce keysym. 76 */ 77 bool 78 swc_keysym_to_key(uint32_t keysym, uint32_t *key, uint32_t *level); 79 80 /** 81 * Send a pointer button event to the currently focused client. 82 * 83 * This is intended for window managers which intercept button events (for 84 * example for mouse chords) but want normal clicks to still reach clients. 85 */ 86 void 87 swc_pointer_send_button(uint32_t time, uint32_t button, uint32_t state); 88 89 /** 90 * Send a pointer axis event to the currently focused client. 91 * 92 * This is intended for window managers which intercept axis events (for 93 * example for mouse chords) but want normal scrolling to still reach clients. 94 * 95 * value120 uses the wl_pointer "120 units" convention. 96 */ 97 void 98 swc_pointer_send_axis(uint32_t time, uint32_t axis, int32_t value120); 99 100 /* Cursor control (compositor-internal cursor) */ 101 enum swc_cursor_kind { 102 SWC_CURSOR_DEFAULT = 0, 103 SWC_CURSOR_BOX = 1, 104 SWC_CURSOR_CROSS = 2, 105 SWC_CURSOR_SIGHT = 3, 106 SWC_CURSOR_UP = 4, 107 SWC_CURSOR_DOWN = 5, 108 }; 109 110 enum swc_cursor_mode { 111 /* Allow clients to set their own cursors (I-beam, resize, etc). */ 112 SWC_CURSOR_MODE_CLIENT = 0, 113 /* Force compositor cursor; ignore client wl_pointer.set_cursor. */ 114 SWC_CURSOR_MODE_COMPOSITOR = 1, 115 }; 116 117 /** 118 * Override the compositor's internal cursor. 119 * 120 * this is intended for window managers to show mode cursors 121 * (move/resize/select) like the ones in hevel If a client has set its own 122 * cursor surface, swc may ignore the override. 123 */ 124 void 125 swc_set_cursor(enum swc_cursor_kind kind); 126 127 /** 128 * Control whether client cursor surfaces are honored. 129 */ 130 void 131 swc_set_cursor_mode(enum swc_cursor_mode mode); 132 133 /** 134 * set a custom argb8888 cursor image for a given kind 135 * 136 * `argb8888` is a pointer to `width*height` pixels in ARGB8888 order. 137 * the caller has to keep the pixel memory alive for as long as it may be used 138 */ 139 void 140 swc_set_cursor_image(enum swc_cursor_kind kind, const uint32_t *argb8888, 141 uint32_t width, uint32_t height, int32_t hotspot_x, 142 int32_t hotspot_y); 143 144 void 145 swc_clear_cursor_image(enum swc_cursor_kind kind); 146 147 /** 148 * set the picture of a cursor by its name: "default", "text", "pointer", 149 * "wait", "ew-resize" and the like, the names of CSS and of the 150 * cursor-shape-v1 protocol, which clients ask for by. nothing is drawn 151 * until a name is asked for, so a window manager with a theme gives 152 * every name it has. 153 * 154 * `argb8888` is `width*height` pixels, kept by the caller as long as it 155 * may be used 156 */ 157 void 158 swc_set_cursor_shape_image(const char *name, const uint32_t *argb8888, 159 uint32_t width, uint32_t height, int32_t hotspot_x, 160 int32_t hotspot_y); 161 162 /** 163 * show the cursor of this name where no client has the pointer, over a 164 * window's border for one, NULL for the usual 165 */ 166 void 167 swc_set_cursor_shape(const char *name); 168 169 /** 170 * be told where the pointer moves, x and y in compositor coordinates, so 171 * a window manager can say what is under it. at most one, NULL to stop 172 */ 173 void 174 swc_set_pointer_motion_handler(void (*handler)(void *data, int32_t x, int32_t y), 175 void *data); 176 177 /** 178 * the clipboard, for a compositor that keeps it itself. a client sets the 179 * selection as it does in any compositor, and the handler is told which types 180 * it offers (none when it is gone, the client exited or the selection was 181 * cleared). what the compositor keeps it offers again as a selection of its 182 * own, so the clipboard does not end with the client that copied 183 */ 184 struct swc_selection_handler { 185 void (*changed)(void *data, const char *const *mime_types, unsigned count); 186 }; 187 188 /* what answers a paste of a selection the compositor offers */ 189 struct swc_selection_source { 190 /* write the type to fd, which the caller closes */ 191 void (*send)(void *data, const char *mime_type, int fd); 192 /* another client took the selection */ 193 void (*cancelled)(void *data); 194 }; 195 196 void 197 swc_selection_set_handler(const struct swc_selection_handler *handler, void *data); 198 199 /** 200 * asks the client that holds the selection for a type, written to fd. 201 * false when no client holds it or it does not offer the type. the caller 202 * closes fd, the client has its own copy 203 */ 204 bool 205 swc_selection_request(const char *mime_type, int fd); 206 207 /** 208 * takes the selection, offering these types, answered by source. what was 209 * the selection is cancelled 210 */ 211 bool 212 swc_selection_offer(const char *const *mime_types, unsigned count, 213 const struct swc_selection_source *source, void *data); 214 215 /** 216 * draw [or update] a simple box overlay 217 * 218 * box is defined by two diagonally opposite corners in compositor-global 219 * coordinates. this draws only the border. Call swc_overlay_clear() to remove 220 * it 221 */ 222 void 223 swc_overlay_set_box(int32_t x1, int32_t y1, int32_t x2, int32_t y2, 224 uint32_t color, uint32_t border_width); 225 226 /** 227 * Clear the current overlay, if any. 228 */ 229 void 230 swc_overlay_clear(void); 231 232 /** 233 * Set the compositor zoom level. 234 * 235 * 1.0 = normal, >1.0 = zoomed in, <1.0 = zoomed out 236 * Uses software (pixman) scaling. 237 */ 238 void 239 swc_set_zoom(float level); 240 241 /** 242 * Get the current zoom level. 243 */ 244 float 245 swc_get_zoom(void); 246 247 /* Rectangles {{{ */ 248 249 struct swc_rectangle { 250 int32_t x, y; 251 uint32_t width, height; 252 }; 253 254 /* }}} */ 255 256 /* Screens {{{ */ 257 258 struct swc_screen_handler { 259 /** 260 * Called when the screen is about to be destroyed. 261 * 262 * After this is called, the screen is no longer valid. 263 */ 264 void (*destroy)(void *data); 265 266 /** 267 * Called when the total area of the screen has changed. 268 */ 269 void (*geometry_changed)(void *data); 270 271 /** 272 * Called when the geometry of the screen available for laying out windows 273 * has changed. 274 * 275 * A window manager should respond by making sure all visible windows are 276 * within this area. 277 */ 278 void (*usable_geometry_changed)(void *data); 279 280 /** 281 * Called when the pointer enters the screen. 282 */ 283 void (*entered)(void *data); 284 }; 285 286 struct swc_screen { 287 /** 288 * The total area of the screen. 289 */ 290 struct swc_rectangle geometry; 291 292 /** 293 * The area of the screen available for placing windows. 294 */ 295 struct swc_rectangle usable_geometry; 296 }; 297 298 /** 299 * Set the handler associated with this screen. 300 */ 301 void 302 swc_screen_set_handler(struct swc_screen *screen, 303 const struct swc_screen_handler *handler, void *data); 304 305 /* what a screen shows on, which says what may be changed about it */ 306 enum swc_screen_kind { 307 /* a display: its modes are the hardware's, any of them may be set */ 308 SWC_SCREEN_DISPLAY, 309 /* a window of another compositor: its size is that window's */ 310 SWC_SCREEN_WINDOW, 311 /* a framebuffer: it has the one mode it was set to */ 312 SWC_SCREEN_FRAMEBUFFER, 313 }; 314 315 struct swc_mode { 316 uint32_t width, height; 317 /* in mHz */ 318 uint32_t refresh; 319 bool preferred, current; 320 }; 321 322 /* the name of the screen's output, as wl_output names it (HDMI-A-1) */ 323 const char * 324 swc_screen_name(struct swc_screen *screen); 325 326 enum swc_screen_kind 327 swc_screen_kind(struct swc_screen *screen); 328 329 /* the modes the screen may be set to, at most max into out; how many 330 * there are */ 331 int 332 swc_screen_modes(struct swc_screen *screen, struct swc_mode *out, int max); 333 334 /* sets the screen to the mode of that size and refresh, a refresh of 0 335 * meaning the highest the size has. the change is made with the next 336 * frame; geometry_changed follows. false when the screen has no such mode 337 * or its modes are not the compositor's to set */ 338 bool 339 swc_screen_set_mode(struct swc_screen *screen, uint32_t width, 340 uint32_t height, uint32_t refresh); 341 342 /* places the screen's top left corner at x, y of the space the screens 343 * share; geometry_changed follows */ 344 void 345 swc_screen_move(struct swc_screen *screen, int32_t x, int32_t y); 346 347 /* }}} */ 348 349 /* Windows {{{ */ 350 351 struct swc_window_handler { 352 /** 353 * Called when the window is about to be destroyed. 354 * 355 * After this is called, the window is no longer valid. 356 */ 357 void (*destroy)(void *data); 358 359 /** 360 * Called when the window's title changes. 361 */ 362 void (*title_changed)(void *data); 363 364 /** 365 * Called when the window's application identifier changes. 366 */ 367 void (*app_id_changed)(void *data); 368 369 /** 370 * Called when the window's parent changes. 371 * 372 * This can occur when the window becomes a transient for another window, or 373 * becomes a toplevel window. 374 */ 375 void (*parent_changed)(void *data); 376 377 /** 378 * Called when the pointer enters the window. 379 */ 380 void (*entered)(void *data); 381 382 /** 383 * Called when the window wants to initiate an interactive move, but the 384 * window is not in stacked mode. 385 * 386 * The window manager may respond by changing the window's mode, after which 387 * the interactive move will be honored. 388 */ 389 void (*move)(void *data); 390 391 /** 392 * Called when the window wants to initiate an interactive resize, but the 393 * window is not in stacked mode. 394 * 395 * The window manager may respond by changing the window's mode, after which 396 * the interactive resize will be honored. 397 */ 398 void (*resize)(void *data); 399 400 /** 401 * Called when the window starts or stops blocking its parent. 402 */ 403 void (*modal_changed)(void *data); 404 405 /** 406 * Called when the window size changes. 407 */ 408 void (*size_changed)(void *data); 409 410 /** 411 * Called when the window asks to be shown fullscreen, or to stop being. 412 * 413 * The window manager decides, see swc_window_set_fullscreen. 414 */ 415 void (*fullscreen)(void *data, bool fullscreen); 416 }; 417 418 struct swc_window { 419 char *title; 420 char *app_id; 421 422 struct swc_window *parent; 423 /* the window says it blocks its parent */ 424 bool modal; 425 uint32_t motion_throttle_ms; 426 uint32_t min_width; 427 uint32_t min_height; 428 uint32_t max_width; 429 uint32_t max_height; 430 }; 431 432 /** 433 * Set the handler associated with this window. 434 */ 435 void 436 swc_window_set_handler(struct swc_window *window, 437 const struct swc_window_handler *handler, void *data); 438 439 /* what lies behind a window while the screen is composited: the target's 440 * pixels as drawn so far, pitch bytes a row in a WLD format, the window's 441 * area with the margin asked for (in those pixels, clipped to them), and the 442 * parts of it being repainted now, which every caller may read and write */ 443 struct swc_backdrop { 444 void *pixels; 445 uint32_t pitch, format; 446 struct swc_rectangle area; 447 const struct swc_rectangle *rects; 448 int nrects; 449 }; 450 451 /* calls hook right before the window is drawn with what lies behind it, so 452 * a window manager can read it or change it: glass, a shade, a lens. the 453 * whole area and margin is drawn again whenever any of it changes, so the 454 * pixels are always complete there. a NULL hook takes it away */ 455 void 456 swc_window_set_backdrop(struct swc_window *window, uint32_t margin, 457 void (*hook)(void *data, const struct swc_backdrop *backdrop), void *data); 458 459 /* depths: a view at a higher one is drawn over one at a lower. the 460 * shells' layers stand at these, a window at SWC_Z_WINDOW until its manager 461 * says otherwise, and every depth between them is the manager's: floating 462 * windows over tiled ones, a fullscreen window over the panels. a window is 463 * raised to the front of the views at its depth, and its transients share 464 * it */ 465 #define SWC_Z_BACKGROUND (-3000) 466 #define SWC_Z_BOTTOM (-2000) 467 #define SWC_Z_WINDOW 0 468 #define SWC_Z_TOP 2000 469 #define SWC_Z_OVERLAY 3000 470 471 void 472 swc_window_set_z(struct swc_window *window, int32_t z); 473 474 /** 475 * Request that the specified window close. 476 */ 477 void 478 swc_window_close(struct swc_window *window); 479 480 /** 481 * Make the specified window visible. 482 */ 483 void 484 swc_window_show(struct swc_window *window); 485 486 /** 487 * Make the specified window hidden. 488 */ 489 void 490 swc_window_hide(struct swc_window *window); 491 492 /** 493 * Set the keyboard focus to the specified window. 494 * 495 * If window is NULL, the keyboard will have no focus. 496 */ 497 void 498 swc_window_focus(struct swc_window *window); 499 500 /** 501 * Sets the window to stacked mode. 502 * 503 * A window in this mode has its size specified by the client. The window's 504 * viewport will be adjusted to the size of the buffer attached by the 505 * client. 506 * 507 * Use of this mode is required to allow interactive moving and resizing. 508 */ 509 void 510 swc_window_set_stacked(struct swc_window *window); 511 512 /** 513 * Sets the window to tiled mode. 514 * 515 * A window in this mode has its size specified by the window manager. 516 * Additionally, swc will configure the window to operate in a tiled or 517 * maximized state in order to prevent the window from drawing shadows. 518 * 519 * It is invalid to interactively move or resize a window in tiled mode. 520 */ 521 void 522 swc_window_set_tiled(struct swc_window *window); 523 524 /** 525 * Sets the window to fullscreen mode. 526 */ 527 void 528 swc_window_set_fullscreen(struct swc_window *window, struct swc_screen *screen); 529 530 /** 531 * Make window a transient of parent, or of nothing when NULL. 532 */ 533 void 534 swc_window_set_parent(struct swc_window *window, struct swc_window *parent); 535 536 /** 537 * An attached transient moves with its parent. 538 */ 539 void 540 swc_window_set_attached(struct swc_window *window, bool attached); 541 542 /** 543 * Raise the window with its transients. 544 */ 545 void 546 swc_window_raise(struct swc_window *window); 547 548 /** 549 * Set the window's position. 550 * 551 * The x and y coordinates refer to the top-left corner of the actual contents 552 * of the window and should be adjusted for the border size. 553 */ 554 void 555 swc_window_set_position(struct swc_window *window, int32_t x, int32_t y); 556 557 /** 558 * Set the window's size. 559 * 560 * The width and height refer to the dimension of the actual contents of the 561 * window and should be adjusted for the border size. 562 */ 563 void 564 swc_window_set_size(struct swc_window *window, uint32_t width, uint32_t height); 565 566 /** 567 * Set the window's size and position. 568 * 569 * This is a convenience function that is equivalent to calling 570 * swc_window_set_size and then swc_window_set_position. 571 */ 572 void 573 swc_window_set_geometry(struct swc_window *window, 574 const struct swc_rectangle *geometry); 575 576 /** 577 * Get the window's current geometry in compositor-global coordinates. 578 */ 579 bool 580 swc_window_get_geometry(const struct swc_window *window, 581 struct swc_rectangle *geometry); 582 583 /** 584 * Get the pid of the client that owns this window 585 * 586 * returns pid, or 0 if unavailable 587 */ 588 pid_t 589 swc_window_get_pid(struct swc_window *window); 590 591 /** 592 * Set the window's border color and width. 593 * 594 * NOTE: The window's geometry remains unchanged, and should be updated if a 595 * fixed top-left corner of the border is desired. 596 * 597 * info from dalem: unsure how much double borders break! 598 */ 599 void 600 swc_window_set_border(struct swc_window *window, uint32_t inner_border_color, 601 uint32_t inner_border_width, uint32_t outer_border_color, 602 uint32_t outer_border_width); 603 604 /** 605 * What the border goes around. 606 */ 607 enum swc_border_placement { 608 /** 609 * The client area only. 610 */ 611 SWC_BORDER_CLIENT, 612 /** 613 * The client area and its decor. 614 */ 615 SWC_BORDER_FRAME, 616 }; 617 618 /** 619 * Choose what the border goes around. The default is SWC_BORDER_CLIENT. 620 */ 621 void 622 swc_window_set_border_placement(struct swc_window *window, 623 enum swc_border_placement placement); 624 625 /*window decor things*/ 626 627 /** 628 * Select which decor edge a text slot is rendered on. 629 */ 630 enum swc_decor_edge { 631 SWC_DECOR_EDGE_TOP, 632 SWC_DECOR_EDGE_RIGHT, 633 SWC_DECOR_EDGE_BOTTOM, 634 SWC_DECOR_EDGE_LEFT, 635 }; 636 637 /** 638 * Choose text alignment within the selected decor edge. 639 * 640 * for top and bottom edges, alignment is horizontal 641 * for left and right edges, alignment is vertical 642 */ 643 enum swc_decor_align { 644 SWC_DECOR_ALIGN_START, 645 SWC_DECOR_ALIGN_CENTER, 646 SWC_DECOR_ALIGN_END, 647 }; 648 649 /** 650 * Describe a window decor text slot. 651 * 652 * if enabled is false, no text is drawn. 653 * 654 * the wm supplies some string to be rendered in this decor slot. swc 655 * copies the string when swc_window_set_decor() is called, so caller doesn't 656 * need to keep it after the call returns. 657 * 658 * for top and bottom edges, text is drawn horizontally 659 * for left and right edges, text is drawn as stacked glyphs, one glyph 660 * per row. 661 * 662 * the font field is a font file ("/a/font.ttf:pixelsize=12"), or a 663 * fontconfig pattern such as "sans-serif:size=10" where wld has fontconfig. 664 * if font is NULL, a default font is used. 665 */ 666 struct swc_decor_text { 667 bool enabled; 668 enum swc_decor_edge edge; 669 enum swc_decor_align align; 670 const char *string; 671 uint32_t color; 672 uint32_t padding; 673 int32_t offset_x, offset_y; 674 const char *font; 675 }; 676 677 /** 678 * Describes one wm-supplied decor pixel block. 679 * 680 * swc copies the pixel data when swc_window_set_decor() is called, so caller 681 * doesn't need to keep it after the call returns. 682 * 683 * Pixel data is expected to be premultiplied ARGB8888 with the provided 684 * stride. 685 */ 686 struct swc_decor_part { 687 uint32_t width, height; 688 uint32_t stride; 689 const void *data; 690 }; 691 692 /** 693 * Describes optional pixel blocks for the outer frame of a decor. 694 * 695 * corner parts are drawn once at their matching corner 696 * edge parts are tiled to fill the remaining edge area between corners. 697 */ 698 struct swc_decor_parts { 699 struct swc_decor_part top_left; 700 struct swc_decor_part top; 701 struct swc_decor_part top_right; 702 struct swc_decor_part left; 703 struct swc_decor_part right; 704 struct swc_decor_part bottom_left; 705 struct swc_decor_part bottom; 706 struct swc_decor_part bottom_right; 707 }; 708 709 /** 710 * Describe decor around a window's edges. 711 * 712 * The edge sizes extend outward from the window content geometry. 713 * if you put 0 it won't be visible. 714 * 715 * The title field controls an optional text slot rendered on one edge. 716 */ 717 struct swc_decor { 718 uint32_t color; 719 uint32_t top, right, bottom, left; 720 const struct swc_decor_parts *parts; 721 struct swc_decor_text title; 722 }; 723 724 /** 725 * Set window decor around the window. 726 * 727 * the dimensions are independent for each edge and extend outward from the 728 * window content geometry. 729 * 730 * swc copies any decor text string needed by the configuration. 731 * 732 * passing NULL disables window decor. 733 */ 734 void 735 swc_window_set_decor(struct swc_window *window, const struct swc_decor *decor); 736 737 /** 738 * Begin an interactive move of the specified window. 739 */ 740 void 741 swc_window_begin_move(struct swc_window *window); 742 743 /** 744 * End an interactive move of the specified window. 745 */ 746 void 747 swc_window_end_move(struct swc_window *window); 748 749 enum { 750 SWC_WINDOW_EDGE_AUTO = 0, 751 SWC_WINDOW_EDGE_TOP = (1 << 0), 752 SWC_WINDOW_EDGE_BOTTOM = (1 << 1), 753 SWC_WINDOW_EDGE_LEFT = (1 << 2), 754 SWC_WINDOW_EDGE_RIGHT = (1 << 3) 755 }; 756 757 /** 758 * Begin an interactive resize of the specified window. 759 */ 760 void 761 swc_window_begin_resize(struct swc_window *window, uint32_t edges); 762 763 /** 764 * End an interactive resize of the specified window. 765 */ 766 void 767 swc_window_end_resize(struct swc_window *window); 768 769 /** 770 * returns the topmost window at any given compositor global coordinates 771 * 772 * returns null if there is no window at that point 773 */ 774 struct swc_window * 775 swc_window_at(int32_t x, int32_t y); 776 777 /** 778 * move a window in the stacking order by one step 779 * 780 * direction < 0 moves the window towards the front (higher) 781 * direction > 0 moves the window towards the back (lower) 782 */ 783 void 784 swc_window_stack(struct swc_window *window, int32_t direction); 785 786 /* }}} */ 787 788 /* Keyboard repeat rate (characters per second) and delay (ms) definitions. 789 * Exposed as extern so compositors can set them. 790 */ 791 extern int32_t swc_repeat_rate, swc_repeat_delay; 792 793 /** 794 * Change the keyboard layout while running: names as XKB's, any of them 795 * NULL for its default. False, the old layout kept, when they make no 796 * keymap. 797 */ 798 bool 799 swc_set_keyboard_layout(const char *layout, const char *variant, 800 const char *options); 801 802 /** 803 * Change the keyboard to a whole keymap, XKB's text format, for a layout 804 * that is not named in the system's rules. False, the old keymap kept, when 805 * the text makes none. 806 */ 807 bool 808 swc_set_keyboard_keymap(const char *keymap); 809 810 /** 811 * Change the repeat rate (characters per second) and delay (ms), which 812 * clients are told again. 813 */ 814 void 815 swc_set_keyboard_repeat(int32_t rate, int32_t delay); 816 817 /* Bindings {{{ */ 818 819 enum { 820 SWC_MOD_CTRL = 1 << 0, 821 SWC_MOD_ALT = 1 << 1, 822 SWC_MOD_LOGO = 1 << 2, 823 SWC_MOD_SHIFT = 1 << 3, 824 SWC_MOD_ANY = ~0 825 }; 826 827 /** 828 * Drag actions, as in wl_data_device_manager.dnd_action. 829 */ 830 enum swc_drag_action { 831 SWC_DRAG_COPY = 1, 832 SWC_DRAG_MOVE = 2, 833 SWC_DRAG_ASK = 4, 834 }; 835 836 /** 837 * Set the modifiers that ask for an action during a drag, all held. 838 * 0 disables it. Defaults: Ctrl copy, Shift move. 839 */ 840 void 841 swc_set_drag_modifiers(enum swc_drag_action action, uint32_t modifiers); 842 843 enum swc_binding_type { 844 SWC_BINDING_KEY, 845 SWC_BINDING_BUTTON, 846 }; 847 848 typedef void (*swc_binding_handler)(void *data, uint32_t time, uint32_t value, 849 uint32_t state); 850 typedef void (*swc_axis_binding_handler)(void *data, uint32_t time, 851 uint32_t axis, int32_t value120); 852 853 /** 854 * Register a new input binding. 855 * 856 * Returns 0 on success, negative error code otherwise. 857 */ 858 int 859 swc_add_binding(enum swc_binding_type type, uint32_t modifiers, uint32_t value, 860 swc_binding_handler handler, void *data); 861 862 /** 863 * Unregister a registered input binding. 864 * 865 */ 866 void 867 swc_remove_binding(enum swc_binding_type type, uint32_t modifiers, 868 uint32_t value); 869 870 /** 871 * register a new pointer axis binding 872 * 873 * this will intercept axis events from clients; use swc_pointer_send_axis() 874 * from the handler to forward events when appropriate 875 */ 876 int 877 swc_add_axis_binding(uint32_t modifiers, uint32_t axis, 878 swc_axis_binding_handler handler, void *data); 879 880 /* }}} */ 881 882 /** 883 * This is a user-provided structure that swc will use to notify the display 884 * server of new windows, screens and input devices. 885 */ 886 struct swc_manager { 887 /** 888 * Called when a new screen is created. 889 */ 890 void (*new_screen)(struct swc_screen *screen); 891 892 /** 893 * Called when a new window is created. 894 */ 895 void (*new_window)(struct swc_window *window); 896 897 /** 898 * Called when a new input device is detected. 899 */ 900 void (*new_device)(struct libinput_device *device); 901 902 /** 903 * Called when the session gets activated (for example, startup or VT 904 * switch). 905 */ 906 void (*activate)(void); 907 908 /** 909 * Called when the session gets deactivated. 910 */ 911 void (*deactivate)(void); 912 }; 913 914 /** 915 * Initializes the compositor using the specified display, event_loop, and 916 * manager. 917 */ 918 bool 919 swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, 920 const struct swc_manager *manager); 921 922 /** 923 * Stops the compositor, releasing any used resources. 924 */ 925 void 926 swc_finalize(void); 927 928 #ifdef __cplusplus 929 } 930 #endif 931 932 #endif 933 934 /* vim: set fdm=marker : */