clang-format: Apply formatting
Code submissions have continually suffered from formatting inconsistencies that constantly have to be addressed. Using clang-format simplifies this by making code formatting more consistent, and allows automation of the code formatting so that maintainers can focus more on the code itself instead of code formatting.
This commit is contained in:
@@ -28,12 +28,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* Theres a lot of talk about this in other implementation and they tend to
|
||||
* be really complicated, but this naive approach seems to work fine ...
|
||||
*/
|
||||
static uint32_t *xcursor_pixels(XFixesCursorImage *xc) {
|
||||
static uint32_t *xcursor_pixels(XFixesCursorImage *xc)
|
||||
{
|
||||
uint_fast32_t size = xc->width * xc->height;
|
||||
uint32_t *pixels = bmalloc(size * sizeof(uint32_t));
|
||||
|
||||
for (uint_fast32_t i = 0; i < size; ++i)
|
||||
pixels[i] = (uint32_t) xc->pixels[i];
|
||||
pixels[i] = (uint32_t)xc->pixels[i];
|
||||
|
||||
return pixels;
|
||||
}
|
||||
@@ -42,22 +43,23 @@ static uint32_t *xcursor_pixels(XFixesCursorImage *xc) {
|
||||
* Create the cursor texture, either by updating if the new cursor has the same
|
||||
* size or by creating a new texture if the size is different
|
||||
*/
|
||||
static void xcursor_create(xcursor_t *data, XFixesCursorImage *xc) {
|
||||
static void xcursor_create(xcursor_t *data, XFixesCursorImage *xc)
|
||||
{
|
||||
uint32_t *pixels = xcursor_pixels(xc);
|
||||
if (!pixels)
|
||||
return;
|
||||
|
||||
if (data->tex
|
||||
&& data->last_height == xc->width
|
||||
&& data->last_width == xc->height) {
|
||||
gs_texture_set_image(data->tex, (const uint8_t *) pixels,
|
||||
xc->width * sizeof(uint32_t), False);
|
||||
if (data->tex && data->last_height == xc->width &&
|
||||
data->last_width == xc->height) {
|
||||
gs_texture_set_image(data->tex, (const uint8_t *)pixels,
|
||||
xc->width * sizeof(uint32_t), False);
|
||||
} else {
|
||||
if (data->tex)
|
||||
gs_texture_destroy(data->tex);
|
||||
|
||||
data->tex = gs_texture_create(xc->width, xc->height,
|
||||
GS_BGRA, 1, (const uint8_t **) &pixels, GS_DYNAMIC);
|
||||
data->tex = gs_texture_create(xc->width, xc->height, GS_BGRA, 1,
|
||||
(const uint8_t **)&pixels,
|
||||
GS_DYNAMIC);
|
||||
}
|
||||
|
||||
bfree(pixels);
|
||||
@@ -67,7 +69,8 @@ static void xcursor_create(xcursor_t *data, XFixesCursorImage *xc) {
|
||||
data->last_height = xc->height;
|
||||
}
|
||||
|
||||
xcursor_t *xcursor_init(Display *dpy) {
|
||||
xcursor_t *xcursor_init(Display *dpy)
|
||||
{
|
||||
xcursor_t *data = bzalloc(sizeof(xcursor_t));
|
||||
|
||||
data->dpy = dpy;
|
||||
@@ -76,13 +79,15 @@ xcursor_t *xcursor_init(Display *dpy) {
|
||||
return data;
|
||||
}
|
||||
|
||||
void xcursor_destroy(xcursor_t *data) {
|
||||
void xcursor_destroy(xcursor_t *data)
|
||||
{
|
||||
if (data->tex)
|
||||
gs_texture_destroy(data->tex);
|
||||
bfree(data);
|
||||
}
|
||||
|
||||
void xcursor_tick(xcursor_t *data) {
|
||||
void xcursor_tick(xcursor_t *data)
|
||||
{
|
||||
XFixesCursorImage *xc = XFixesGetCursorImage(data->dpy);
|
||||
if (!xc)
|
||||
return;
|
||||
@@ -98,11 +103,12 @@ void xcursor_tick(xcursor_t *data) {
|
||||
XFree(xc);
|
||||
}
|
||||
|
||||
void xcursor_render(xcursor_t *data) {
|
||||
void xcursor_render(xcursor_t *data)
|
||||
{
|
||||
if (!data->tex)
|
||||
return;
|
||||
|
||||
gs_effect_t *effect = gs_get_effect();
|
||||
gs_effect_t *effect = gs_get_effect();
|
||||
gs_eparam_t *image = gs_effect_get_param_by_name(effect, "image");
|
||||
gs_effect_set_texture(image, data->tex);
|
||||
|
||||
@@ -119,9 +125,8 @@ void xcursor_render(xcursor_t *data) {
|
||||
gs_blend_state_pop();
|
||||
}
|
||||
|
||||
void xcursor_offset(xcursor_t* data, int_fast32_t x_org, int_fast32_t y_org)
|
||||
void xcursor_offset(xcursor_t *data, int_fast32_t x_org, int_fast32_t y_org)
|
||||
{
|
||||
data->x_org = x_org;
|
||||
data->y_org = y_org;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user