1: /*
2: * $Id: mwapi_event.c,v 1.4 2025/04/10 01:24:38 snw Exp $
3: * mwapi event support
4: *
5: *
6: * Author: Serena Willis <snw@coherent-logic.com>
7: * Copyright (C) 1998 MUG Deutschland
8: * Copyright (C) 2014, 2020, 2021, 2025 Coherent Logic Development LLC
9: *
10: *
11: * This file is part of FreeM.
12: *
13: * FreeM is free software: you can redistribute it and/or modify
14: * it under the terms of the GNU Affero Public License as published by
15: * the Free Software Foundation, either version 3 of the License, or
16: * (at your option) any later version.
17: *
18: * FreeM is distributed in the hope that it will be useful,
19: * but WITHOUT ANY WARRANTY; without even the implied warranty of
20: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21: * GNU Affero Public License for more details.
22: *
23: * You should have received a copy of the GNU Affero Public License
24: * along with FreeM. If not, see <https://www.gnu.org/licenses/>.
25: *
26: * $Log: mwapi_event.c,v $
27: * Revision 1.4 2025/04/10 01:24:38 snw
28: * Remove C++ style comments
29: *
30: * Revision 1.3 2025/03/09 19:50:47 snw
31: * Second phase of REUSE compliance and header reformat
32: *
33: *
34: * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
35: * SPDX-License-Identifier: AGPL-3.0-or-later
36: **/
37: #include "config.h"
38:
39: #if defined(HAVE_MWAPI_MOTIF)
40:
41: #include <stdlib.h>
42: #include <Xm/Xm.h>
43: #include "mpsdef0.h"
44: #include "mwapi_event.h"
45: #include "mwapi_window.h"
46:
47: short evt_sync_enabled = FALSE;
48: mwapi_event_queue_entry *mwapi_event_queue_head;
49:
50: mwapi_event *mwapi_event_new(char *evclass, char *window_name, Widget *window)
51: {
52: mwapi_event *e = (mwapi_event *) malloc (sizeof (mwapi_event));
53: NULLPTRCHK(e,"mwapi_event_new");
54:
55: e->evclass = evclass;
56: e->window_name = window_name;
57: e->window = window;
58:
59: stcnv_m2c (e->window_name);
60:
61: return e;
62: }
63:
64: void mwapi_wire_event(mwapi_event *e, char *entryref)
65: {
66: char m_gtk_ev[100];
67:
68: if (strcmp (e->evclass, "CLOSE") == 0) strcpy (m_gtk_ev, "destroy");
69:
70: e->entryref = (char *) malloc (strlen (entryref) * sizeof (char));
71: NULLPTRCHK(e->entryref,"mwapi_wire_event");
72:
73: strcpy (e->entryref, entryref);
74: }
75:
76: void mwapi_enqueue_event(Widget *widget, void *data)
77: {
78: mwapi_event *e = (mwapi_event *) malloc (sizeof (mwapi_event));
79: NULLPTRCHK(e,"mwapi_enqueue_event");
80:
81: mwapi_event_queue_entry *t = (mwapi_event_queue_entry *) malloc (sizeof (mwapi_event_queue_entry));
82: NULLPTRCHK(t,"mwapi_enqueue_event");
83:
84: e = (mwapi_event *) data;
85:
86: t->e = e;
87: t->next = mwapi_event_queue_head;
88: mwapi_event_queue_head = t;
89:
90: return;
91: }
92:
93: int mwapi_dequeue_events(char *result)
94: {
95:
96: mwapi_event_queue_entry *t;
97: int i = 0;
98:
99: for (t = mwapi_event_queue_head; t != NULL; t = t->next) {
100:
101: strcat (result, t->e->entryref);
102: strcat (result, ",");
103: i++;
104:
105: }
106:
107: /* TODO: delete events */
108: mwapi_event_queue_head = NULL;
109:
110: /* chop off the final comma */
111: result[strlen (result) - 1] = '\0';
112:
113: return i;
114:
115: }
116:
117: void mwapi_on_merge_complete(char *window_name)
118: {
119: mwapi_window *t;
120:
121: if (stcmp (window_name, "\201") == 0) {
122: /* we're merging to the global directly; no specified subscript */
123: /* we'll do a loop here */
124: }
125: else {
126: /* merging to a specific window */
127: t = mwapi_win_get (window_name);
128: mwapi_win_show (t);
129: }
130:
131: }
132:
133: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>