Annotation of freem/src/mwapi_event.c, revision 1.4
1.1 snw 1: /*
1.4 ! snw 2: * $Id: mwapi_event.c,v 1.3 2025/03/09 19:50:47 snw Exp $
1.1 snw 3: * mwapi event support
4: *
5: *
1.2 snw 6: * Author: Serena Willis <snw@coherent-logic.com>
1.1 snw 7: * Copyright (C) 1998 MUG Deutschland
1.3 snw 8: * Copyright (C) 2014, 2020, 2021, 2025 Coherent Logic Development LLC
1.1 snw 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: *
1.4 ! snw 26: * $Log: mwapi_event.c,v $
! 27: * Revision 1.3 2025/03/09 19:50:47 snw
! 28: * Second phase of REUSE compliance and header reformat
! 29: *
1.3 snw 30: *
31: * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
32: * SPDX-License-Identifier: AGPL-3.0-or-later
1.1 snw 33: **/
34: #include "config.h"
35:
36: #if defined(HAVE_MWAPI_MOTIF)
37:
38: #include <stdlib.h>
39: #include <Xm/Xm.h>
40: #include "mpsdef0.h"
41: #include "mwapi_event.h"
42: #include "mwapi_window.h"
43:
44: short evt_sync_enabled = FALSE;
45: mwapi_event_queue_entry *mwapi_event_queue_head;
46:
47: mwapi_event *mwapi_event_new(char *evclass, char *window_name, Widget *window)
48: {
49: mwapi_event *e = (mwapi_event *) malloc (sizeof (mwapi_event));
50: NULLPTRCHK(e,"mwapi_event_new");
51:
52: e->evclass = evclass;
53: e->window_name = window_name;
54: e->window = window;
55:
56: stcnv_m2c (e->window_name);
57:
58: return e;
59: }
60:
61: void mwapi_wire_event(mwapi_event *e, char *entryref)
62: {
63: char m_gtk_ev[100];
64:
65: if (strcmp (e->evclass, "CLOSE") == 0) strcpy (m_gtk_ev, "destroy");
66:
67: e->entryref = (char *) malloc (strlen (entryref) * sizeof (char));
68: NULLPTRCHK(e->entryref,"mwapi_wire_event");
69:
70: strcpy (e->entryref, entryref);
71: }
72:
73: void mwapi_enqueue_event(Widget *widget, void *data)
74: {
75: mwapi_event *e = (mwapi_event *) malloc (sizeof (mwapi_event));
76: NULLPTRCHK(e,"mwapi_enqueue_event");
77:
78: mwapi_event_queue_entry *t = (mwapi_event_queue_entry *) malloc (sizeof (mwapi_event_queue_entry));
79: NULLPTRCHK(t,"mwapi_enqueue_event");
80:
81: e = (mwapi_event *) data;
82:
83: t->e = e;
84: t->next = mwapi_event_queue_head;
85: mwapi_event_queue_head = t;
86:
87: return;
88: }
89:
90: int mwapi_dequeue_events(char *result)
91: {
92:
93: mwapi_event_queue_entry *t;
94: int i = 0;
95:
96: for (t = mwapi_event_queue_head; t != NULL; t = t->next) {
97:
98: strcat (result, t->e->entryref);
99: strcat (result, ",");
100: i++;
101:
102: }
103:
1.4 ! snw 104: /* TODO: delete events */
1.1 snw 105: mwapi_event_queue_head = NULL;
106:
107: /* chop off the final comma */
108: result[strlen (result) - 1] = '\0';
109:
110: return i;
111:
112: }
113:
114: void mwapi_on_merge_complete(char *window_name)
115: {
116: mwapi_window *t;
117:
118: if (stcmp (window_name, "\201") == 0) {
119: /* we're merging to the global directly; no specified subscript */
120: /* we'll do a loop here */
121: }
122: else {
123: /* merging to a specific window */
124: t = mwapi_win_get (window_name);
125: mwapi_win_show (t);
126: }
127:
128: }
129:
130: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>