1275
1279
// Window state
1276
1280
generic.netstates.net_wm_state_atom =
1277
XInternAtom(dpy, "_NET_WM_STATE", False);
1281
XInternAtom(dpy, "_NET_WM_STATE", False);
1282
generic.netstates.new_wm_state_modal_atom =
1283
XInternAtom(dpy, "_NET_WM_STATE_MODAL", False);
1284
generic.netstates.net_wm_state_sticky_atom =
1285
XInternAtom(dpy, "_NET_WM_STATE_STICKY", False);
1286
generic.netstates.net_wm_state_maximized_vert_atom =
1287
XInternAtom(dpy, "_NET_WM_STATE_MAXIMIZED_VERT", False);
1288
generic.netstates.net_wm_state_maximized_horz_atom =
1289
XInternAtom(dpy, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
1290
generic.netstates.net_wm_state_shaded_atom =
1291
XInternAtom(dpy, "_NET_WM_STATE_SHADED", False);
1278
1292
generic.netstates.net_wm_state_skip_taskbar_atom =
1279
XInternAtom(dpy, "_NET_WM_STATE_SKIP_TASKBAR", False);
1293
XInternAtom(dpy, "_NET_WM_STATE_SKIP_TASKBAR", False);
1280
1294
generic.netstates.net_wm_state_skip_pager_atom =
1281
XInternAtom(dpy, "_NET_WM_STATE_SKIP_PAGER", False);
1282
generic.netstates.net_wm_state_sticky_atom =
1283
XInternAtom(dpy, "_NET_WM_STATE_STICKY", False);
1295
XInternAtom(dpy, "_NET_WM_STATE_SKIP_PAGER", False);
1284
1296
generic.netstates.net_wm_state_hidden_atom =
1285
XInternAtom(dpy, "_NET_WM_STATE_HIDDEN", False);
1297
XInternAtom(dpy, "_NET_WM_STATE_HIDDEN", False);
1298
generic.netstates.net_wm_state_fullscreen_atom =
1299
XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
1300
generic.netstates.net_wm_state_above_atom =
1301
XInternAtom(dpy, "_NET_WM_STATE_ABOVE", False);
1302
generic.netstates.net_wm_state_below_atom =
1303
XInternAtom(dpy, "_NET_WM_STATE_BELOW", False);
1304
generic.netstates.net_wm_state_demands_attention_atom =
1305
XInternAtom(dpy, "_NET_WM_STATE_DEMANDS_ATTENTION", False);
1447
1467
if ((generic.wm & XGWM_EWMH) != 0)
1449
1469
window->protocols[window->numProtocols++] = generic.net_wm_ping_atom;
1471
window->protocols[window->numProtocols++] = generic.net_wm_sync_request_atom;
1451
1474
if ((generic.wm & XGWM_WINDOWMAKER) != 0
1452
1475
&& (window->win_attrs.window_style & NSMiniaturizableWindowMask) != 0)
1454
1477
window->protocols[window->numProtocols++] = generic.miniaturize_atom;
1479
NSAssert1(window->numProtocols <= GSMaxWMProtocols,
1480
@"Too many protocols (%d > GSMaxWMProtocols)",
1481
window->numProtocols);
1456
1482
XSetWMProtocols(dpy, window->ident, window->protocols, window->numProtocols);
1484
1510
generic.delete_win_atom = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
1485
1511
generic.wm_state_atom = XInternAtom(dpy, "WM_STATE", False);
1486
1512
generic.net_wm_ping_atom = XInternAtom(dpy, "_NET_WM_PING", False);
1513
generic.net_wm_sync_request_atom = XInternAtom(dpy, "_NET_WM_SYNC_REQUEST", False);
1514
generic.net_wm_sync_request_counter_atom = XInternAtom(dpy, "_NET_WM_SYNC_REQUEST_COUNTER", False);
1487
1515
generic.miniaturize_atom
1488
1516
= XInternAtom(dpy, "_GNUSTEP_WM_MINIATURIZE_WINDOW", False);
1489
1517
generic.win_decor_atom = XInternAtom(dpy,"_GNUSTEP_WM_ATTR", False);
2074
2102
// All the windows of a GNUstep application belong to one group.
2075
2103
window->gen_hints.flags |= WindowGroupHint;
2076
2104
window->gen_hints.window_group = ROOT;
2108
* Setup net_wm_sync_request_counter
2112
XSyncIntToValue(&value, 0);
2113
window->net_wm_sync_request_counter = XSyncCreateCounter(dpy, value);
2114
XChangeProperty(dpy,
2116
generic.net_wm_sync_request_counter_atom,
2120
(unsigned char *) &(window->net_wm_sync_request_counter),
2122
window->net_wm_sync_request_counter_value_low = 0;
2123
window->net_wm_sync_request_counter_value_high = 0;
2079
2128
* Prepare the protocols supported by the window.
3053
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
3002
3055
[self _sendRoot: window->root
3003
3056
type: generic.netstates.net_wm_state_atom
3004
3057
window: window->ident
3005
3058
data0: _NET_WM_STATE_ADD
3006
3059
data1: generic.netstates.net_wm_state_skip_taskbar_atom
3007
3060
data2: generic.netstates.net_wm_state_skip_pager_atom
3063
if ((window->win_attrs.window_style & NSIconWindowMask) != 0)
3065
sticky = [defs boolForKey: @"GSStickyAppIcons"];
3067
else if ((window->win_attrs.window_style & NSMiniWindowMask) != 0)
3069
sticky = [defs boolForKey: @"GSStickyMiniWindows"];
3073
[self _sendRoot: window->root
3074
type: generic.netstates.net_wm_state_atom
3075
window: window->ident
3076
data0: _NET_WM_STATE_ADD
3077
data1: generic.netstates.net_wm_state_sticky_atom
4235
/* FIXME: Handle this better or return an error? */
4236
XQueryBestCursor(dpy, ROOT, w, h, &maxw, &maxh);
4237
if ((unsigned int)w > maxw)
4239
if ((unsigned int)h > maxh)
4242
source = xgps_cursor_image(dpy, ROOT, data, w, h, colors, &fg, &bg);
4243
mask = xgps_cursor_mask(dpy, ROOT, data, w, h, colors);
4244
bg = [self xColorFromColor: bg forScreen: defScreen];
4245
fg = [self xColorFromColor: fg forScreen: defScreen];
4247
cursor = XCreatePixmapCursor(dpy, source, mask, &fg, &bg,
4248
(int)hotp.x, (int)hotp.y);
4249
XFreePixmap(dpy, source);
4250
XFreePixmap(dpy, mask);
4321
// FIXME: Standardize getStandardBitmap() so it always returns
4322
// alpha, and document the format.
4330
XcursorImage *xcursorImage;
4331
xcursorImage = XcursorImageCreate(w, h);
4332
xcursorImage->xhot = hotp.x;
4333
xcursorImage->yhot = hotp.y;
4335
// Copy the data from the image rep to the Xcursor structure
4340
bytesPerRow = [rep bytesPerRow];
4342
for (row = 0; row < h; row++)
4344
memcpy((char*)xcursorImage->pixels + (row * (w * 4)),
4345
data + (row * bytesPerRow),
4350
// FIXME: Factor this out
4351
// Convert RGBA unpacked to BGRA packed
4355
unsigned char *cdata;
4358
cdata = (unsigned char *)xcursorImage->pixels;
4360
for (y = 0; y < h; y++)
4362
for (x = 0; x < w; x++)
4364
NSInteger i = (y * stride) + (x * 4);
4365
unsigned char d = cdata[i];
4367
#if GS_WORDS_BIGENDIAN
4368
cdata[i] = cdata[i + 1];
4369
cdata[i + 1] = cdata[i + 2];
4370
cdata[i + 2] = cdata[i + 3];
4373
cdata[i] = cdata[i + 2];
4374
//cdata[i + 1] = cdata[i + 1];
4376
//cdata[i + 3] = cdata[i + 3];
4382
cursor = XcursorImageLoadCursor(dpy, xcursorImage);
4383
XcursorImageDestroy(xcursorImage);
4385
#else // !HAVE_XCURSOR
4387
Pixmap source, mask;
4388
unsigned int maxw, maxh;
4391
/* FIXME: Handle this better or return an error? */
4392
XQueryBestCursor(dpy, ROOT, w, h, &maxw, &maxh);
4393
if ((unsigned int)w > maxw)
4395
if ((unsigned int)h > maxh)
4398
source = xgps_cursor_image(dpy, ROOT, data, w, h, colors, &fg, &bg);
4399
mask = xgps_cursor_mask(dpy, ROOT, data, w, h, colors);
4400
bg = [self xColorFromColor: bg forScreen: defScreen];
4401
fg = [self xColorFromColor: fg forScreen: defScreen];
4403
cursor = XCreatePixmapCursor(dpy, source, mask, &fg, &bg,
4404
(int)hotp.x, (int)hotp.y);
4405
XFreePixmap(dpy, source);
4406
XFreePixmap(dpy, mask);
4252
4411
*cid = (void *)cursor;
4419
4578
- (NSSize) resolutionForScreen: (int)screen_num
4581
// -gui now trusts the return value of resolutionForScreen:,
4582
// so if it is not {72, 72} then the entire UI will be scaled.
4584
// I commented out the implementation below because it may not
4585
// be safe to use the DPI value we get from the X server.
4586
// (i.e. I don't know if it will be a "fake" DPI like 72 or 96,
4587
// or a real measurement reported from the monitor's firmware
4588
// (possibly incorrect?))
4589
// More research needs to be done.
4591
return NSMakeSize(72, 72);
4421
4594
int res_x, res_y;
4423
4596
if (screen_num < 0 || screen_num >= ScreenCount(dpy))