Changeset 2056 for libcaca/trunk/caca/driver_x11.c
- Timestamp:
- Nov 25, 2007, 3:12:01 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca/driver_x11.c
r2055 r2056 34 34 #include <string.h> 35 35 36 #include "cucul.h" 37 #include "cucul_internals.h" 36 38 #include "caca.h" 37 39 #include "caca_internals.h" 38 #include "cucul.h"39 #include "cucul_internals.h"40 40 41 41 /* … … 78 78 char const *fonts[] = { NULL, "8x13bold", "fixed" }, **parser; 79 79 char const *geometry; 80 unsigned int width = dp->cv->width, height = dp->cv->height; 80 unsigned int width = cucul_get_canvas_width(dp->cv); 81 unsigned int height = cucul_get_canvas_height(dp->cv); 81 82 int i; 82 83 … … 91 92 dp->resize.allow = 1; 92 93 cucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32); 94 width = cucul_get_canvas_width(dp->cv); 95 height = cucul_get_canvas_height(dp->cv); 93 96 dp->resize.allow = 0; 94 97 … … 193 196 dp->drv.p->window = 194 197 XCreateWindow(dp->drv.p->dpy, DefaultRootWindow(dp->drv.p->dpy), 0, 0, 195 dp->cv->width * dp->drv.p->font_width,196 dp->cv->height * dp->drv.p->font_height,198 width * dp->drv.p->font_width, 199 height * dp->drv.p->font_height, 197 200 0, 0, InputOutput, 0, 198 201 CWBackingStore | CWBackPixel | CWEventMask, … … 241 244 242 245 dp->drv.p->pixmap = XCreatePixmap(dp->drv.p->dpy, dp->drv.p->window, 243 dp->cv->width * dp->drv.p->font_width,244 dp->cv->height * dp->drv.p->font_height,245 DefaultDepth(dp->drv.p->dpy,246 246 width * dp->drv.p->font_width, 247 height * dp->drv.p->font_height, 248 DefaultDepth(dp->drv.p->dpy, 249 DefaultScreen(dp->drv.p->dpy))); 247 250 dp->drv.p->pointer = None; 248 251 … … 279 282 static unsigned int x11_get_display_width(caca_display_t const *dp) 280 283 { 281 return dp->cv->width* dp->drv.p->font_width;284 return cucul_get_canvas_width(dp->cv) * dp->drv.p->font_width; 282 285 } 283 286 284 287 static unsigned int x11_get_display_height(caca_display_t const *dp) 285 288 { 286 return dp->cv->height* dp->drv.p->font_height;289 return cucul_get_canvas_height(dp->cv) * dp->drv.p->font_height; 287 290 } 288 291 289 292 static void x11_display(caca_display_t *dp) 290 293 { 294 uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv); 295 uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv); 296 unsigned int width = cucul_get_canvas_width(dp->cv); 297 unsigned int height = cucul_get_canvas_height(dp->cv); 291 298 unsigned int x, y, len; 292 299 293 300 /* First draw the background colours. Splitting the process in two 294 301 * loops like this is actually slightly faster. */ 295 for(y = 0; y < dp->cv->height; y++)296 { 297 for(x = 0; x < dp->cv->width; x += len)298 { 299 uint32_t *attrs = dp->cv->attrs + x + y * dp->cv->width;302 for(y = 0; y < height; y++) 303 { 304 for(x = 0; x < width; x += len) 305 { 306 uint32_t const *attrs = cvattrs + x + y * width; 300 307 uint16_t bg = _cucul_attr_to_rgb12bg(*attrs); 301 308 302 309 len = 1; 303 while(x + len < dp->cv->width310 while(x + len < width 304 311 && _cucul_attr_to_rgb12bg(attrs[len]) == bg) 305 312 len++; … … 316 323 317 324 /* Then print the foreground characters */ 318 for(y = 0; y < dp->cv->height; y++)325 for(y = 0; y < height; y++) 319 326 { 320 327 unsigned int yoff = (y + 1) * dp->drv.p->font_height 321 328 - dp->drv.p->font_offset; 322 uint32_t *chars = dp->cv->chars + y * dp->cv->width;323 uint32_t *attrs = dp->cv->attrs + y * dp->cv->width;324 325 for(x = 0; x < dp->cv->width; x++, chars++, attrs++)329 uint32_t const *chars = cvchars + y * width; 330 uint32_t const *attrs = cvattrs + y * width; 331 332 for(x = 0; x < width; x++, chars++, attrs++) 326 333 { 327 334 XSetForeground(dp->drv.p->dpy, dp->drv.p->gc, … … 349 356 XCopyArea(dp->drv.p->dpy, dp->drv.p->pixmap, dp->drv.p->window, 350 357 dp->drv.p->gc, 0, 0, 351 dp->cv->width * dp->drv.p->font_width,352 dp->cv->height * dp->drv.p->font_height,358 width * dp->drv.p->font_width, 359 height * dp->drv.p->font_height, 353 360 0, 0); 354 361 XFlush(dp->drv.p->dpy); … … 374 381 static int x11_get_event(caca_display_t *dp, caca_privevent_t *ev) 375 382 { 383 unsigned int width = cucul_get_canvas_width(dp->cv); 384 unsigned int height = cucul_get_canvas_height(dp->cv); 376 385 XEvent xevent; 377 386 char key; … … 387 396 XCopyArea(dp->drv.p->dpy, dp->drv.p->pixmap, 388 397 dp->drv.p->window, dp->drv.p->gc, 0, 0, 389 dp->cv->width * dp->drv.p->font_width,390 dp->cv->height * dp->drv.p->font_height, 0, 0);398 width * dp->drv.p->font_width, 399 height * dp->drv.p->font_height, 0, 0); 391 400 continue; 392 401 } … … 402 411 / dp->drv.p->font_height; 403 412 404 if(!w || !h || (w == dp->cv->width && h == dp->cv->height))413 if(!w || !h || (w == width && h == height)) 405 414 continue; 406 415 … … 418 427 unsigned int newy = xevent.xmotion.y / dp->drv.p->font_height; 419 428 420 if(newx >= dp->cv->width)421 newx = dp->cv->width - 1;422 if(newy >= dp->cv->height)423 newy = dp->cv->height - 1;429 if(newx >= width) 430 newx = width - 1; 431 if(newy >= height) 432 newy = height - 1; 424 433 425 434 if(dp->mouse.x == newx && dp->mouse.y == newy)
Note: See TracChangeset
for help on using the changeset viewer.