4 * Copyright (C) 2004-2011 Simon Wunderlich <dotslash@packetmixer.de>
6 * This file is part of s3d, a 3d network display server.
7 * See http://s3d.berlios.de/ for more updates.
9 * s3d is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * s3d is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with s3d; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "proto.h" /* for S3D_P_OBJECT, to be integrated in proto.c */
29 #include <netinet/in.h> /* htonl() */
31 #include <string.h> /* strncpy() */
33 /* this interacts with the actual mcp client */
36 float trans_x
, trans_y
, trans_z
;
39 char name
[S3D_NAME_MAX
];
42 #define MCP_NEW_OBJECT 1
44 /* call when a new mcp connects */
49 p
= get_proc_by_pid(MCP
);
52 if (p
->object
[i
] != NULL
)
53 switch (p
->object
[i
]->oflags
& OF_TYPE
) {
66 /* report the mcp about our object */
67 int mcp_rep_object(int32_t mcp_oid
)
70 struct t_process
*p
, *ap
;
71 p
= get_proc_by_pid(MCP
);
72 mo
.object
= htonl(mcp_oid
);
73 mo
.trans_x
= p
->object
[mcp_oid
]->translate
.x
;
74 mo
.trans_y
= p
->object
[mcp_oid
]->translate
.y
;
75 mo
.trans_z
= p
->object
[mcp_oid
]->translate
.z
;
76 mo
.r
= p
->object
[mcp_oid
]->r
;
78 htonfb(&mo
.trans_x
, 4);
79 ap
= get_proc_by_pid(p
->object
[mcp_oid
]->virtual_pid
);
80 strncpy(mo
.name
, ap
->name
, S3D_NAME_MAX
);
81 prot_com_out(p
, S3D_P_MCP_OBJECT
, (uint8_t *) & mo
, sizeof(struct mcp_object
));
85 /* tells the mcp that some program vanished ... */
86 int mcp_del_object(int32_t mcp_oid
)
88 int32_t oid
= htonl(mcp_oid
);
89 if (mcp_oid
== focus_oid
) {
90 s3dprintf(MED
, "lost the focus of mcp-oid %d", mcp_oid
);
93 prot_com_out(get_proc_by_pid(MCP
), S3D_P_MCP_DEL_OBJECT
, (uint8_t *) & oid
, 4);
97 /* sets a new focus */
98 int mcp_focus(int oid
)
103 p
= get_proc_by_pid(MCP
);
104 s3dprintf(MED
, "request to focus %d", oid
);
105 if (OBJ_VALID(p
, oid
, o
))
106 if (o
->oflags
& OF_VIRTUAL
) {
108 obj_pos_update(p
, 0, 0);