File: sqUnixHostWindowPlugin.c

package info (click to toggle)
squeak-vm 1%3A4.10.2.2614-4.1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 13,284 kB
  • ctags: 15,344
  • sloc: ansic: 75,096; cs: 11,191; objc: 5,494; sh: 3,170; asm: 1,533; cpp: 449; pascal: 372; makefile: 366; awk: 103
file content (163 lines) | stat: -rw-r--r-- 5,200 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*  sqUnixHostWindowPlugin.c -- support for multiple host windows
 *
 * Copyright (C) 2009 by Bert Freudenberg and other
 *                             authors/contributors as listed.
 *   All rights reserved.
 *   
 *   This file is part of Unix Squeak.
 * 
 *   Permission is hereby granted, free of charge, to any person obtaining a copy
 *   of this software and associated documentation files (the "Software"), to deal
 *   in the Software without restriction, including without limitation the rights
 *   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 *   copies of the Software, and to permit persons to whom the Software is
 *   furnished to do so, subject to the following conditions:
 * 
 *   The above copyright notice and this permission notice shall be included in
 *   all copies or substantial portions of the Software.
 * 
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 *   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 *   SOFTWARE.
 */

#define AVOID_OPENGL_H	1

#include "sq.h"
#include "SqDisplay.h"
#include "HostWindowPlugin.h"

#define FPRINTF(x) fprintf x

static struct SqDisplay	*dpy= 0;

#define noDisplay ( (!dpy && !(dpy= ioGetDisplayModule())) || (dpy->version < 0x10002) )
 
/* closeWindow: arg is int windowIndex. Fail (return 0) if anything goes wrong
 * - typically the windowIndex invalid or similar
 */
sqInt closeWindow(sqInt index)
{
  if (noDisplay)
    return 0;
  else
    return dpy->hostWindowClose(index); 
}


/* createWindow: takes int width, height and origin x/y plus a char* list of
 * as yet undefined attributes. Returns an int window index or 0 for failure
 * Failure may occur because of an inability to add the window, too many
 * windows already extant (platform dependant), the specified size being
 * unreasonable etc.
 */
sqInt createWindowWidthheightoriginXyattrlength(
	sqInt w, sqInt h, sqInt x, sqInt y, char *list, sqInt attributeListLength)
{
  if (noDisplay)
    return 0;
  else
    return dpy->hostWindowCreate(w, h, x, y, list, attributeListLength);
}


/* ioShowDisplayOnWindow: similar to ioShowDisplay but adds the int windowIndex
 * Return true if ok, false if not, but not currently checked
 */
sqInt ioShowDisplayOnWindow(
	unsigned char *dispBitsIndex, 
	sqInt width, sqInt height, sqInt depth, 
	sqInt affectedL, sqInt affectedR, sqInt affectedT, sqInt affectedB,
	sqInt windowIndex)
{
  if (noDisplay)
    return 0;
  else
    return dpy->hostWindowShowDisplay(
      dispBitsIndex, width, height, depth, affectedL, affectedR, affectedT, affectedB, windowIndex);
}


/* ioSizeOfWindow: arg is int windowIndex. Return the size of the specified
 * window in (width<<16 || height) format like ioScreenSize.
 * Return -1 for failure - typically invalid windowIndex
 * -1 is chosen since itwould correspond to a window size of 64k@64k which
 * I hope is unlikely for some time to come
 */
sqInt ioSizeOfWindow(sqInt windowIndex)
{
  if (noDisplay)
    return -1;
  else
    return dpy->hostWindowGetSize(windowIndex);
}


/* ioSizeOfWindowSetxy: args are int windowIndex, int w & h for the
 * width / height to make the window. Return the actual size the OS
 * produced in (width<<16 || height) format or -1 for failure as above.
 */
sqInt ioSizeOfWindowSetxy(sqInt windowIndex, sqInt w, sqInt h)
{
  if (noDisplay)
    return -1;
  else
    return dpy->hostWindowSetSize(windowIndex, w, h);
}


/* ioPositionOfWindow: arg is int windowIndex. Return the pos of the specified
 * window in (left<<16 || top) format like ioScreenSize.
 * Return -1 (as above) for failure - typically invalid windowIndex
 */
sqInt ioPositionOfWindow(sqInt windowIndex)
{
  if (noDisplay)
    return -1;
  else
    return dpy->hostWindowGetPosition(windowIndex);
}


/* ioPositionOfWindowSetxy: args are int windowIndex, int x & y for the
 * origin x/y for the window. Return the actual origin the OS
 * produced in (left<<16 || top) format or -1 for failure, as above
 */
sqInt ioPositionOfWindowSetxy(sqInt windowIndex, sqInt x, sqInt y)
{
  if (noDisplay)
    return -1;
  else
    return dpy->hostWindowSetPosition(windowIndex, x, y);
}


/* ioSetTitleOfWindow: args are int windowIndex, char* newTitle and
 * int size of new title. Fail with -1 if windowIndex is invalid, string is too
 * long for platform etc. Leave previous title in place on failure
 */
sqInt ioSetTitleOfWindow(sqInt windowIndex, char *newTitle, sqInt sizeOfTitle)
{
  if (noDisplay)
    return -1;
  else
    return dpy->hostWindowSetTitle(windowIndex, newTitle, sizeOfTitle);
}


/* ioCloseAllWindows: intended for VM shutdown.
 * Close all the windows that appear to be open.
 * No useful return value since we're getting out of Dodge anyway.
 */
sqInt ioCloseAllWindows(void)
{
  if (noDisplay)
    return 0;
  else
    return dpy->hostWindowCloseAll();
}