unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob bd1d6c88f0bfa6385aa3d2868f73439b0eadb670 3654 bytes (raw)
name: src/haiku_simx.c 	 # note: path name is non-authoritative(*)

  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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
 
/* Utilities and defines for using XPM without X on Haiku

Copyright (C) 2021 Free Software Foundation, Inc.

This file is part of GNU Emacs.

GNU Emacs 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.

GNU Emacs 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 GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */

#include <config.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#include "dispextern.h"
#include "haiku_support.h"
#define FOR_MSW
#include "xpm_be.h"
#undef FOR_MSW

/* Defined in haikufns.c. */
extern int haiku_get_color (const char *name, Emacs_Color *color);
extern unsigned long haiku_get_pixel (haiku bitmap, int x, int y);
extern void haiku_put_pixel (haiku bitmap, int x, int y, unsigned long pixel);

Visual *
XDefaultVisual (Display *dpy, Screen *screen)
{
  return NULL;
}

Screen *
XDefaultScreen (Display *d)
{
  return NULL;
}

int
XDefaultDepth (Display *display, Screen *screen)
{
  return 24;
}

Colormap *
XDefaultColormap (Display *display, Screen *screen)
{
  return NULL;
}

int
XParseColor (Display *d, Colormap *cmap, char *name, XColor *color)
{
  int r, g, b;
  int okay;

  if (name == NULL)
    return (0);

  Emacs_Color ecol;

  okay = !haiku_get_color (name, &ecol);
  if (okay)
    {
      r = ecol.red / 256;
      g = ecol.green / 256;
      b = ecol.blue / 256;
    }

  if (okay)
    {
      color->red = (uint8_t) r;
      color->green = (uint8_t) g;
      color->blue = (uint8_t) b;
      color->pixel = ((color->red << 16) |
		      (color->green << 8) |
		      color->blue);
      return 1;
    }
  else
    return 0;
}

int
XAllocColor (Display *d, Colormap cmap, XColor *color)
{
  return 1;
}

void
XQueryColors (Display *display, Colormap *colormap,
	      XColor *xcolors, int ncolors)
{
  for (int i = 0; i < ncolors; ++i)
    {
      xcolors[i].red = xcolors[i].pixel >> 16 & 0xff;
      xcolors[i].green = xcolors[i].pixel >> 8 & 0xff;
      xcolors[i].blue = xcolors[i].pixel & 0xff;
    }
}

XImage *
XCreateImage (Display *d, Visual *v,
	      int depth, int format,
	      int x, int y, int width, int height,
	      int pad, int foo)
{
  XImage *img = (XImage *) malloc (sizeof (XImage));

  if (img)
    {
      img->bitmap = BBitmap_new (width + 1, height + 1, depth == 1);
      img->width = width + 1;
      img->height = height + 1;
      img->depth = depth == 1 ? 1 : 32;
    }

  return img;
}

int
XFreeColors (Display *d, Colormap cmap,
	     Pixel *pixels, int npixels, unsigned long planes)
{
  return 0;
}

void
XImageFree (XImage *img)
{
  if (img)
    free (img);
}

void
XDestroyImage (XImage *img)
{
  if (img)
    {
      BBitmap_free (img->bitmap);
      XImageFree (img);
    }
}

void *
boundCheckingMalloc (long size)
{
  return malloc (size);
}

void *
boundCheckingCalloc (long n, long s)
{
  return calloc (n, s);
}

void *
boundCheckingRealloc (void *p, long s)
{
  return realloc (p, s);
}

void
XPutPixel (XImage *img, int x, int y, unsigned long p)
{
  if (img->depth == 1)
    haiku_put_pixel (img->bitmap, x, y, p);
  else
    haiku_put_pixel (img->bitmap, x, y, p | ((unsigned long) 255) << 24);
}

unsigned long
XGetPixel (XImage *img, int x, int y)
{
  return haiku_get_pixel (img->bitmap, x, y);
}

debug log:

solving bd1d6c88f0 ...
found bd1d6c88f0 in https://yhetil.org/emacs-devel/87ee9tjjmt.fsf@yahoo.com/

applying [1/1] https://yhetil.org/emacs-devel/87ee9tjjmt.fsf@yahoo.com/
diff --git a/src/haiku_simx.c b/src/haiku_simx.c
new file mode 100644
index 0000000000..bd1d6c88f0

Checking patch src/haiku_simx.c...
Applied patch src/haiku_simx.c cleanly.

index at:
100644 bd1d6c88f0bfa6385aa3d2868f73439b0eadb670	src/haiku_simx.c

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).