21#include <X11/extensions/shape.h>
22#include <X11/cursorfont.h>
24#include <winpr/assert.h>
25#include <winpr/cast.h>
27#include "xf_floatbar.h"
29#include "resource/close.xbm"
30#include "resource/lock.xbm"
31#include "resource/unlock.xbm"
32#include "resource/minimize.xbm"
33#include "resource/restore.xbm"
35#include <freerdp/log.h>
36#define TAG CLIENT_TAG("x11")
38#define FLOATBAR_HEIGHT 26
39#define FLOATBAR_DEFAULT_WIDTH 576
40#define FLOATBAR_MIN_WIDTH 200
41#define FLOATBAR_BORDER 24
42#define FLOATBAR_BUTTON_WIDTH 24
43#define FLOATBAR_COLOR_BACKGROUND "RGB:31/6c/a9"
44#define FLOATBAR_COLOR_BORDER "RGB:75/9a/c8"
45#define FLOATBAR_COLOR_FOREGROUND "RGB:FF/FF/FF"
47#define XF_FLOATBAR_MODE_NONE 0
48#define XF_FLOATBAR_MODE_DRAGGING 1
49#define XF_FLOATBAR_MODE_RESIZE_LEFT 2
50#define XF_FLOATBAR_MODE_RESIZE_RIGHT 3
52#define XF_FLOATBAR_BUTTON_CLOSE 1
53#define XF_FLOATBAR_BUTTON_RESTORE 2
54#define XF_FLOATBAR_BUTTON_MINIMIZE 3
55#define XF_FLOATBAR_BUTTON_LOCKED 4
57typedef BOOL (*OnClick)(xfFloatbar*);
77 int last_motion_x_root;
78 int last_motion_y_root;
80 xfFloatbarButton* buttons[4];
91static xfFloatbarButton* xf_floatbar_new_button(xfFloatbar* floatbar,
int type);
93static BOOL xf_floatbar_button_onclick_close(xfFloatbar* floatbar)
98 return freerdp_abort_connect_context(&floatbar->xfc->common.context);
101static BOOL xf_floatbar_button_onclick_minimize(xfFloatbar* floatbar)
103 xfContext* xfc = NULL;
105 if (!floatbar || !floatbar->xfc)
109 xf_SetWindowMinimized(xfc, xfc->window);
113static BOOL xf_floatbar_button_onclick_restore(xfFloatbar* floatbar)
118 xf_toggle_fullscreen(floatbar->xfc);
122static BOOL xf_floatbar_button_onclick_locked(xfFloatbar* floatbar)
127 floatbar->locked = (floatbar->locked) ? FALSE : TRUE;
128 return xf_floatbar_hide_and_show(floatbar);
131BOOL xf_floatbar_set_root_y(xfFloatbar* floatbar,
int y)
136 floatbar->last_motion_y_root = y;
140BOOL xf_floatbar_hide_and_show(xfFloatbar* floatbar)
142 xfContext* xfc = NULL;
144 if (!floatbar || !floatbar->xfc)
147 if (!floatbar->created)
152 WINPR_ASSERT(xfc->display);
154 if (!floatbar->locked)
156 if ((floatbar->mode == XF_FLOATBAR_MODE_NONE) && (floatbar->last_motion_y_root > 10) &&
157 (floatbar->y > (FLOATBAR_HEIGHT * -1)))
159 floatbar->y = floatbar->y - 1;
160 LogDynAndXMoveWindow(xfc->log, xfc->display, floatbar->handle, floatbar->x,
163 else if (floatbar->y < 0 && (floatbar->last_motion_y_root < 10))
165 floatbar->y = floatbar->y + 1;
166 LogDynAndXMoveWindow(xfc->log, xfc->display, floatbar->handle, floatbar->x,
174static BOOL create_floatbar(xfFloatbar* floatbar)
176 xfContext* xfc = NULL;
178 XWindowAttributes attr = { 0 };
180 WINPR_ASSERT(floatbar);
181 if (floatbar->created)
186 WINPR_ASSERT(xfc->display);
188 status = XGetWindowAttributes(xfc->display, floatbar->root_window, &attr);
191 WLog_WARN(TAG,
"XGetWindowAttributes failed");
194 floatbar->x = attr.x + attr.width / 2 - FLOATBAR_DEFAULT_WIDTH / 2;
197 if (((floatbar->flags & 0x0004) == 0) && !floatbar->locked)
198 floatbar->y = -FLOATBAR_HEIGHT + 1;
200 floatbar->handle = LogDynAndXCreateWindow(
201 xfc->log, xfc->display, floatbar->root_window, floatbar->x, 0, FLOATBAR_DEFAULT_WIDTH,
202 FLOATBAR_HEIGHT, 0, CopyFromParent, InputOutput, CopyFromParent, 0, NULL);
203 floatbar->width = FLOATBAR_DEFAULT_WIDTH;
204 floatbar->height = FLOATBAR_HEIGHT;
205 floatbar->mode = XF_FLOATBAR_MODE_NONE;
206 floatbar->buttons[0] = xf_floatbar_new_button(floatbar, XF_FLOATBAR_BUTTON_CLOSE);
207 floatbar->buttons[1] = xf_floatbar_new_button(floatbar, XF_FLOATBAR_BUTTON_RESTORE);
208 floatbar->buttons[2] = xf_floatbar_new_button(floatbar, XF_FLOATBAR_BUTTON_MINIMIZE);
209 floatbar->buttons[3] = xf_floatbar_new_button(floatbar, XF_FLOATBAR_BUTTON_LOCKED);
210 XSelectInput(xfc->display, floatbar->handle,
211 ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
212 FocusChangeMask | LeaveWindowMask | EnterWindowMask | StructureNotifyMask |
214 floatbar->created = TRUE;
218BOOL xf_floatbar_toggle_fullscreen(xfFloatbar* floatbar,
bool fullscreen)
221 bool visible = False;
222 xfContext* xfc = NULL;
224 if (!floatbar || !floatbar->xfc)
228 WINPR_ASSERT(xfc->display);
231 if (floatbar->flags & 0x0001)
234 visible |= ((floatbar->flags & 0x0010) != 0) && fullscreen;
236 visible |= ((floatbar->flags & 0x0020) != 0) && !fullscreen;
241 if (!create_floatbar(floatbar))
244 LogDynAndXMapWindow(xfc->log, xfc->display, floatbar->handle);
245 size = ARRAYSIZE(floatbar->buttons);
247 for (
int i = 0; i < size; i++)
249 xfFloatbarButton* button = floatbar->buttons[i];
250 LogDynAndXMapWindow(xfc->log, xfc->display, button->handle);
254 if (((floatbar->flags & 0x0004) == 0) && !floatbar->locked)
255 floatbar->y = -FLOATBAR_HEIGHT + 1;
257 xf_floatbar_hide_and_show(floatbar);
259 else if (floatbar->created)
261 XUnmapSubwindows(xfc->display, floatbar->handle);
262 LogDynAndXUnmapWindow(xfc->log, xfc->display, floatbar->handle);
268xfFloatbarButton* xf_floatbar_new_button(xfFloatbar* floatbar,
int type)
270 xfFloatbarButton* button = NULL;
272 WINPR_ASSERT(floatbar);
273 WINPR_ASSERT(floatbar->xfc);
274 WINPR_ASSERT(floatbar->xfc->display);
275 WINPR_ASSERT(floatbar->handle);
277 button = (xfFloatbarButton*)calloc(1,
sizeof(xfFloatbarButton));
282 case XF_FLOATBAR_BUTTON_CLOSE:
283 button->x = floatbar->width - FLOATBAR_BORDER - FLOATBAR_BUTTON_WIDTH * type;
284 button->onclick = xf_floatbar_button_onclick_close;
287 case XF_FLOATBAR_BUTTON_RESTORE:
288 button->x = floatbar->width - FLOATBAR_BORDER - FLOATBAR_BUTTON_WIDTH * type;
289 button->onclick = xf_floatbar_button_onclick_restore;
292 case XF_FLOATBAR_BUTTON_MINIMIZE:
293 button->x = floatbar->width - FLOATBAR_BORDER - FLOATBAR_BUTTON_WIDTH * type;
294 button->onclick = xf_floatbar_button_onclick_minimize;
297 case XF_FLOATBAR_BUTTON_LOCKED:
298 button->x = FLOATBAR_BORDER;
299 button->onclick = xf_floatbar_button_onclick_locked;
307 button->focus = FALSE;
309 LogDynAndXCreateWindow(floatbar->xfc->log, floatbar->xfc->display, floatbar->handle,
310 button->x, 0, FLOATBAR_BUTTON_WIDTH, FLOATBAR_BUTTON_WIDTH, 0,
311 CopyFromParent, InputOutput, CopyFromParent, 0, NULL);
312 XSelectInput(floatbar->xfc->display, button->handle,
313 ExposureMask | ButtonPressMask | ButtonReleaseMask | FocusChangeMask |
314 LeaveWindowMask | EnterWindowMask | StructureNotifyMask);
318xfFloatbar* xf_floatbar_new(xfContext* xfc, Window window,
const char* name, DWORD flags)
321 WINPR_ASSERT(xfc->display);
325 if ((flags & 0x0001) == 0)
335 xfFloatbar* floatbar = (xfFloatbar*)calloc(1,
sizeof(xfFloatbar));
340 floatbar->title = _strdup(name);
342 if (!floatbar->title)
345 floatbar->root_window = window;
346 floatbar->flags = flags;
348 floatbar->locked = (flags & 0x0002) != 0 ? TRUE : FALSE;
349 xf_floatbar_toggle_fullscreen(floatbar, FALSE);
352 char** missingList = NULL;
353 int missingCount = 0;
354 char* defString = NULL;
355 floatbar->fontSet = XCreateFontSet(floatbar->xfc->display,
"-*-*-*-*-*-*-*-*-*-*-*-*-*-*",
356 &missingList, &missingCount, &defString);
358 if (floatbar->fontSet == NULL)
360 WLog_ERR(TAG,
"Failed to create fontset");
362 XFreeStringList(missingList);
366 WINPR_PRAGMA_DIAG_PUSH
367 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
368 xf_floatbar_free(floatbar);
369 WINPR_PRAGMA_DIAG_POP
373static unsigned long xf_floatbar_get_color(xfFloatbar* floatbar,
char* rgb_value)
377 WINPR_ASSERT(floatbar);
378 WINPR_ASSERT(floatbar->xfc);
380 Display* display = floatbar->xfc->display;
381 WINPR_ASSERT(display);
383 Colormap cmap = DefaultColormap(display, XDefaultScreen(display));
384 XParseColor(display, cmap, rgb_value, &color);
385 XAllocColor(display, cmap, &color);
389static void xf_floatbar_event_expose(xfFloatbar* floatbar)
394 XPoint shape[5] = { 0 };
395 XPoint border[5] = { 0 };
397 WINPR_ASSERT(floatbar);
398 WINPR_ASSERT(floatbar->xfc);
400 Display* display = floatbar->xfc->display;
401 WINPR_ASSERT(display);
404 pmap = LogDynAndXCreatePixmap(floatbar->xfc->log, display, floatbar->handle,
405 WINPR_ASSERTING_INT_CAST(uint32_t, floatbar->width),
406 WINPR_ASSERTING_INT_CAST(uint32_t, floatbar->height), 1);
407 gc = LogDynAndXCreateGC(floatbar->xfc->log, display, floatbar->handle, 0, 0);
408 shape_gc = LogDynAndXCreateGC(floatbar->xfc->log, display, pmap, 0, 0);
412 shape[1].x = WINPR_ASSERTING_INT_CAST(
short, floatbar->width);
414 shape[2].x = WINPR_ASSERTING_INT_CAST(
short, shape[1].x - FLOATBAR_BORDER);
415 shape[2].y = FLOATBAR_HEIGHT;
416 shape[3].x = WINPR_ASSERTING_INT_CAST(
short, shape[0].x + FLOATBAR_BORDER);
417 shape[3].y = FLOATBAR_HEIGHT;
418 shape[4].x = shape[0].x;
419 shape[4].y = shape[0].y;
421 border[0].x = shape[0].x;
422 border[0].y = WINPR_ASSERTING_INT_CAST(
short, shape[0].y - 1);
423 border[1].x = WINPR_ASSERTING_INT_CAST(
short, shape[1].x - 1);
424 border[1].y = WINPR_ASSERTING_INT_CAST(
short, shape[1].y - 1);
425 border[2].x = shape[2].x;
426 border[2].y = WINPR_ASSERTING_INT_CAST(
short, shape[2].y - 1);
427 border[3].x = WINPR_ASSERTING_INT_CAST(
short, shape[3].x - 1);
428 border[3].y = WINPR_ASSERTING_INT_CAST(
short, shape[3].y - 1);
429 border[4].x = border[0].x;
430 border[4].y = border[0].y;
432 LogDynAndXSetForeground(floatbar->xfc->log, display, shape_gc, 0);
433 LogDynAndXFillRectangle(floatbar->xfc->log, display, pmap, shape_gc, 0, 0,
434 WINPR_ASSERTING_INT_CAST(uint32_t, floatbar->width),
435 WINPR_ASSERTING_INT_CAST(uint32_t, floatbar->height));
437 LogDynAndXSetForeground(floatbar->xfc->log, display, shape_gc, 1);
438 XFillPolygon(display, pmap, shape_gc, shape, 5, 0, CoordModeOrigin);
439 XShapeCombineMask(display, floatbar->handle, ShapeBounding, 0, 0, pmap, ShapeSet);
441 LogDynAndXSetForeground(floatbar->xfc->log, display, gc,
442 xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_BACKGROUND));
443 XFillPolygon(display, floatbar->handle, gc, shape, 4, 0, CoordModeOrigin);
445 LogDynAndXSetForeground(floatbar->xfc->log, display, gc,
446 xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_BORDER));
447 XDrawLines(display, floatbar->handle, gc, border, 5, CoordModeOrigin);
449 const size_t len = strnlen(floatbar->title, MAX_PATH);
450 LogDynAndXSetForeground(floatbar->xfc->log, display, gc,
451 xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_FOREGROUND));
453 WINPR_ASSERT(len <= INT32_MAX / 2);
454 const int fx = floatbar->width / 2 - (int)len * 2;
455 if (floatbar->fontSet != NULL)
457 XmbDrawString(display, floatbar->handle, floatbar->fontSet, gc, fx, 15, floatbar->title,
462 XDrawString(display, floatbar->handle, gc, fx, 15, floatbar->title, (
int)len);
464 LogDynAndXFreeGC(floatbar->xfc->log, display, gc);
465 LogDynAndXFreeGC(floatbar->xfc->log, display, shape_gc);
468static xfFloatbarButton* xf_floatbar_get_button(xfFloatbar* floatbar, Window window)
470 WINPR_ASSERT(floatbar);
471 const size_t size = ARRAYSIZE(floatbar->buttons);
473 for (
size_t i = 0; i < size; i++)
475 xfFloatbarButton* button = floatbar->buttons[i];
476 if (button->handle == window)
485static void xf_floatbar_button_update_positon(xfFloatbar* floatbar)
487 xfFloatbarButton* button = NULL;
488 WINPR_ASSERT(floatbar);
489 xfContext* xfc = floatbar->xfc;
490 const size_t size = ARRAYSIZE(floatbar->buttons);
492 for (
size_t i = 0; i < size; i++)
494 button = floatbar->buttons[i];
496 switch (button->type)
498 case XF_FLOATBAR_BUTTON_CLOSE:
500 floatbar->width - FLOATBAR_BORDER - FLOATBAR_BUTTON_WIDTH * button->type;
503 case XF_FLOATBAR_BUTTON_RESTORE:
505 floatbar->width - FLOATBAR_BORDER - FLOATBAR_BUTTON_WIDTH * button->type;
508 case XF_FLOATBAR_BUTTON_MINIMIZE:
510 floatbar->width - FLOATBAR_BORDER - FLOATBAR_BUTTON_WIDTH * button->type;
518 WINPR_ASSERT(xfc->display);
519 LogDynAndXMoveWindow(xfc->log, xfc->display, button->handle, button->x, button->y);
520 xf_floatbar_event_expose(floatbar);
524static void xf_floatbar_button_event_expose(xfFloatbar* floatbar, Window window)
526 xfFloatbarButton* button = xf_floatbar_get_button(floatbar, window);
527 static unsigned char* bits;
530 xfContext* xfc = floatbar->xfc;
536 WINPR_ASSERT(xfc->display);
537 WINPR_ASSERT(xfc->window);
539 gc = LogDynAndXCreateGC(xfc->log, xfc->display, button->handle, 0, 0);
540 floatbar = xfc->window->floatbar;
541 WINPR_ASSERT(floatbar);
543 switch (button->type)
545 case XF_FLOATBAR_BUTTON_CLOSE:
549 case XF_FLOATBAR_BUTTON_RESTORE:
553 case XF_FLOATBAR_BUTTON_MINIMIZE:
554 bits = minimize_bits;
557 case XF_FLOATBAR_BUTTON_LOCKED:
558 if (floatbar->locked)
569 pattern = XCreateBitmapFromData(xfc->display, button->handle, (
const char*)bits,
570 FLOATBAR_BUTTON_WIDTH, FLOATBAR_BUTTON_WIDTH);
572 if (!(button->focus))
573 LogDynAndXSetForeground(floatbar->xfc->log, xfc->display, gc,
574 xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_BACKGROUND));
576 LogDynAndXSetForeground(floatbar->xfc->log, xfc->display, gc,
577 xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_BORDER));
579 LogDynAndXSetBackground(xfc->log, xfc->display, gc,
580 xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_FOREGROUND));
581 XCopyPlane(xfc->display, pattern, button->handle, gc, 0, 0, FLOATBAR_BUTTON_WIDTH,
582 FLOATBAR_BUTTON_WIDTH, 0, 0, 1);
583 LogDynAndXFreePixmap(xfc->log, xfc->display, pattern);
584 LogDynAndXFreeGC(xfc->log, xfc->display, gc);
587static void xf_floatbar_button_event_buttonpress(xfFloatbar* floatbar,
const XButtonEvent* event)
590 xfFloatbarButton* button = xf_floatbar_get_button(floatbar, event->window);
593 button->clicked = TRUE;
596static void xf_floatbar_button_event_buttonrelease(xfFloatbar* floatbar,
const XButtonEvent* event)
598 xfFloatbarButton* button = NULL;
600 WINPR_ASSERT(floatbar);
603 button = xf_floatbar_get_button(floatbar, event->window);
608 button->onclick(floatbar);
609 button->clicked = FALSE;
613static void xf_floatbar_event_buttonpress(xfFloatbar* floatbar,
const XButtonEvent* event)
615 WINPR_ASSERT(floatbar);
618 switch (event->button)
621 if (event->x <= FLOATBAR_BORDER)
622 floatbar->mode = XF_FLOATBAR_MODE_RESIZE_LEFT;
623 else if (event->x >= (floatbar->width - FLOATBAR_BORDER))
624 floatbar->mode = XF_FLOATBAR_MODE_RESIZE_RIGHT;
626 floatbar->mode = XF_FLOATBAR_MODE_DRAGGING;
635static void xf_floatbar_event_buttonrelease(xfFloatbar* floatbar,
const XButtonEvent* event)
637 WINPR_ASSERT(floatbar);
640 switch (event->button)
643 floatbar->mode = XF_FLOATBAR_MODE_NONE;
651static void xf_floatbar_resize(xfFloatbar* floatbar,
const XMotionEvent* event)
657 WINPR_ASSERT(floatbar);
660 xfContext* xfc = floatbar->xfc;
662 WINPR_ASSERT(xfc->display);
665 movement =
event->x_root - floatbar->last_motion_x_root;
668 if (floatbar->mode == XF_FLOATBAR_MODE_RESIZE_LEFT)
670 x = floatbar->x + movement;
671 width = floatbar->width + movement * -1;
676 width = floatbar->width + movement;
680 if (FLOATBAR_MIN_WIDTH < width)
682 LogDynAndXMoveResizeWindow(xfc->log, xfc->display, floatbar->handle, x, 0,
683 WINPR_ASSERTING_INT_CAST(uint32_t, width),
684 WINPR_ASSERTING_INT_CAST(uint32_t, floatbar->height));
686 floatbar->width = width;
690static void xf_floatbar_dragging(xfFloatbar* floatbar,
const XMotionEvent* event)
695 WINPR_ASSERT(floatbar);
697 xfContext* xfc = floatbar->xfc;
699 WINPR_ASSERT(xfc->window);
700 WINPR_ASSERT(xfc->display);
703 movement =
event->x_root - floatbar->last_motion_x_root;
704 x = floatbar->x + movement;
707 if (x < 0 || (x + floatbar->width) > xfc->window->width)
711 LogDynAndXMoveWindow(xfc->log, xfc->display, floatbar->handle, x, 0);
713 floatbar->last_motion_x_root = floatbar->last_motion_x_root + movement;
717static void xf_floatbar_event_motionnotify(xfFloatbar* floatbar,
const XMotionEvent* event)
722 WINPR_ASSERT(floatbar);
725 xfContext* xfc = floatbar->xfc;
727 WINPR_ASSERT(xfc->display);
729 mode = floatbar->mode;
730 cursor = XCreateFontCursor(xfc->display, XC_arrow);
732 if ((event->state & Button1Mask) && (mode > XF_FLOATBAR_MODE_DRAGGING))
734 xf_floatbar_resize(floatbar, event);
736 else if ((event->state & Button1Mask) && (mode == XF_FLOATBAR_MODE_DRAGGING))
738 xf_floatbar_dragging(floatbar, event);
742 if (event->x <= FLOATBAR_BORDER || event->x >= floatbar->width - FLOATBAR_BORDER)
743 cursor = XCreateFontCursor(xfc->display, XC_sb_h_double_arrow);
746 XDefineCursor(xfc->display, xfc->window->handle, cursor);
747 XFreeCursor(xfc->display, cursor);
748 floatbar->last_motion_x_root =
event->x_root;
751static void xf_floatbar_button_event_focusin(xfFloatbar* floatbar,
const XAnyEvent* event)
753 xfFloatbarButton* button = NULL;
755 WINPR_ASSERT(floatbar);
758 button = xf_floatbar_get_button(floatbar, event->window);
762 button->focus = TRUE;
763 xf_floatbar_button_event_expose(floatbar, event->window);
767static void xf_floatbar_button_event_focusout(xfFloatbar* floatbar,
const XAnyEvent* event)
769 xfFloatbarButton* button = NULL;
771 WINPR_ASSERT(floatbar);
774 button = xf_floatbar_get_button(floatbar, event->window);
778 button->focus = FALSE;
779 xf_floatbar_button_event_expose(floatbar, event->window);
783static void xf_floatbar_event_focusout(xfFloatbar* floatbar)
785 WINPR_ASSERT(floatbar);
786 xfContext* xfc = floatbar->xfc;
791 WINPR_ASSERT(xfc->window);
792 WINPR_ASSERT(xfc->pointer);
793 XDefineCursor(xfc->display, xfc->window->handle, xfc->pointer->cursor);
797BOOL xf_floatbar_check_event(xfFloatbar* floatbar,
const XEvent* event)
799 if (!floatbar || !floatbar->xfc || !event)
802 if (!floatbar->created)
805 if (event->xany.window == floatbar->handle)
808 size_t size = ARRAYSIZE(floatbar->buttons);
810 for (
size_t i = 0; i < size; i++)
812 const xfFloatbarButton* button = floatbar->buttons[i];
814 if (event->xany.window == button->handle)
821BOOL xf_floatbar_event_process(xfFloatbar* floatbar,
const XEvent* event)
823 if (!floatbar || !floatbar->xfc || !event)
826 if (!floatbar->created)
832 if (event->xexpose.window == floatbar->handle)
833 xf_floatbar_event_expose(floatbar);
835 xf_floatbar_button_event_expose(floatbar, event->xexpose.window);
840 xf_floatbar_event_motionnotify(floatbar, &event->xmotion);
844 if (event->xany.window == floatbar->handle)
845 xf_floatbar_event_buttonpress(floatbar, &event->xbutton);
847 xf_floatbar_button_event_buttonpress(floatbar, &event->xbutton);
852 if (event->xany.window == floatbar->handle)
853 xf_floatbar_event_buttonrelease(floatbar, &event->xbutton);
855 xf_floatbar_button_event_buttonrelease(floatbar, &event->xbutton);
861 if (event->xany.window != floatbar->handle)
862 xf_floatbar_button_event_focusin(floatbar, &event->xany);
868 if (event->xany.window == floatbar->handle)
869 xf_floatbar_event_focusout(floatbar);
871 xf_floatbar_button_event_focusout(floatbar, &event->xany);
875 case ConfigureNotify:
876 if (event->xany.window == floatbar->handle)
877 xf_floatbar_button_update_positon(floatbar);
882 if (event->xany.window == floatbar->handle)
883 xf_floatbar_button_update_positon(floatbar);
891 return floatbar->handle ==
event->xany.window;
894static void xf_floatbar_button_free(xfContext* xfc, xfFloatbarButton* button)
902 WINPR_ASSERT(xfc->display);
903 LogDynAndXUnmapWindow(xfc->log, xfc->display, button->handle);
904 LogDynAndXDestroyWindow(xfc->log, xfc->display, button->handle);
910void xf_floatbar_free(xfFloatbar* floatbar)
913 xfContext* xfc = NULL;
918 free(floatbar->title);
922 size = ARRAYSIZE(floatbar->buttons);
924 for (
size_t i = 0; i < size; i++)
926 xf_floatbar_button_free(xfc, floatbar->buttons[i]);
927 floatbar->buttons[i] = NULL;
930 if (floatbar->handle)
932 WINPR_ASSERT(xfc->display);
933 LogDynAndXUnmapWindow(xfc->log, xfc->display, floatbar->handle);
934 LogDynAndXDestroyWindow(xfc->log, xfc->display, floatbar->handle);
940BOOL xf_floatbar_is_locked(xfFloatbar* floatbar)
944 return floatbar->mode != XF_FLOATBAR_MODE_NONE;
947BOOL xf_floatbar_is_window(xfFloatbar* floatbar, Window window)
951 return floatbar->handle == window;
954BOOL xfc_is_floatbar_window(xfContext* xfc, Window window)
956 if (!xfc || !xfc->window)
958 return xf_floatbar_is_window(xfc->window->floatbar, window);