12to11/alloc.c
oldosfan c190ead122 Implement support for zwp_text_input_manager_v3
* 12to11.c (HandleCmdline): New function.
(XLMain): Handle locale, initialize text input and and set up
the resource database.
* 12to11.man: Document resources and command-line arguments.
* Imakefile (SRCS, OBJS): Add text_input.c and text_input.o.
(text-input-unstable-v3): New scanner target.
* README: Document support for zwp_text_input_manager_v3.
* alloc.c (XLMalloc, XLCalloc, XLRealloc): Allow alloc of size 0
to return NULL.
* atoms.c (resource_quark, app_quark, QString): New quarks.
(XLInitAtoms): Initialize some quarks.
* compositor.h (struct _Compositor): Add resource and app names.
(struct _RoleFuncs): Add `select_extra_events'.
(struct _TextInputFuncs): New structure.
* run.c (HandleOneXEvent): Filter events if necessary.
* seat.c (AllKeyMask): New define.
(input_funcs): New variable.
(MakeSeatForDevicePair, NoticeDeviceDisabled): Always assign a
single seat the role of "text input seat".
(ClearFocusSurface, SetFocusSurface): Call input method hooks.
(HackKeyboardModifiers): New function.
(DispatchKey): Ignore repeated key events.
(XLSeatGetFocus): New function.
(XLSeatSetTextInputFuncs, XLSeatGetKeyboardDevice)
(XLSeatGetInputMethodSeat, XLSeatDispatchCoreKeyEvent): New
function.
* surface.c (XLSurfaceSelectExtraEvents): New function.
* xdg_surface.c (DefaultEventMask): Add core event mask here.
(XLHandleXEventForXdgSurfaces): Handle core key events.
(Commit, NoteBounds): Improve debug code.
(SelectExtraEvents): New function.
(XLGetXdgSurface, XLXdgRoleSetBoundsSize): Improve debug code.
(XLInitXdgSurfaces): Reduce size of assoc table.
* xdg_toplevel.c (SendConfigure, SendDecorationConfigure, Map)
(HandleConfigureEvent, SetMode, UnsetMode): Avoid sending
decoration configure before initial commit.
2022-10-06 02:09:36 +00:00

108 lines
1.9 KiB
C

/* Wayland compositor running on top of an X server.
Copyright (C) 2022 to various contributors.
This file is part of 12to11.
12to11 is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
12to11 is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with 12to11. If not, see <https://www.gnu.org/licenses/>. */
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "compositor.h"
void *
XLMalloc (size_t size)
{
void *ptr;
ptr = malloc (size);
if (!ptr && size)
{
fprintf (stderr, "Allocation of %zu bytes failed\n",
size);
abort ();
}
return ptr;
}
void *
XLSafeMalloc (size_t size)
{
return malloc (size);
}
void *
XLCalloc (size_t nmemb, size_t size)
{
void *ptr;
ptr = calloc (nmemb, size);
if (!ptr && nmemb && size)
{
fprintf (stderr, "Allocation of %zu * %zu failed\n",
nmemb, size);
abort ();
}
return ptr;
}
void
XLFree (void *ptr)
{
if (ptr)
free (ptr);
}
char *
XLStrdup (const char *data)
{
char *string;
string = strdup (data);
if (!string)
{
fprintf (stderr, "Allocation of %zu bytes failed\n",
strlen (data));
abort ();
}
return string;
}
void *
XLRealloc (void *ptr, size_t size)
{
if (!ptr)
return XLMalloc (size);
ptr = realloc (ptr, size);
if (size && !ptr)
{
fprintf (stderr, "Reallocation of %zu bytes failed\n", size);
abort ();
}
/* Allow realloc to return NULL if size is also NULL. */
return ptr;
}