mirror of
https://github.com/FreeRDP/FreeRDP.git
synced 2025-06-03 00:00:20 +00:00
Added assertions to floatbar
This commit is contained in:
parent
54a1e4ea7e
commit
8671339b12
@ -155,6 +155,8 @@ BOOL xf_floatbar_hide_and_show(xfFloatbar* floatbar)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
xfc = floatbar->xfc;
|
xfc = floatbar->xfc;
|
||||||
|
WINPR_ASSERT(xfc);
|
||||||
|
WINPR_ASSERT(xfc->display);
|
||||||
|
|
||||||
if (!floatbar->locked)
|
if (!floatbar->locked)
|
||||||
{
|
{
|
||||||
@ -178,12 +180,16 @@ static BOOL create_floatbar(xfFloatbar* floatbar)
|
|||||||
{
|
{
|
||||||
xfContext* xfc;
|
xfContext* xfc;
|
||||||
Status status;
|
Status status;
|
||||||
XWindowAttributes attr;
|
XWindowAttributes attr = { 0 };
|
||||||
|
|
||||||
|
WINPR_ASSERT(floatbar);
|
||||||
if (floatbar->created)
|
if (floatbar->created)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
xfc = floatbar->xfc;
|
xfc = floatbar->xfc;
|
||||||
|
WINPR_ASSERT(xfc);
|
||||||
|
WINPR_ASSERT(xfc->display);
|
||||||
|
|
||||||
status = XGetWindowAttributes(xfc->display, floatbar->root_window, &attr);
|
status = XGetWindowAttributes(xfc->display, floatbar->root_window, &attr);
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
{
|
{
|
||||||
@ -224,6 +230,7 @@ BOOL xf_floatbar_toggle_fullscreen(xfFloatbar* floatbar, bool fullscreen)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
xfc = floatbar->xfc;
|
xfc = floatbar->xfc;
|
||||||
|
WINPR_ASSERT(xfc->display);
|
||||||
|
|
||||||
/* Only visible if enabled */
|
/* Only visible if enabled */
|
||||||
if (floatbar->flags & 0x0001)
|
if (floatbar->flags & 0x0001)
|
||||||
@ -244,7 +251,8 @@ BOOL xf_floatbar_toggle_fullscreen(xfFloatbar* floatbar, bool fullscreen)
|
|||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
XMapWindow(xfc->display, floatbar->buttons[i]->handle);
|
xfFloatbarButton* button = floatbar->buttons[i];
|
||||||
|
XMapWindow(xfc->display, button->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If default is hidden (and not sticky) don't show on fullscreen state changes */
|
/* If default is hidden (and not sticky) don't show on fullscreen state changes */
|
||||||
@ -265,6 +273,12 @@ BOOL xf_floatbar_toggle_fullscreen(xfFloatbar* floatbar, bool fullscreen)
|
|||||||
xfFloatbarButton* xf_floatbar_new_button(xfFloatbar* floatbar, int type)
|
xfFloatbarButton* xf_floatbar_new_button(xfFloatbar* floatbar, int type)
|
||||||
{
|
{
|
||||||
xfFloatbarButton* button;
|
xfFloatbarButton* button;
|
||||||
|
|
||||||
|
WINPR_ASSERT(floatbar);
|
||||||
|
WINPR_ASSERT(floatbar->xfc);
|
||||||
|
WINPR_ASSERT(floatbar->xfc->display);
|
||||||
|
WINPR_ASSERT(floatbar->xfc->window);
|
||||||
|
|
||||||
button = (xfFloatbarButton*)calloc(1, sizeof(xfFloatbarButton));
|
button = (xfFloatbarButton*)calloc(1, sizeof(xfFloatbarButton));
|
||||||
button->type = type;
|
button->type = type;
|
||||||
|
|
||||||
@ -309,6 +323,10 @@ xfFloatbar* xf_floatbar_new(xfContext* xfc, Window window, const char* name, DWO
|
|||||||
{
|
{
|
||||||
xfFloatbar* floatbar;
|
xfFloatbar* floatbar;
|
||||||
|
|
||||||
|
WINPR_ASSERT(xfc);
|
||||||
|
WINPR_ASSERT(xfc->display);
|
||||||
|
WINPR_ASSERT(name);
|
||||||
|
|
||||||
/* Floatbar not enabled */
|
/* Floatbar not enabled */
|
||||||
if ((flags & 0x0001) == 0)
|
if ((flags & 0x0001) == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -353,10 +371,15 @@ fail:
|
|||||||
|
|
||||||
static unsigned long xf_floatbar_get_color(xfFloatbar* floatbar, char* rgb_value)
|
static unsigned long xf_floatbar_get_color(xfFloatbar* floatbar, char* rgb_value)
|
||||||
{
|
{
|
||||||
Colormap cmap;
|
|
||||||
XColor color;
|
XColor color;
|
||||||
|
|
||||||
|
WINPR_ASSERT(floatbar);
|
||||||
|
WINPR_ASSERT(floatbar->xfc);
|
||||||
|
|
||||||
Display* display = floatbar->xfc->display;
|
Display* display = floatbar->xfc->display;
|
||||||
cmap = DefaultColormap(display, XDefaultScreen(display));
|
WINPR_ASSERT(display);
|
||||||
|
|
||||||
|
Colormap cmap = DefaultColormap(display, XDefaultScreen(display));
|
||||||
XParseColor(display, cmap, rgb_value, &color);
|
XParseColor(display, cmap, rgb_value, &color);
|
||||||
XAllocColor(display, cmap, &color);
|
XAllocColor(display, cmap, &color);
|
||||||
return color.pixel;
|
return color.pixel;
|
||||||
@ -366,9 +389,14 @@ static void xf_floatbar_event_expose(xfFloatbar* floatbar)
|
|||||||
{
|
{
|
||||||
GC gc, shape_gc;
|
GC gc, shape_gc;
|
||||||
Pixmap pmap;
|
Pixmap pmap;
|
||||||
XPoint shape[5], border[5];
|
XPoint shape[5] = { 0 }, border[5] = { 0 };
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
WINPR_ASSERT(floatbar);
|
||||||
|
WINPR_ASSERT(floatbar->xfc);
|
||||||
|
|
||||||
Display* display = floatbar->xfc->display;
|
Display* display = floatbar->xfc->display;
|
||||||
|
WINPR_ASSERT(display);
|
||||||
|
|
||||||
/* create the pixmap that we'll use for shaping the window */
|
/* create the pixmap that we'll use for shaping the window */
|
||||||
pmap = XCreatePixmap(display, floatbar->handle, floatbar->width, floatbar->height, 1);
|
pmap = XCreatePixmap(display, floatbar->handle, floatbar->width, floatbar->height, 1);
|
||||||
@ -428,14 +456,15 @@ static void xf_floatbar_event_expose(xfFloatbar* floatbar)
|
|||||||
|
|
||||||
static xfFloatbarButton* xf_floatbar_get_button(xfFloatbar* floatbar, Window window)
|
static xfFloatbarButton* xf_floatbar_get_button(xfFloatbar* floatbar, Window window)
|
||||||
{
|
{
|
||||||
int i, size;
|
WINPR_ASSERT(floatbar);
|
||||||
size = ARRAYSIZE(floatbar->buttons);
|
const size_t size = ARRAYSIZE(floatbar->buttons);
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (size_t i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
if (floatbar->buttons[i]->handle == window)
|
xfFloatbarButton* button = floatbar->buttons[i];
|
||||||
|
if (button->handle == window)
|
||||||
{
|
{
|
||||||
return floatbar->buttons[i];
|
return button;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,11 +474,11 @@ static xfFloatbarButton* xf_floatbar_get_button(xfFloatbar* floatbar, Window win
|
|||||||
static void xf_floatbar_button_update_positon(xfFloatbar* floatbar)
|
static void xf_floatbar_button_update_positon(xfFloatbar* floatbar)
|
||||||
{
|
{
|
||||||
xfFloatbarButton* button;
|
xfFloatbarButton* button;
|
||||||
int i, size;
|
WINPR_ASSERT(floatbar);
|
||||||
xfContext* xfc = floatbar->xfc;
|
xfContext* xfc = floatbar->xfc;
|
||||||
size = ARRAYSIZE(floatbar->buttons);
|
const size_t size = ARRAYSIZE(floatbar->buttons);
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (size_t i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
button = floatbar->buttons[i];
|
button = floatbar->buttons[i];
|
||||||
|
|
||||||
@ -474,6 +503,8 @@ static void xf_floatbar_button_update_positon(xfFloatbar* floatbar)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WINPR_ASSERT(xfc);
|
||||||
|
WINPR_ASSERT(xfc->display);
|
||||||
XMoveWindow(xfc->display, button->handle, button->x, button->y);
|
XMoveWindow(xfc->display, button->handle, button->x, button->y);
|
||||||
xf_floatbar_event_expose(floatbar);
|
xf_floatbar_event_expose(floatbar);
|
||||||
}
|
}
|
||||||
@ -490,8 +521,13 @@ static void xf_floatbar_button_event_expose(xfFloatbar* floatbar, Window window)
|
|||||||
if (!button)
|
if (!button)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
WINPR_ASSERT(xfc);
|
||||||
|
WINPR_ASSERT(xfc->display);
|
||||||
|
WINPR_ASSERT(xfc->window);
|
||||||
|
|
||||||
gc = XCreateGC(xfc->display, button->handle, 0, 0);
|
gc = XCreateGC(xfc->display, button->handle, 0, 0);
|
||||||
floatbar = xfc->window->floatbar;
|
floatbar = xfc->window->floatbar;
|
||||||
|
WINPR_ASSERT(floatbar);
|
||||||
|
|
||||||
switch (button->type)
|
switch (button->type)
|
||||||
{
|
{
|
||||||
@ -537,6 +573,7 @@ static void xf_floatbar_button_event_expose(xfFloatbar* floatbar, Window window)
|
|||||||
|
|
||||||
static void xf_floatbar_button_event_buttonpress(xfFloatbar* floatbar, const XButtonEvent* event)
|
static void xf_floatbar_button_event_buttonpress(xfFloatbar* floatbar, const XButtonEvent* event)
|
||||||
{
|
{
|
||||||
|
WINPR_ASSERT(event);
|
||||||
xfFloatbarButton* button = xf_floatbar_get_button(floatbar, event->window);
|
xfFloatbarButton* button = xf_floatbar_get_button(floatbar, event->window);
|
||||||
|
|
||||||
if (button)
|
if (button)
|
||||||
@ -546,6 +583,10 @@ static void xf_floatbar_button_event_buttonpress(xfFloatbar* floatbar, const XBu
|
|||||||
static void xf_floatbar_button_event_buttonrelease(xfFloatbar* floatbar, const XButtonEvent* event)
|
static void xf_floatbar_button_event_buttonrelease(xfFloatbar* floatbar, const XButtonEvent* event)
|
||||||
{
|
{
|
||||||
xfFloatbarButton* button;
|
xfFloatbarButton* button;
|
||||||
|
|
||||||
|
WINPR_ASSERT(floatbar);
|
||||||
|
WINPR_ASSERT(event);
|
||||||
|
|
||||||
button = xf_floatbar_get_button(floatbar, event->window);
|
button = xf_floatbar_get_button(floatbar, event->window);
|
||||||
|
|
||||||
if (button)
|
if (button)
|
||||||
@ -558,6 +599,9 @@ static void xf_floatbar_button_event_buttonrelease(xfFloatbar* floatbar, const X
|
|||||||
|
|
||||||
static void xf_floatbar_event_buttonpress(xfFloatbar* floatbar, const XButtonEvent* event)
|
static void xf_floatbar_event_buttonpress(xfFloatbar* floatbar, const XButtonEvent* event)
|
||||||
{
|
{
|
||||||
|
WINPR_ASSERT(floatbar);
|
||||||
|
WINPR_ASSERT(event);
|
||||||
|
|
||||||
switch (event->button)
|
switch (event->button)
|
||||||
{
|
{
|
||||||
case Button1:
|
case Button1:
|
||||||
@ -577,6 +621,9 @@ static void xf_floatbar_event_buttonpress(xfFloatbar* floatbar, const XButtonEve
|
|||||||
|
|
||||||
static void xf_floatbar_event_buttonrelease(xfFloatbar* floatbar, const XButtonEvent* event)
|
static void xf_floatbar_event_buttonrelease(xfFloatbar* floatbar, const XButtonEvent* event)
|
||||||
{
|
{
|
||||||
|
WINPR_ASSERT(floatbar);
|
||||||
|
WINPR_ASSERT(event);
|
||||||
|
|
||||||
switch (event->button)
|
switch (event->button)
|
||||||
{
|
{
|
||||||
case Button1:
|
case Button1:
|
||||||
@ -591,7 +638,14 @@ static void xf_floatbar_event_buttonrelease(xfFloatbar* floatbar, const XButtonE
|
|||||||
static void xf_floatbar_resize(xfFloatbar* floatbar, const XMotionEvent* event)
|
static void xf_floatbar_resize(xfFloatbar* floatbar, const XMotionEvent* event)
|
||||||
{
|
{
|
||||||
int x, width, movement;
|
int x, width, movement;
|
||||||
|
|
||||||
|
WINPR_ASSERT(floatbar);
|
||||||
|
WINPR_ASSERT(event);
|
||||||
|
|
||||||
xfContext* xfc = floatbar->xfc;
|
xfContext* xfc = floatbar->xfc;
|
||||||
|
WINPR_ASSERT(xfc);
|
||||||
|
WINPR_ASSERT(xfc->display);
|
||||||
|
|
||||||
/* calculate movement which happened on the root window */
|
/* calculate movement which happened on the root window */
|
||||||
movement = event->x_root - floatbar->last_motion_x_root;
|
movement = event->x_root - floatbar->last_motion_x_root;
|
||||||
|
|
||||||
@ -619,7 +673,14 @@ static void xf_floatbar_resize(xfFloatbar* floatbar, const XMotionEvent* event)
|
|||||||
static void xf_floatbar_dragging(xfFloatbar* floatbar, const XMotionEvent* event)
|
static void xf_floatbar_dragging(xfFloatbar* floatbar, const XMotionEvent* event)
|
||||||
{
|
{
|
||||||
int x, movement;
|
int x, movement;
|
||||||
|
|
||||||
|
WINPR_ASSERT(floatbar);
|
||||||
|
WINPR_ASSERT(event);
|
||||||
xfContext* xfc = floatbar->xfc;
|
xfContext* xfc = floatbar->xfc;
|
||||||
|
WINPR_ASSERT(xfc);
|
||||||
|
WINPR_ASSERT(xfc->window);
|
||||||
|
WINPR_ASSERT(xfc->display);
|
||||||
|
|
||||||
/* calculate movement and new x position */
|
/* calculate movement and new x position */
|
||||||
movement = event->x_root - floatbar->last_motion_x_root;
|
movement = event->x_root - floatbar->last_motion_x_root;
|
||||||
x = floatbar->x + movement;
|
x = floatbar->x + movement;
|
||||||
@ -639,7 +700,14 @@ static void xf_floatbar_event_motionnotify(xfFloatbar* floatbar, const XMotionEv
|
|||||||
{
|
{
|
||||||
int mode;
|
int mode;
|
||||||
Cursor cursor;
|
Cursor cursor;
|
||||||
|
|
||||||
|
WINPR_ASSERT(floatbar);
|
||||||
|
WINPR_ASSERT(event);
|
||||||
|
|
||||||
xfContext* xfc = floatbar->xfc;
|
xfContext* xfc = floatbar->xfc;
|
||||||
|
WINPR_ASSERT(xfc);
|
||||||
|
WINPR_ASSERT(xfc->display);
|
||||||
|
|
||||||
mode = floatbar->mode;
|
mode = floatbar->mode;
|
||||||
cursor = XCreateFontCursor(xfc->display, XC_arrow);
|
cursor = XCreateFontCursor(xfc->display, XC_arrow);
|
||||||
|
|
||||||
@ -665,6 +733,10 @@ static void xf_floatbar_event_motionnotify(xfFloatbar* floatbar, const XMotionEv
|
|||||||
static void xf_floatbar_button_event_focusin(xfFloatbar* floatbar, const XAnyEvent* event)
|
static void xf_floatbar_button_event_focusin(xfFloatbar* floatbar, const XAnyEvent* event)
|
||||||
{
|
{
|
||||||
xfFloatbarButton* button;
|
xfFloatbarButton* button;
|
||||||
|
|
||||||
|
WINPR_ASSERT(floatbar);
|
||||||
|
WINPR_ASSERT(event);
|
||||||
|
|
||||||
button = xf_floatbar_get_button(floatbar, event->window);
|
button = xf_floatbar_get_button(floatbar, event->window);
|
||||||
|
|
||||||
if (button)
|
if (button)
|
||||||
@ -677,6 +749,10 @@ static void xf_floatbar_button_event_focusin(xfFloatbar* floatbar, const XAnyEve
|
|||||||
static void xf_floatbar_button_event_focusout(xfFloatbar* floatbar, const XAnyEvent* event)
|
static void xf_floatbar_button_event_focusout(xfFloatbar* floatbar, const XAnyEvent* event)
|
||||||
{
|
{
|
||||||
xfFloatbarButton* button;
|
xfFloatbarButton* button;
|
||||||
|
|
||||||
|
WINPR_ASSERT(floatbar);
|
||||||
|
WINPR_ASSERT(event);
|
||||||
|
|
||||||
button = xf_floatbar_get_button(floatbar, event->window);
|
button = xf_floatbar_get_button(floatbar, event->window);
|
||||||
|
|
||||||
if (button)
|
if (button)
|
||||||
@ -688,19 +764,20 @@ static void xf_floatbar_button_event_focusout(xfFloatbar* floatbar, const XAnyEv
|
|||||||
|
|
||||||
static void xf_floatbar_event_focusout(xfFloatbar* floatbar)
|
static void xf_floatbar_event_focusout(xfFloatbar* floatbar)
|
||||||
{
|
{
|
||||||
|
WINPR_ASSERT(floatbar);
|
||||||
xfContext* xfc = floatbar->xfc;
|
xfContext* xfc = floatbar->xfc;
|
||||||
|
WINPR_ASSERT(xfc);
|
||||||
|
|
||||||
if (xfc->pointer)
|
if (xfc->pointer)
|
||||||
{
|
{
|
||||||
|
WINPR_ASSERT(xfc->window);
|
||||||
|
WINPR_ASSERT(xfc->pointer);
|
||||||
XDefineCursor(xfc->display, xfc->window->handle, xfc->pointer->cursor);
|
XDefineCursor(xfc->display, xfc->window->handle, xfc->pointer->cursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL xf_floatbar_check_event(xfFloatbar* floatbar, const XEvent* event)
|
BOOL xf_floatbar_check_event(xfFloatbar* floatbar, const XEvent* event)
|
||||||
{
|
{
|
||||||
xfFloatbarButton* button;
|
|
||||||
size_t i, size;
|
|
||||||
|
|
||||||
if (!floatbar || !floatbar->xfc || !event)
|
if (!floatbar || !floatbar->xfc || !event)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -710,11 +787,11 @@ BOOL xf_floatbar_check_event(xfFloatbar* floatbar, const XEvent* event)
|
|||||||
if (event->xany.window == floatbar->handle)
|
if (event->xany.window == floatbar->handle)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
size = ARRAYSIZE(floatbar->buttons);
|
size_t size = ARRAYSIZE(floatbar->buttons);
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (size_t i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
button = floatbar->buttons[i];
|
const xfFloatbarButton* button = floatbar->buttons[i];
|
||||||
|
|
||||||
if (event->xany.window == button->handle)
|
if (event->xany.window == button->handle)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -803,6 +880,8 @@ static void xf_floatbar_button_free(xfContext* xfc, xfFloatbarButton* button)
|
|||||||
|
|
||||||
if (button->handle)
|
if (button->handle)
|
||||||
{
|
{
|
||||||
|
WINPR_ASSERT(xfc);
|
||||||
|
WINPR_ASSERT(xfc->display);
|
||||||
XUnmapWindow(xfc->display, button->handle);
|
XUnmapWindow(xfc->display, button->handle);
|
||||||
XDestroyWindow(xfc->display, button->handle);
|
XDestroyWindow(xfc->display, button->handle);
|
||||||
}
|
}
|
||||||
@ -820,6 +899,8 @@ void xf_floatbar_free(xfFloatbar* floatbar)
|
|||||||
|
|
||||||
free(floatbar->title);
|
free(floatbar->title);
|
||||||
xfc = floatbar->xfc;
|
xfc = floatbar->xfc;
|
||||||
|
WINPR_ASSERT(xfc);
|
||||||
|
|
||||||
size = ARRAYSIZE(floatbar->buttons);
|
size = ARRAYSIZE(floatbar->buttons);
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
@ -830,6 +911,7 @@ void xf_floatbar_free(xfFloatbar* floatbar)
|
|||||||
|
|
||||||
if (floatbar->handle)
|
if (floatbar->handle)
|
||||||
{
|
{
|
||||||
|
WINPR_ASSERT(xfc->display);
|
||||||
XUnmapWindow(xfc->display, floatbar->handle);
|
XUnmapWindow(xfc->display, floatbar->handle);
|
||||||
XDestroyWindow(xfc->display, floatbar->handle);
|
XDestroyWindow(xfc->display, floatbar->handle);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user