1 /* 2 * 0BSD 3 * 4 * BSD Zero Clause License 5 * 6 * Copyright (c) 2019 Hermann Meyer 7 * 8 * Permission to use, copy, modify, and/or distribute this software for any 9 * purpose with or without fee is hereby granted. 10 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 13 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 16 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 * 19 */ 20 21 #pragma once 22 23 #ifndef XWIDGET_H 24 #define XWIDGET_H 25 26 #include "xputty.h" 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 /*--------------------------------------------------------------------- 33 ----------------------------------------------------------------------- 34 basic X11 widgets 35 ----------------------------------------------------------------------- 36 ----------------------------------------------------------------------*/ 37 38 #define SYSTEM_TRAY_REQUEST_DOCK 0 39 #define SYSTEM_TRAY_BEGIN_MESSAGE 1 40 #define SYSTEM_TRAY_CANCEL_MESSAGE 2 41 42 /** 43 * @brief *vfunc - function pointer to connect Xevents from the main loop to Widget_t 44 * @param *widget - void pointer to the Widget_t 45 * @param *main - pointer to Xputty main struct running the loop 46 * @param *event - void pointer to the XEvent 47 * @param *user_data - void pointer to attached user_data, maybe NULL 48 * @return void 49 */ 50 51 typedef void (*vfunc)(void * widget, void * event, Xputty *main, void* user_data); 52 53 /** 54 * @brief *evfunc - function pointer to connect Xevents from a Widget_t to a event handler 55 * @param *widget - void pointer to the Widget_t 56 * @param *event - void pointer to the XEvent 57 * @param *user_data - void pointer to attached user_data, maybe NULL 58 * @return void 59 */ 60 61 typedef void (*evfunc)(void * widget, void * event, void* user_data); 62 63 64 /** 65 * @brief *xevfunc - function pointer to connect XEvents from a Widget_t to a event handler 66 * @param *widget - void pointer to the widget 67 * @param *user_data - void pointer to attached user_data, maybe NULL 68 * @return void 69 */ 70 71 typedef void (*xevfunc)(void * widget, void* user_data); 72 73 /** 74 * 75 * @brief Func_t - struct to hold all supported event callbacks 76 * 77 */ 78 79 typedef struct { 80 xevfunc expose_callback; 81 xevfunc configure_callback; 82 xevfunc enter_callback; 83 xevfunc leave_callback; 84 xevfunc adj_callback; 85 xevfunc value_changed_callback; 86 xevfunc user_callback; 87 xevfunc mem_free_callback; 88 xevfunc configure_notify_callback; 89 xevfunc map_notify_callback; 90 xevfunc unmap_notify_callback; 91 xevfunc dialog_callback; 92 xevfunc dnd_notify_callback; 93 94 evfunc button_press_callback; 95 evfunc button_release_callback; 96 evfunc double_click_callback; 97 evfunc motion_callback; 98 evfunc key_press_callback; 99 evfunc key_release_callback; 100 } Func_t; 101 102 /** 103 * 104 * @brief EventType - enum to hold identifier for all supported event callbacks 105 * \n Events could be connected to a handler by using this identifier 106 * @param EXPOSE - (*xevfunc) expose_callback(void * widget, void* user_data) 107 * @param CONFIGURE - (*xevfunc) configure_callback(void * widget, void* user_data) 108 * @param ENTER - (*xevfunc) enter_callback(void * widget, void* user_data) 109 * @param LEAVE - (*xevfunc) leave_callback(void * widget, void* user_data) 110 * @param ADJ_INTERN - (*xevfunc) adj_callback(void * widget, void* user_data) 111 * @param VALUE_CHANGED - (*xevfunc) value_changed_callback(void * widget, void* user_data) 112 * @param USER - (*xevfunc) user_callback(void * widget, void* user_data) 113 * @param MEM_FREE - (*xevfunc) mem_free_callback(void * widget, void* user_data) 114 * @param CONFIGURE_NOTIFY - (*xevfunc) configure_notify_callback(void * widget, void* user_data) 115 * @param MAP_NOTIFY - (*xevfunc) map_notify_callback(void * widget, void* user_data) 116 * @param UNMAP_NOTIFY - (*xevfunc) unmap_notify_callback(void * widget, void* user_data) 117 * @param DIALOG_RESPONS - (*xevfunc) dialog_callback(void * widget, void* user_data) 118 * @param BUTTON_PRESS - (*evfunc) button_press_callback(void * widget, void * event, void* user_data) 119 * @param BUTTON_RELEASE - (*evfunc) button_release_callback(void * widget, void * event, void* user_data) 120 * @param POINTER_MOTION - (*evfunc) motion_callback(void * widget, void * event, void* user_data) 121 * @param KEY_PRESS - (*evfunc) key_press_callback(void * widget, void * event, void* user_data) 122 * @param KEY_RELEASE - (*evfunc) key_release_callback(void * widget, void * event, void* user_data) 123 */ 124 125 typedef enum { 126 EXPOSE = 1, 127 CONFIGURE, 128 ENTER, 129 LEAVE, 130 ADJ_INTERN, 131 VALUE_CHANGED, 132 USER, 133 MEM_FREE, 134 CONFIGURE_NOTIFY, 135 MAP_NOTIFY, 136 UNMAP_NOTIFY, 137 DIALOG_RESPONSE, 138 BUTTON_PRESS, 139 BUTTON_RELEASE, 140 POINTER_MOTION, 141 KEY_PRESS, 142 KEY_RELEASE, 143 } EventType; 144 145 /** 146 * 147 * @brief Gravity - enum to indicate how to resize a widget 148 * @param NORTHWEST - Widget_t adjust nord/west 149 * @param NORTHEAST - Widget_t adjust nord/east 150 * @param SOUTHWEST - Widget_t adjust south/west 151 * @param SOUTHEAST - Widget_t adjust south/east 152 * @param CENTER - Widget_t adjust centered 153 * @param ASPECT - Widget_t adjust in a aspect frame 154 * @param NONE - Widget_t request no adjustment in frame 155 */ 156 157 typedef enum { 158 /** Widget_t adjust nord/west */ 159 NORTHWEST , 160 /** Widget_t adjust nord/east */ 161 NORTHEAST , 162 /** Widget_t adjust south/west */ 163 SOUTHWEST , 164 /** Widget_t adjust south/east */ 165 SOUTHEAST , 166 /** Widget_t adjust south/east */ 167 SOUTHCENTER , 168 /** Widget_t adjust east/west */ 169 EASTWEST , 170 /** Widget_t adjust east/north */ 171 EASTNORTH , 172 /** Widget_t adjust west/north */ 173 WESTNORTH , 174 /** Widget_t adjust west/south */ 175 WESTSOUTH , 176 /** Widget_t adjust centered */ 177 CENTER , 178 /** Widget_t adjust in a aspect frame */ 179 ASPECT , 180 /** Widget_t has fixed size */ 181 FIXEDSIZE , 182 /** Widget_t adjust in a aspect frame */ 183 MENUITEM , 184 /** Widget_t request no adjustment in frame */ 185 NONE , 186 }Gravity; 187 188 /** 189 * 190 * @brief Resize_t - struct used to resize child widgets 191 * @param init_x - initial x position on Parent 192 * @param init_y - initial y position on Parent 193 * @param init_width - initial width 194 * @param init_height - initial height 195 * @param scale_x - scalling size of the x axsis 196 * @param scale_y - scalling size of the y axsis 197 * @param cscale_x - scalling factor of the x axsis 198 * @param cscale_y - scalling factor of the y axsis 199 * @param ascale - scalling factor for aspect scalling 200 */ 201 202 typedef struct { 203 /** indicate how the widget wish to be resized */ 204 Gravity gravity; 205 /** initial x position on Parent */ 206 int init_x; 207 /** initial y position on Parent */ 208 int init_y; 209 /** initial width */ 210 int init_width; 211 /** initial height */ 212 int init_height; 213 /** scalling size of the x axsis */ 214 float scale_x; 215 /** scalling size of the y axsis */ 216 float scale_y; 217 /** scalling factor of the x axsis */ 218 float cscale_x; 219 /** scalling factor of the y axsis */ 220 float cscale_y; 221 /** rescalling factor of the x axsis */ 222 float rcscale_x; 223 /** rescalling factor of the y axsis */ 224 float rcscale_y; 225 /** scalling factor for aspect scalling */ 226 float ascale; 227 } Resize_t; 228 229 /** 230 * 231 * @brief anonymous enum - flags to set Widget_t propertys 232 * @param IS_WIDGET - Widget_t is a sub widget 233 * @param IS_WINDOW - Widget_t has no Widget_t parent 234 * @param IS_POPUP - Widget_t is a pop up widget 235 * @param IS_RADIO - Widget_t is part of a radio group 236 * @param USE_TRANSPARENCY - Widget_t need transparent draw (buffer) 237 * @param HAS_FOCUS - Mouse pointer is above Widget_t 238 * @param HAS_POINTER - Mouse pointer is pressed on Widget_t 239 * @param HAS_TOOLTIP - Widget_t have tooltip 240 * @param HAS_MEM - Widget_t have mem to be released 241 */ 242 243 enum { 244 /** Widget_t is a sub widget */ 245 IS_WIDGET = 1<<0, 246 /** Widget_t has no Widget_t parent */ 247 IS_WINDOW = 1<<1, 248 /** Widget_t is a pop up widget */ 249 IS_POPUP = 1<<2, 250 /** Widget_t is part of a radio group */ 251 IS_RADIO = 1<<3, 252 /** Widget_t is a tooltip widget */ 253 IS_TOOLTIP = 1<<4, 254 /** Widget_t need transparent draw (buffer) */ 255 USE_TRANSPARENCY = 1<<5, 256 /** Mouse pointer is above Widget_t */ 257 HAS_FOCUS = 1<<6, 258 /** Mouse pointer is pressed on Widget_t */ 259 HAS_POINTER = 1<<7, 260 /** Widget_t have tooltip */ 261 HAS_TOOLTIP = 1<<8, 262 /** Widget_t have mem to be released */ 263 HAS_MEM = 1<<9, 264 /** Widget_t didn't receive autorepeated keys */ 265 NO_AUTOREPEAT = 1<<10, 266 /** Widget_t need fast redrawing */ 267 FAST_REDRAW = 1<<11, 268 /** Hide Widget_t instead delete on "WM_DELETE_WINDOW" */ 269 HIDE_ON_DELETE = 1<<12, 270 /** Widget_t reuse a surface from a other Widget_t */ 271 REUSE_IMAGE = 1<<13, 272 /** Widget_t didn't receive redraw events on propagate */ 273 NO_PROPAGATE = 1<<14, 274 /** Widget_t is a sub Widget_t from a Popup Widget_t */ 275 IS_SUBMENU = 1<<15, 276 277 }; 278 279 /** 280 * 281 * @brief Widget_t - struct to hold the basic Widget_t info 282 * @param *app - pointer to the main struct 283 * @param widget - the X11 Window 284 * @param *parent - pointer to the Parent Window or Widget_t 285 * @param event_callback - the main XEvent callback 286 * @param func - struct holding the event callbacks 287 * @param *surface - pointer to the cairo xlib surface 288 * @param *cr - pointer to the cairo xlib surface context 289 * @param *buffer - pointer to the cairo buffer surface 290 * @param *crb - pointer to the cairo buffer surface context 291 * @param *image - pointer to the cairo image surface 292 * @param data - int to hold user data 293 * @param flags - unsigned int to hold Widget_t flags 294 * @param *label - pointer to the widget label 295 * @param input_label - char array the widget input label 296 * @param state - int to hold the widget state 297 * @param pos_x - mouse pointer x position on button press 298 * @param pos_y - mouse pointer y position on button press 299 * @param x - x position of Window on Parent 300 * @param y - y position of Window on Parent 301 * @param width - widget width 302 * @param height - widget height 303 * @param scale - struct used to resize child widgets 304 * @param *adj_x - pointer to the x axis adjustment 305 * @param *adj_y - pointer to the y axis adjustment 306 * @param *adj - pointer to the adjustment in use 307 * @param *childlist - pointer to Widget_t child list 308 * @param xic - Locale and UTF 8 support interface 309 * @param xim - Context to Locale and UTF 8 support 310 */ 311 312 struct Widget_t { 313 /** pointer to the main struct */ 314 Xputty *app; 315 /** the X11 newly created Window */ 316 Window widget; 317 /** pointer to the Parent Window or Widget_t */ 318 void *parent; 319 /** pointer to the Parent struct */ 320 void *parent_struct; 321 /** pointer to the Parent struct */ 322 void *private_struct; 323 /** the main XEvent callback */ 324 vfunc event_callback; 325 /** struct holding the event callbacks */ 326 Func_t func; 327 /** pointer to the cairo xlib surface */ 328 cairo_surface_t *surface; 329 /** pointer to the cairo xlib surface context */ 330 cairo_t *cr; 331 /** pointer to the cairo buffer surface used for transparency */ 332 cairo_surface_t *buffer; 333 /** pointer to the cairo buffer surface context */ 334 cairo_t *crb; 335 /** pointer to the cairo image surface used to load a png */ 336 cairo_surface_t *image; 337 /** int to hold user data */ 338 int data; 339 /** int to hold Widget_t flags */ 340 long long flags; 341 /** pointer to the widget label */ 342 const char* label; 343 /** char array to hold user input */ 344 char input_label[32]; 345 /** pointer to the x axis adjustment */ 346 Adjustment_t *adj_x; 347 /** pointer to the y axis adjustment */ 348 Adjustment_t *adj_y; 349 /** pointer to the adjustment in use*/ 350 Adjustment_t *adj; 351 /** pointer to Widget_t child list */ 352 Childlist_t *childlist; 353 /** Locale and UTF 8 support */ 354 XIC xic; 355 /** Context to Locale and UTF 8 support */ 356 XIM xim; 357 /** int to hold the widget state default = 0 */ 358 Time double_click; 359 /** time of the last button press */ 360 int state; 361 /** mouse pointer x position on button press */ 362 int pos_x; 363 /** mouse pointer y position on button press */ 364 int pos_y; 365 /** x position of Window related to the Parent */ 366 int x; 367 /** y position of Window related to the Parent */ 368 int y; 369 /** the widget size x-axis */ 370 int width; 371 /** the widget size y-axis */ 372 int height; 373 /** struct used to resize child widgets */ 374 Resize_t scale; 375 /** notify widget that a paste is in clipboard */ 376 xevfunc xpaste_callback; 377 }; 378 379 380 /** 381 * @brief *create_window - create a Window 382 * \n You need to create as least minimun one Window to get started. 383 * \n The first created Window is the top_level_widget() 384 * \n A Window could be created on the DefaultRootWindow() or embeded 385 * into a other XWindow 386 * @param *app - pointer to the Xputty *main struct to use 387 * @param win - pointer to the Parrent Window (may be Root) 388 * @param x,y,width,height - the position/geometry to create the window 389 * @return Widget_t * - pointer to the Widget_t struct 390 */ 391 392 Widget_t *create_window(Xputty *app, Window win, 393 int x, int y, int width, int height); 394 395 /** 396 * @brief *create_widget - create a widget 397 * \n A Widget_t could only be created as child of a other Widget_t 398 * \n To create a Widget_t you need to create a Widget_t with create_window() 399 * before. 400 * @param *app - pointer to the Xputty *main struct to use 401 * @param *parent - pointer to the Parrent Widget_t 402 * @param x,y,width,height - the position/geometry to create the widget 403 * @return Widget_t* - pointer to the Widget_t struct 404 */ 405 406 Widget_t *create_widget(Xputty *app, Widget_t *win, 407 int x, int y, int width, int height); 408 409 /** 410 * @brief connect_func - connect a event with a handler 411 * without type check. For supported events see: Func_t 412 * @param **event - the event to connect 413 * @param *handler - the handler to handle the event 414 * @return void 415 */ 416 417 void connect_func(void (**event)(), void (*handler)()); 418 419 /** 420 * @brief widget_set_title - set window title for a Widget_t 421 * @param *w - pointer to the Widget_t to set the title 422 * @param *title - the title to store 423 * @return void 424 */ 425 426 void widget_set_title(Widget_t *w, const char *title); 427 428 /** 429 * @brief widget_show - map/show widget 430 * @param *w - pointer to the Widget_t to map 431 * @return void 432 */ 433 434 void widget_show(Widget_t *w); 435 436 /** 437 * @brief pop_widget_show_all - map/show popup widget with all it's childs 438 * @param *w - pointer to the Widget_t to map 439 * @return void 440 */ 441 442 void pop_widget_show_all(Widget_t *w); 443 444 /** 445 * @brief submenu_widget_show_all - map/show submenu Widget_t with all childs 446 * @param *w - pointer to the Widget_t to map 447 * @return void 448 */ 449 450 void submenu_widget_show_all(Widget_t *w); 451 452 /** 453 * @brief widget_hide - unmap/hide a Widget_t 454 * @param *w - pointer to the Widget_t to unmap 455 * @return void 456 */ 457 458 void widget_hide(Widget_t *w); 459 460 /** 461 * @brief widget_show_all - map/show Widget_t with all childs 462 * @param *w - pointer to the Widget_t to map 463 * @return void 464 */ 465 466 void widget_show_all(Widget_t *w); 467 468 /** 469 * @brief show_tooltip - check if a Widget_t have a tooltip, 470 * and show it, if a tooltip is available. 471 * @param *wid - pointer to the Widget_t receiving the event 472 * @return void 473 */ 474 475 void show_tooltip(Widget_t *wid); 476 477 /** 478 * @brief hide_tooltip - check if a Widget_t have a tooltip, 479 * and hide it, if a tooltip is mapped. 480 * @param *wid - pointer to the Widget_t receiving the event 481 * @return void 482 */ 483 484 void hide_tooltip(Widget_t *wid); 485 486 /** 487 * @brief *get_toplevel_widget - get pointer to the top level Widget_t 488 * @param *main - pointer to the main Xputty struct 489 * @return void 490 */ 491 492 Widget_t *get_toplevel_widget(Xputty *main); 493 494 /** 495 * @brief quit - exit the main loop 496 * @param *w - pointer to the Widget_t sending the request 497 * @return void 498 */ 499 500 void quit(Widget_t *w); 501 502 /** 503 * @brief quit_widget - remove a widget from the processing loop 504 * @param *w - pointer to the Widget_t sending the request 505 * @return void 506 */ 507 508 void quit_widget(Widget_t *w); 509 510 /** 511 * @brief transparent_draw - copy parent surface to child surface 512 * \n you usaualy didn't need to call this, it's used automaticaly 513 * when a Widget_t have set the flag USE_TRANSPARENCY 514 * \n this is the default setting for Widget_t 515 * @param *wid - pointer to the Widget_t receiving the event 516 * @param *user_data - void pointer to attached user_data 517 * @return void 518 */ 519 520 void transparent_draw(void * wid, void* user_data); 521 522 523 /** 524 * @brief resize_childs - intern check if child widgets needs resizing 525 * @param *wid - pointer to the Widget_t receive the event 526 * @return void 527 */ 528 529 void resize_childs(Widget_t *wid); 530 531 /** 532 * @brief widget_reset_scale - used to reset scaling mode after a image surface 533 * is drawn to the Widget_t surface with widget_set_scale() 534 * @param *w - pointer to the Widget_t sending the request 535 * @return void 536 */ 537 538 void widget_reset_scale(Widget_t *w); 539 540 /** 541 * @brief widget_set_scale - set scaling mode to scale a image surface 542 * to the size of the Widget_t surface 543 * @param *w - pointer to the Widget_t sending the request 544 * @return void 545 */ 546 547 void widget_set_scale(Widget_t *w); 548 549 /** 550 * @brief destroy_widget - destroy a widget 551 * \n When a Widget_t receive a destroy_widget() call, it will propagate that 552 * to all childs in it's Childlist_t. So all childs get destroyed before the 553 * Widget_t itself close. 554 * @param *w - pointer to the Widget_t sending the request 555 * @param *main - pointer to main struct 556 * @return void 557 */ 558 559 void destroy_widget(Widget_t *w, Xputty *main); 560 561 /** 562 * @brief widget_event_loop - the internal widget event loop 563 * @param *w - void pointer to the Widget_t receiving the event 564 * @param *event - void pointer to the XEvent 565 * @param *main - void pointer to the Xputty *main struct running 566 * the event loop 567 * @param *user_data - void pointer to attached user_data 568 * @return void 569 */ 570 571 void widget_event_loop(void *w_, void* event, Xputty *main, void* user_data); 572 573 /** 574 * @brief send_configure_event - send a ConfigureNotify to Widget_t 575 * \n used to resize a Widget_t 576 * @param *w - pointer to the Widget_t to send the notify 577 * @param x,y - the new Widget_t position 578 * @param width,height - the new Widget_t size 579 * @return void 580 */ 581 582 void send_configure_event(Widget_t *w,int x, int y, int width, int height); 583 584 /** 585 * @brief send_button_press_event - send ButtonPress event to Widget_t 586 * \n simulate a BUTTON_PRESS Event 587 * @param *w - pointer to the Widget_t to send the notify 588 * @return void 589 */ 590 591 void send_button_press_event(Widget_t *w); 592 593 /** 594 * @brief send_button_release_event - send ButtonRelease event to Widget_t 595 * \n simulate a BUTTON_RELEASE Event 596 * @param *w - pointer to the Widget_t to send the notify 597 * @return void 598 */ 599 600 void send_button_release_event(Widget_t *w); 601 602 /** 603 * @brief send_systray_message - request a systray icon for Widget_t 604 * \n currently not working 605 * @param *w - pointer to the Widget_t to send the notify 606 * @return void 607 */ 608 609 void send_systray_message(Widget_t *w); 610 611 /** 612 * @brief expose_widgets - send a expose event (EXPOSE) to a Widget_t 613 * @param w - the Widget_t to send the event to 614 * @return void 615 */ 616 617 void expose_widget(Widget_t *w); 618 619 /** 620 * @brief _key_mapping - modifier key's mapped to a integer value 621 * @param *dpy - pointer to the Display in use 622 * @param *xkey - the key to map 623 * @return int - value (1-10) or 0 when not mapped 624 */ 625 626 int key_mapping(Display *dpy, XKeyEvent *xkey); 627 628 /** 629 * @brief strdecode - replace string in char* 630 * @param *target - the string to modify 631 * @param *needle - the string to replace 632 * @param *replacement - the replacement for the needle 633 * @return void 634 */ 635 636 void strdecode(char *target, const char *needle, const char *replacement); 637 638 /** 639 * @brief widget_set_dnd_aware - allow drag and drop for on Widget_t 640 * @param w - the Widget_t to send the event to 641 * @return void 642 */ 643 644 void widget_set_dnd_aware(Widget_t *w); 645 646 /** 647 * @brief widget_set_dnd_unaware - disable drag and drop for on Widget_t 648 * @param w - the Widget_t to send the event to 649 * @return void 650 */ 651 652 void widget_set_dnd_unaware(Widget_t *w); 653 654 /** 655 * @brief handle_drag_data - handle recived drag data 656 * @param w - the Widget_t recive the event 657 * @param event - the drag event contain the drop data 658 * @return void 659 */ 660 661 void handle_drag_data(Widget_t *w, XEvent* event); 662 663 /** 664 * @brief handle_drag_enter - handle drag event enter the Widget_t 665 * @param main - pointer to the Xputty *main struct running 666 * @param event - the drag event contain the drop data 667 * @return void 668 */ 669 670 void handle_dnd_enter(Xputty *main, XEvent* event); 671 672 /** 673 * @brief send_dnd_finished_event - notify the drag sender that the event is handled 674 * @param w - the Widget_t handled the event 675 * @param event - the drag event contain the drop data 676 * @return void 677 */ 678 679 void send_dnd_finished_event(Widget_t *w, XEvent* event); 680 681 /** 682 * @brief send_dnd_status_event - notify the drag sender that prepared to recive the event 683 * @param w - the Widget_t to recive the event 684 * @param event - the drag event contain the drop data 685 * @return void 686 */ 687 688 void send_dnd_status_event(Widget_t *w, XEvent* event); 689 690 /** 691 * @brief copy_to_clipboard - send textbuffer to clipboard 692 * @param w - the Widget_t to send the event 693 * @param text - the text buffer to send to clipboard 694 * @param size - the size of the buffer to send 695 * @return void 696 */ 697 698 void copy_to_clipboard(Widget_t *w, char* text, int size); 699 700 /** 701 * @brief send_to_clipboard - send textbuffer to clipboard on request 702 * @param w - the Widget_t to send the event 703 * @param event - the event contain the request 704 * @return void 705 */ 706 707 void send_to_clipboard(Widget_t *w, XEvent* event); 708 709 710 /** 711 * @brief have_paste - check if clipboard contain a textbuffer 712 * @param w - the Widget_t to send the request 713 * @return void 714 */ 715 716 int have_paste(Widget_t *w); 717 718 /** 719 * @brief request_paste_from_clipboard - request textbuffer from clipboard 720 * @param w - the Widget_t to send the request 721 * @return void 722 */ 723 724 void request_paste_from_clipboard(Widget_t *w); 725 726 /** 727 * @brief receive_paste_from_clipboard - receive textbuffer from clipboard 728 * @param w - the Widget_t which requested the buffer 729 * @param event - the event contain the request 730 * @return void 731 */ 732 733 void receive_paste_from_clipboard(Widget_t *w, XEvent* event); 734 735 #ifdef __cplusplus 736 } 737 #endif 738 739 #endif //XWIDGET_H 740