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 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767
|
/* -*-c-*- */
#include "config.h"
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Intrinsic.h>
#include <X11/Xatom.h>
#include <X11/Xproto.h>
#include "libs/FEvent.h"
Display *dpy;
Window Root, win;
int screen;
int has_focus_proto = 0;
int has_delete_proto = 1;
int input_mode = -1;
Atom ATOM_NET_WM_WINDOW_TYPE = None;
Atom ATOM_NET_WM_WINDOW_TYPE_DESKTOP = None;
Atom ATOM_NET_WM_WINDOW_TYPE_DOCK = None;
Atom ATOM_NET_WM_WINDOW_TYPE_TOOLBAR = None;
Atom ATOM_NET_WM_WINDOW_TYPE_MENU = None;
Atom ATOM_NET_WM_WINDOW_TYPE_DIALOG = None;
Atom ATOM_NET_WM_WINDOW_TYPE_NORMAL = None;
Atom ATOM_NET_WM_WINDOW_TYPE_SPLASH = None;
Atom ATOM_NET_WM_WINDOW_TYPE_UTILITY = None;
Atom ATOM_KDE_NET_WM_WINDOW_TYPE_OVERRIDE = None;
Atom ATOM_NET_WM_STATE = None;
Atom ATOM_NET_WM_STATE_MODAL = None;
Atom ATOM_NET_WM_STATE_STICKY = None;
Atom ATOM_NET_WM_STATE_MAXIMIZED_VERT = None;
Atom ATOM_NET_WM_STATE_MAXIMIZED_HORIZ = None;
Atom ATOM_NET_WM_STATE_SHADED = None;
Atom ATOM_NET_WM_STATE_SKIP_TASKBAR = None;
Atom ATOM_NET_WM_STATE_SKIP_PAGER = None;
Atom ATOM_NET_WM_STATE_HIDDEN = None;
Atom ATOM_NET_WM_STATE_STAYS_ON_TOP = None;
Atom ATOM_NET_WM_STATE_FULLSCREEN = None;
Atom ATOM_NET_WM_DESKTOP = None;
/* wm protocol */
Atom ATOM_WM_DELETE_WINDOW = None;
Atom ATOM_WM_TAKE_FOCUS = None;
/* Motif window hints */
Atom ATOM_MOTIF_WM_HINTS = None;
#define MWM_HINTS_FUNCTIONS (1L << 0)
#define MWM_HINTS_DECORATIONS (1L << 1)
#define MWM_HINTS_INPUT_MODE (1L << 2)
#define MWM_HINTS_STATUS (1L << 3) /* ? */
/* bit definitions for MwmHints.functions */
#define MWM_FUNC_ALL (1L << 0)
#define MWM_FUNC_RESIZE (1L << 1)
#define MWM_FUNC_MOVE (1L << 2)
#define MWM_FUNC_MINIMIZE (1L << 3)
#define MWM_FUNC_MAXIMIZE (1L << 4)
#define MWM_FUNC_CLOSE (1L << 5)
/* values for MwmHints.input_mode */
#define MWM_INPUT_MODELESS 0
#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
#define MWM_INPUT_SYSTEM_MODAL 2
#define MWM_INPUT_FULL_APPLICATION_MODAL 3
/* bit definitions for MwmHints.decorations */
#define MWM_DECOR_ALL (1L << 0)
#define MWM_DECOR_BORDER (1L << 1)
#define MWM_DECOR_RESIZEH (1L << 2)
#define MWM_DECOR_TITLE (1L << 3)
#define MWM_DECOR_MENU (1L << 4)
#define MWM_DECOR_MINIMIZE (1L << 5)
#define MWM_DECOR_MAXIMIZE (1L << 6)
/*
* _MWM_HINTS property
*/
typedef struct
{
long props[4];
/* props[0]: flags */
/* props[1]: functions */
/* props[2]: decorations */
/* props[3]: inputMode */
} PropMotifWmHints;
typedef PropMotifWmHints PropMwmHints;
#define PROP_MOTIF_WM_HINTS_ELEMENTS 4
#define PROP_MWM_HINTS_ELEMENTS PROP_MOTIF_WM_HINTS_ELEMENTS
void
Xloop(void)
{
while (1)
{
XEvent ev;
XWindowAttributes xatt;
/* Sit and wait for an event to happen */
FNextEvent(dpy,&ev);
switch(ev.type)
{
case ConfigureNotify:
break;
case ClientMessage:
if (has_delete_proto && ev.xclient.format == 32 &&
ev.xclient.data.l[0] == ATOM_WM_DELETE_WINDOW)
{
exit(0);
}
else if (has_focus_proto &&
ev.xclient.data.l[0] == ATOM_WM_TAKE_FOCUS)
{
printf("WM_TAKE_FOCUS message\n");
if (input_mode == 1)
{
printf ("\t...do nothing\n");
}
else if (input_mode == 0)
{
if (XGetWindowAttributes(dpy, win, &xatt)
&& xatt.map_state == IsViewable)
{
printf ("\t...setting focus on our own: %lu\n",
ev.xclient.data.l[1]);
XSetInputFocus(
dpy, win, RevertToParent,
ev.xclient.data.l[1]);
}
else
{
printf ("\t...but we are not viewable\n");
}
}
}
break;
default:
break;
}
}
}
#define XIA(a) XInternAtom(dpy,a,False);
void InitAtom(void)
{
ATOM_NET_WM_WINDOW_TYPE = XIA("_NET_WM_WINDOW_TYPE");
ATOM_NET_WM_WINDOW_TYPE_DESKTOP = XIA("_NET_WM_WINDOW_TYPE_DESKTOP");
ATOM_NET_WM_WINDOW_TYPE_DOCK = XIA("_NET_WM_WINDOW_TYPE_DOCK");
ATOM_NET_WM_WINDOW_TYPE_TOOLBAR = XIA("_NET_WM_WINDOW_TYPE_TOOLBAR");
ATOM_NET_WM_WINDOW_TYPE_MENU = XIA("_NET_WM_WINDOW_TYPE_MENU");
ATOM_NET_WM_WINDOW_TYPE_DIALOG = XIA("_NET_WM_WINDOW_TYPE_DIALOG");
ATOM_NET_WM_WINDOW_TYPE_NORMAL = XIA("_NET_WM_WINDOW_TYPE_NORMAL");
ATOM_NET_WM_WINDOW_TYPE_SPLASH = XIA("_NET_WM_WINDOW_TYPE_SPLASH");
ATOM_NET_WM_WINDOW_TYPE_UTILITY = XIA("_NET_WM_WINDOW_TYPE_UTILITY");
ATOM_KDE_NET_WM_WINDOW_TYPE_OVERRIDE = XIA("_KDE_NET_WM_WINDOW_TYPE_OVERRIDE");
ATOM_NET_WM_STATE = XIA("_NET_WM_STATE");
ATOM_NET_WM_STATE_MODAL = XIA("_NET_WM_STATE_MODAL");
ATOM_NET_WM_STATE_STICKY = XIA("_NET_WM_STATE_STICKY");
ATOM_NET_WM_STATE_MAXIMIZED_VERT = XIA("_NET_WM_STATE_MAXIMIZED_VERT");
ATOM_NET_WM_STATE_MAXIMIZED_HORIZ = XIA("_NET_WM_STATE_MAXIMIZED_HORIZ");
ATOM_NET_WM_STATE_SHADED = XIA("_NET_WM_STATE_SHADED");
ATOM_NET_WM_STATE_SKIP_TASKBAR = XIA("_NET_WM_STATE_SKIP_TASKBAR");
ATOM_NET_WM_STATE_SKIP_PAGER = XIA("_NET_WM_STATE_SKIP_PAGER");
ATOM_NET_WM_STATE_HIDDEN = XIA("_NET_WM_STATE_HIDDEN");
ATOM_NET_WM_STATE_FULLSCREEN = XIA("_NET_WM_STATE_FULLSCREEN");
ATOM_NET_WM_STATE_STAYS_ON_TOP = XIA("_NET_WM_STATE_STAYS_ON_TOP");
ATOM_NET_WM_DESKTOP = XIA("_NET_WM_DESKTOP");
ATOM_WM_DELETE_WINDOW = XIA("WM_DELETE_WINDOW");
ATOM_WM_TAKE_FOCUS = XIA("WM_TAKE_FOCUS");
ATOM_MOTIF_WM_HINTS = XIA("_MOTIF_WM_HINTS");
}
void show_usage(void)
{
printf("Usage: hints_test OPTIONS\n");
printf("Options:\n");
printf(" --mwm-func <names>\n");
printf(" all, resize, move, minimize, maximize, close\n");
printf(" --mwm-decor <names>\n");
printf(" all, border, resizeh, title, menu, minimize, maximize\n");
printf(" --ewmh-state <names>\n");
printf(" hidden, shaded, sticky, skippager, skiptaskbar,\n");
printf(" maxhoriz, maxvert, modal, staysontop, fullscreen\n");
printf(" --ewmh-type <names>\n");
printf(" normal, dock, toolbar, desktop, menu, dialog, splash, utility\n");
printf(" --mwm-input { modless, app_modal, sys_modal, full_app_modal}\n");
printf(" --ewmh-desktop\n");
printf(" --wm-state { withdrawn, normal, iconic }\n");
printf(" --wm-urgency\n");
printf(" --wm-group { window, root, <win_id> }\n");
printf(" --min-size <width> <height>\n");
printf(" --max-size <width> <height>\n");
printf(" --inc-size <width> <height>\n");
printf(" --p-geometry <geometry>\n");
printf(" --us-geometry <geometry>\n");
printf(" --input { true, false }\n");
printf(" --delete-proto\n");
printf(" --no-delete-proto\n");
printf(" --transient\n");
}
int main(int argc, char **argv)
{
int state_count = 0;
Atom states[10];
Atom type = 0;
int i,x_r,y_r;
unsigned int h_r,w_r;
int ret;
int ewmh_state_arg = 0;
int ewmh_type_arg = 0;
int mwm_func_arg = 0;
int mwm_decor_arg = 0;
int has_ewmh_desktop = 0;
Atom ewmh_desktop = 0;
XSizeHints hints;
XClassHint classhints;
XWMHints wm_hints;
PropMwmHints mwm_hints;
Window trans_win = 0;
if (!(dpy = XOpenDisplay("")))
{
fprintf(stderr, "can't open display\n");
exit(1);
}
screen = DefaultScreen(dpy);
Root = RootWindow(dpy, screen);
InitAtom();
hints.width = 170;
hints.height = 100;
hints.x = 0;
hints.y = 0;
hints.flags = 0;
wm_hints.flags = 0;
mwm_hints.props[0] = 0;
mwm_hints.props[1] = 0;
mwm_hints.props[2] = 0;
mwm_hints.props[3] = 0;
win = XCreateSimpleWindow(
dpy, Root, 0, 0, hints.width, hints.height, 0, 0, 0);
for (i = 1; i < argc; i++)
{
char *error_arg = NULL;
if (strcasecmp(argv[i], "--help") == 0)
{
show_usage();
exit(0);
}
else if (strcasecmp(argv[i], "--ewmh-state") == 0)
{
ewmh_state_arg = 1;
ewmh_type_arg = 0;
mwm_func_arg = 0;
mwm_decor_arg = 0;
}
else if (strcasecmp(argv[i], "--ewmh-type") == 0)
{
ewmh_state_arg = 0;
ewmh_type_arg = 1;
mwm_func_arg = 0;
mwm_decor_arg = 0;
}
else if (strcasecmp(argv[i], "--mwm-func") == 0)
{
ewmh_state_arg = 0;
ewmh_type_arg = 0;
mwm_func_arg = 1;
mwm_decor_arg = 0;
}
else if (strcasecmp(argv[i], "--mwm-decor") == 0)
{
ewmh_state_arg = 0;
ewmh_type_arg = 0;
mwm_func_arg = 0;
mwm_decor_arg = 1;
}
else if (strcasecmp(argv[i], "--min-size") == 0)
{
i++;
hints.min_width = atoi(argv[i]);
i++;
hints.min_height = atoi(argv[i]);
hints.flags |= PMinSize;
}
else if (strcasecmp(argv[i], "--max-size") == 0)
{
i++;
hints.max_width = atoi(argv[i]);
i++;
hints.max_height = atoi(argv[i]);
hints.flags |= PMaxSize;
}
else if (strcasecmp(argv[i], "--inc-size") == 0)
{
i++;
hints.width_inc = atoi(argv[i]);
i++;
hints.height_inc = atoi(argv[i]);
hints.flags |= PResizeInc;
}
else if (strcasecmp(argv[i], "--p-geometry") == 0)
{
i++;
ret = XParseGeometry(argv[i], &x_r, &y_r, &w_r, &h_r);
if ((ret & WidthValue) && (ret & HeightValue))
{
hints.width = w_r;
hints.height = h_r;
hints.flags |= PSize;
}
if ((ret & XValue) && (ret & YValue))
{
hints.x = x_r;
hints.y = y_r;
hints.win_gravity = NorthWestGravity;
if (ret & XNegative)
{
hints.x += XDisplayWidth(dpy, screen) -
hints.width;
hints.win_gravity = NorthEastGravity;
}
if (ret & YNegative)
{
hints.y += XDisplayHeight(dpy, screen) -
hints.height;
if (ret & XNegative)
{
hints.win_gravity =
SouthEastGravity;
}
else
{
hints.win_gravity =
SouthWestGravity;
}
hints.flags |= PWinGravity;
}
hints.flags |= PPosition;
}
}
else if (strcasecmp(argv[i], "--us-geometry") == 0)
{
i++;
ret = XParseGeometry(argv[i], &x_r, &y_r, &w_r, &h_r);
if ((ret & WidthValue) && (ret & HeightValue))
{
hints.width = w_r;
hints.height = h_r;
hints.flags |= USSize;
}
if ((ret & XValue) && (ret & YValue))
{
hints.x = x_r;
hints.y = y_r;
hints.win_gravity=NorthWestGravity;
if (ret & XNegative)
{
hints.x += XDisplayWidth(dpy,screen) -
hints.width;
hints.win_gravity=NorthEastGravity;
}
if (ret & YNegative)
{
hints.y += XDisplayHeight(dpy,screen) -
hints.height;
if (ret & XNegative)
{
hints.win_gravity =
SouthEastGravity;
}
else
{
hints.win_gravity =
SouthWestGravity;
}
}
hints.flags |= USPosition | PWinGravity;
}
}
else if (strcasecmp(argv[i], "--input") == 0)
{
i++;
if (strcasecmp(argv[i], "true") == 0)
{
wm_hints.input = input_mode = True;
wm_hints.flags |= InputHint;
}
else if (strcasecmp(argv[i], "false") == 0)
{
wm_hints.input = input_mode = False;
wm_hints.flags |= InputHint;
}
else
{
error_arg = "--input";
}
}
else if (strcasecmp(argv[i], "--focus-proto") == 0)
{
has_focus_proto = 1;
}
else if (strcasecmp(argv[i], "--no-delete-proto") == 0)
{
has_delete_proto = 0;
}
else if (strcasecmp(argv[i], "--wm-state") == 0)
{
wm_hints.flags |= StateHint;
i++;
if (strcasecmp(argv[i], "withdrawn") == 0)
{
wm_hints.initial_state = WithdrawnState;
}
else if (strcasecmp(argv[i], "normal") == 0)
{
wm_hints.initial_state = NormalState;
}
else if (strcasecmp(argv[i], "iconic") == 0)
{
wm_hints.initial_state = IconicState;
}
else
{
error_arg = "--wm-state";
}
}
else if (strcasecmp(argv[i], "--wm-urgency") == 0)
{
wm_hints.flags |= XUrgencyHint;
}
else if (strcasecmp(argv[i], "--wm-group") == 0)
{
wm_hints.flags |= WindowGroupHint;
i++;
if (strcasecmp(argv[i], "window") == 0)
{
wm_hints.window_group = win;
}
else if (strcasecmp(argv[i], "root") == 0)
{
wm_hints.window_group = Root;
}
else
{
wm_hints.window_group =
strtoul(argv[i], NULL, 0);
}
}
else if (strcasecmp(argv[i], "--transient") == 0)
{
i++;
if (strcasecmp(argv[i],"root") == 0)
{
trans_win = Root;
}
else
{
trans_win = strtoul(argv[i], NULL, 0);
}
}
else if (strcasecmp(argv[i], "--mwm-input") == 0)
{
mwm_hints.props[0] |= MWM_HINTS_INPUT_MODE;
i++;
if (strcasecmp(argv[i], "modless") == 0)
{
mwm_hints.props[3] = MWM_INPUT_MODELESS;
}
else if (strcasecmp(argv[i], "app_modal") == 0)
{
mwm_hints.props[3] =
MWM_INPUT_PRIMARY_APPLICATION_MODAL;
}
else if (strcasecmp(argv[i], "sys_modal") == 0)
{
mwm_hints.props[3] =
MWM_INPUT_SYSTEM_MODAL;
}
else if (strcasecmp(argv[i], "full_app_modal") == 0)
{
mwm_hints.props[3] =
MWM_INPUT_FULL_APPLICATION_MODAL;
}
else
{
error_arg = "--mwm-input";
}
}
else if (strcasecmp(argv[i], "--ewmh-desktop") == 0)
{
has_ewmh_desktop = 1;
i++;
ewmh_desktop = atol(argv[i]);
}
else if (ewmh_state_arg && state_count < 10)
{
if (strcasecmp(argv[i], "hidden") == 0)
{
states[state_count++] =
ATOM_NET_WM_STATE_HIDDEN;
}
else if (strcasecmp(argv[i], "shaded") == 0)
{
states[state_count++] =
ATOM_NET_WM_STATE_SHADED;
}
else if (strcasecmp(argv[i], "sticky") == 0)
{
states[state_count++] =
ATOM_NET_WM_STATE_STICKY;
}
else if (strcasecmp(argv[i], "skippager") == 0)
{
states[state_count++] =
ATOM_NET_WM_STATE_SKIP_PAGER;
}
else if (strcasecmp(argv[i], "skiptaskbar") == 0)
{
states[state_count++] =
ATOM_NET_WM_STATE_SKIP_TASKBAR;
}
else if (strcasecmp(argv[i], "maxhoriz") == 0)
{
states[state_count++] =
ATOM_NET_WM_STATE_MAXIMIZED_HORIZ;
}
else if (strcasecmp(argv[i], "maxvert") == 0)
{
states[state_count++] =
ATOM_NET_WM_STATE_MAXIMIZED_VERT;
}
else if (strcasecmp(argv[i], "modal") == 0)
{
states[state_count++] =
ATOM_NET_WM_STATE_MODAL;
}
else if (strcasecmp(argv[i], "staysontop") == 0)
{
states[state_count++] =
ATOM_NET_WM_STATE_STAYS_ON_TOP;
}
else if (strcasecmp(argv[i], "fullscreen") == 0)
{
states[state_count++] =
ATOM_NET_WM_STATE_FULLSCREEN;
}
else
{
error_arg = "--ewmh-state";
}
}
else if (ewmh_type_arg)
{
if (strcasecmp(argv[i], "normal") == 0)
{
type = ATOM_NET_WM_WINDOW_TYPE_NORMAL;
}
else if (strcasecmp(argv[i], "dock") == 0)
{
type = ATOM_NET_WM_WINDOW_TYPE_DOCK;
}
else if (strcasecmp(argv[i], "toolbar") == 0)
{
type = ATOM_NET_WM_WINDOW_TYPE_TOOLBAR;
}
else if (strcasecmp(argv[i], "desktop") == 0)
{
type = ATOM_NET_WM_WINDOW_TYPE_DESKTOP;
}
else if (strcasecmp(argv[i], "menu") == 0)
{
type = ATOM_NET_WM_WINDOW_TYPE_MENU;
}
else if (strcasecmp(argv[i], "dialog") == 0)
{
type = ATOM_NET_WM_WINDOW_TYPE_DIALOG;
}
else if (strcasecmp(argv[i], "splash") == 0)
{
type = ATOM_NET_WM_WINDOW_TYPE_SPLASH;
}
else if (strcasecmp(argv[i], "utility") == 0)
{
type = ATOM_NET_WM_WINDOW_TYPE_UTILITY;
}
else
{
error_arg = "--ewmh-type";
}
}
else if (mwm_func_arg)
{
mwm_hints.props[0] |= MWM_HINTS_FUNCTIONS;
if (strcasecmp(argv[i], "all") == 0)
{
mwm_hints.props[1] |= MWM_FUNC_ALL;
}
else if (strcasecmp(argv[i], "resize") == 0)
{
mwm_hints.props[1] |= MWM_FUNC_RESIZE;
}
else if (strcasecmp(argv[i], "move") == 0)
{
mwm_hints.props[1] |= MWM_FUNC_MOVE;
}
else if (strcasecmp(argv[i], "minimize") == 0)
{
mwm_hints.props[1] |= MWM_FUNC_MINIMIZE;
}
else if (strcasecmp(argv[i], "maximize") == 0)
{
mwm_hints.props[1] |= MWM_FUNC_MAXIMIZE;
}
else if (strcasecmp(argv[i], "close") == 0)
{
mwm_hints.props[1] |= MWM_FUNC_CLOSE;
}
else
{
error_arg = "--mwm-func";
}
}
else if (mwm_decor_arg)
{
mwm_hints.props[0] |= MWM_HINTS_DECORATIONS;
if (strcasecmp(argv[i], "all") == 0)
{
mwm_hints.props[2] |= MWM_DECOR_ALL;
}
else if (strcasecmp(argv[i], "border") == 0)
{
mwm_hints.props[2] |= MWM_DECOR_BORDER;
}
else if (strcasecmp(argv[i], "resizeh") == 0)
{
mwm_hints.props[2] |= MWM_DECOR_RESIZEH;
}
else if (strcasecmp(argv[i], "title") == 0)
{
mwm_hints.props[2] |= MWM_DECOR_TITLE;
}
else if (strcasecmp(argv[i], "menu") == 0)
{
mwm_hints.props[2] |= MWM_DECOR_MENU;
}
else if (strcasecmp(argv[i], "minimize") == 0)
{
mwm_hints.props[2] |= MWM_DECOR_MINIMIZE;
}
else if (strcasecmp(argv[i], "maximize") == 0)
{
mwm_hints.props[2] |= MWM_DECOR_MAXIMIZE;
}
else
{
error_arg = "--mwm-decor";
}
}
else
{
error_arg = "regular";
}
if (error_arg)
{
show_usage();
printf("Invalid %s argument: %s\n", error_arg, argv[i]);
exit(1);
}
}
XSelectInput(dpy, win, StructureNotifyMask);
if (wm_hints.flags)
{
XSetWMHints(dpy, win, &wm_hints);
}
if (state_count != 0)
{
XChangeProperty(
dpy, win, ATOM_NET_WM_STATE, XA_ATOM, 32,
PropModeReplace, (unsigned char *)states, state_count);
}
if (type != 0)
{
XChangeProperty(
dpy, win, ATOM_NET_WM_WINDOW_TYPE, XA_ATOM, 32,
PropModeReplace, (unsigned char *)&type, 1);
}
if (has_ewmh_desktop)
{
XChangeProperty(
dpy, win, ATOM_NET_WM_DESKTOP, XA_CARDINAL, 32,
PropModeReplace, (unsigned char *)&ewmh_desktop, 1);
}
if (has_delete_proto || has_focus_proto)
{
Atom proto[2];
int j = 0;
if (has_delete_proto)
proto[j++] = ATOM_WM_DELETE_WINDOW;
if (has_focus_proto)
proto[j++] = ATOM_WM_TAKE_FOCUS;
XSetWMProtocols(dpy, win, proto, j);
}
{
XTextProperty nametext;
char *list[] = { NULL, NULL };
list[0] = "Hints Test";
classhints.res_name = strdup("hints_test");
classhints.res_class = strdup("HintsTest");
if (!XStringListToTextProperty(list, 1, &nametext))
{
fprintf(stderr, "Failed to convert name to XText\n");
exit(1);
}
XSetWMProperties(
dpy, win, &nametext, &nametext, NULL, 0, &hints, NULL,
&classhints);
XFree(nametext.value);
}
if (mwm_hints.props[0] != 0)
{
XChangeProperty(
dpy, win, ATOM_MOTIF_WM_HINTS, ATOM_MOTIF_WM_HINTS, 32,
PropModeReplace,(unsigned char *)&mwm_hints,
PROP_MWM_HINTS_ELEMENTS);
}
if (trans_win !=0)
XSetTransientForHint(dpy, win, trans_win);
XMapWindow(dpy, win);
XSetWindowBackground(dpy, win, 0);
Xloop();
return 1;
}
|